KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
As per title, I'm trying to build a DLL using C and link it from a C++ project. I read and followed different tutorials on internet but everytime there is something missing and I don't understand what. Here's what I did, step by step: I created a new Win32 project, named testlib , then, from the wizard, I chose "DLL" and "Empty project". Added a header: //testlib.h #include <stdio.h> __declspec(dllexport) void hello(); Added a source; since I want it to be a C source I read I should simplly rename the .cpp file in .c, so //testlib.c #include "testlib.h" void hello() { printf("DLL hello() called\n"); } Build succeded. Now I would like to use my useful dll in another project. Then: new project ( testlibUse ). This time I selected "Empty project". No need to add an header, just created a cpp source //main.cpp #include <testlib.h> int main() { hello(); } Then: I added the path to the folder where is testlib.dll in Properties->VC++ directories->Executable directories I added the path to the folder where is testlib.h in Properties->VC++ directories->Include directories I added the path to testlib.lib (included extension) in Properties->Linker->Input->Additional dependencies I tried to build but I got a linker error: LINK : C:\path\testlibUse\Debug\testlibUse.exe not found or not built by the last incremental link; performing full link main.obj : error LNK2019: unresolved external symbol "void __cdecl hello(void)" (?hello@@YAXXZ) referenced in function _main C:\path\testlibUse\Debug\testlibUse.exe : fatal error LNK1120: 1 unresolved externals If I go back to testlib , rename back testlib.c</cod
Tags (comma-separated)
Save Edits
Cancel