Re: Dll Application Error
I hate how this website doesn't indent -.-
Re: Dll Application Error
Quote:
Originally Posted by
VitexHD
I hate how this website doesn't indent -.-
You should hate yourself because you didn't read the Announcement, Information on posting and Including Code sections.
Re: Dll Application Error
Simply, you don't put templated code in a .dll. The templated code needs to be in the same compilation unit as the code that invokes it. As Simplemaths() invokes templated VitexMaths(), then they both need to be in the same compilation unit.
Also note that SimpleMaths() is a templated function, but its forward declaration is not.
Re: Dll Application Error
Quote:
Originally Posted by
VitexHD
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
The thing is you cannot place a template into dll unless it's some instantiated template class or a few ones. You place in dll the code that was able to build, but not an abstract template that is to be turned to real code at compile time. Just because the dll compile time is history when you load the dll at runtime.
The thing is pretty obvious, but it rarely occurs to C++ beginners. Now when you are properly informed you are to revise your approach.