CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Sep 2017
    Posts
    2

    Dll Application Error

    ===============Program===============
    --->Main.cpp<---
    Code:
    #include "Dll_VitexMaths.h"
    #include <iostream>
    
    void SimpleMaths();
    
    int main() {
    	/* Check For Memory Leaks */
    	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
    
    	SimpleMaths();
    
    	return EXIT_SUCCESS;
    }
    
    template<typename T>
    void SimpleMaths() {
    	Dll_VitexMaths<T>* VitexMaths<T> = new Dll_VitexMaths<T>();
    	T VM_Value;
    	T VM_MultiplyBy;
    
    	/* Main Code */
    	std::cout << "Enter a Number: ";
    	std::cin >> VM_Value;
    	std::cout << "Multiply " << VM_Value << " By: ";
    	std::cin >> VM_MultiplyBy;
    
    	std::cout << "Your End Value Is: " << VitexMaths<T>->Multiply(VM_Value, VM_MultiplyBy) << "\n";
    
    	system("PAUSE >NULL");
    
    	delete VitexMaths;
    }
    ===============Dll===============
    --->Dll_VitexMaths.cpp<---
    Code:
    #include "Dll_VitexMaths.h"
    
    template<typename T>
    T Dll_VitexMaths<T>::Multiply(const T value, const T multiplyBy) {
    	value *= multiplyBy;
    
    	return value;
    }
    ===============Dll===============
    --->Dll_VitexMaths.h<---
    Code:
    #ifndef Dll_VitexMaths_H
    #define Dll_VitexMaths_H
    
    template<typename T>
    class __declspec(dllexport) Dll_VitexMaths {
    public:
    	T Multiply(const T value, const T multiplyBy);
    };
    
    #endif /* Dll_VitexMaths_H */
    ================================

    Hello, I've made a simple program which uses a Dll to do math stuff like multiplying integers, but then I decided to make it a template and now I have the error:
    Severity Code Description Project File Line Suppression State
    Error LNK2019 unresolved external symbol "void __cdecl SimpleMaths(void)" (?SimpleMaths@@YAXXZ) referenced in function _main Simple Maths L:\C++\PROGRAMS\Simple Maths\Simple Maths\Main.obj 1

    from the application that uses the Dll, the error isn't in the Dll I don't think, I may have done something wrong in my program.
    The Dll_VitexMaths.cpp/.h is in the project/Source/Dll_VitexMaths/ so I'm not sure if it's reading it correctly, I also included the Dll cpp file in my program and that didn't change anything, any help? Thanks
    Also quickly, everything is linked properly.
    Last edited by 2kaud; September 21st, 2017 at 03:35 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured