error LNK2001 while trying to make a dll file
I'm trying to make a dll. When I compile the cpp file, it compiles alright but when making the dll it shows these errors:
Linking...
Creating library Debug/ServerExtApp.lib and object Debug/ServerExtApp.exp
ServerExtApp.obj : error LNK2001: unresolved external symbol "public: void __thiscall ServerExt::respond(int)" (?respond@ServerExt@@QAEXH@Z)
ServerExtApp.obj : error LNK2001: unresolved external symbol "public: static class ServerExt * __cdecl ServerExt::create(struct CEE_handle_tag const *,char const *,long,long *,void * *,struct CEE_handle_tag *,class ServerExt * (__cdecl*)(void))" (?c
reate@ServerExt@@SAPAV1@PBUCEE_handle_tag@@PBDJPAJPAPAXPAU2@P6APAV1@XZ@Z)
Debug/ServerExtApp.dll : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Can someone please help me to resolve these errors?
[1155 byte] By [
VíctorM.] at [2007-12-17]
Some things to check:
1) The *.obj or *.lib that contains the definition of these functions is being included.
2) The definition/declaration of these functions match on both sides (this includes the calling convention)
3) The files are being compiled with exactly the same options: you haven't changed the default calling convention.
1) When I create the proyect and then start making the dll, the *.obj and the *.lib are created by VC++, so I don't know what is in them. ?Is there another way to create these files?
2) The definition/declaration do match on both sides. (what do you mean by calling convention)
3) Where do I check the default calling convention.
1) They can be created by C# or VB but by the looks of your code I suspect they were created by C++.
2) Calling convention is the convention that the compiler uses to pass arguments (and the return type) between a caller and a callee. The possible calling conventions in Visual C++ are __cdecl, __stdcall, __fastcall, __thiscall, and __clrcall. Of the five most users only have to worry about the first three.
3) The default calling convention is specified by three switches:
/Gd: this is __cdecl and it is the "default" default calling convention
/Gz: this is __stdcall
/Gr: this is __fastcall
Are both functions that you are getting a linker error for defined in the same file and is there nothing else in this file that your program depends upon? If this is the case then I would double check that *.obj (or *.lib) file created from this file is actually being included at the link step.
If the functions are defined in a file in which there are other functions that your program depends upon and these functions are not giving a linker error then I would double check that the declarations match in all files.