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.
在此,我采取了以下步骤:
我创建了一个新的Win32项目,名为testlib
,然后从主人那里选择了“DL”和“Empty Project”。
添加一个标题:
//testlib.h
#include <stdio.h>
__declspec(dllexport) void hello();
添加一个来源;由于我希望它成为一C来文方,我读一读,应该简单地将C.c.的档案改成一。
//testlib.c
#include "testlib.h"
void hello() {
printf("DLL hello() called
");
}
建设。
现在,我想在另一个项目中利用我的有益助手。
然后: 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();
}
然后:
我在册子上添加了一条路:
testlib.dll
in Property->VC++Directories-> 可执行目录我在册子上添加了一条路:
testlib.h
in Property->VC++Directories->IncludeDirectories我添加了以下途径:房地产和建筑中的“条码”:条码>;Linker->Input->Additional Dependencies
我试图建设,但我犯了一个联系错误:
LINK : C:path estlibUseDebug estlibUse.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 estlibUseDebug estlibUse.exe : fatal error LNK1120: 1 unresolved externals
如果我回到<条码>测试lib代码>,更名为<条码>测试lib.c,载于<条码>测试校准/代码>,并重建票价,那么,我可以建造<条码>测试校准/代码>,但我在操作时有“没有发现”错误。
I tried also to change the configurations of both projects in "Release" (changing the path where needed), but nothing changed.
Sorry for the long post but I think it was necessary to write down exactly what I did.
任何建议?
此外,如果我想要在Qt项目中使用我的飞机,我是否需要改变配置参数吗?