Eclipse CDT 中未解析的外部符号
我尝试使用 eclipse cdt 构建 cpp 文件。链接器抛出“无法解析的外部符号”,但是包含函数实现的 lib 文件的路径列在 Project Properties->C/C++ Build->Environment
上的 LIB 环境变量中
我做错了什么?
UPD 我尝试构建 文件。路径 C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\
上有 lib RpcRT4.Lib
并且链接器失败:
**** Build of configuration Debug for project test cpp ****
**** Internal Builder is used for build ****
link /debug /nologo /OUT:test cpp.exe main.obj
main.obj : error LNK2019: unresolved external symbol __imp__RpcStringFreeA@4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)"(?Initialize_CreateWindowClass@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__RegisterClassA@4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__UuidToStringA@8 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__UuidCreate@4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcA@16 referenced in function "long __stdcall SkypeAPITest_Windows_WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?SkypeAPITest_Windows_WindowProc@@YGJPAUHWND__@@IIJ@Z)
main.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage@4 referenced in function "long __stdcall SkypeAPITest_Windows_WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?SkypeAPITest_Windows_WindowProc@@YGJPAUHWND__@@IIJ@Z)
main.obj : error LNK2019: unresolved external symbol __imp__UnregisterClassA@8 referenced in function "void __cdecl DeInitialize_DestroyWindowClass(void)" (?DeInitialize_DestroyWindowClass@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function "bool __cdecl Initialize_CreateMainWindow(void)" (?Initialize_CreateMainWindow@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DestroyWindow@4 referenced in function "void __cdecl DeInitialize_DestroyMainWindow(void)" (?DeInitialize_DestroyMainWindow@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageA@4 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__GetMessageA@16 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__PostMessageA@16 referenced in function "void __cdecl Global_InputProcessingThread(void *)" (?Global_InputProcessingThread@@YAXPAX@Z)
main.obj : error LNK2019: unresolved external symbol __imp__SendMessageA@16 referenced in function "void __cdecl Global_InputProcessingThread(void *)" (?Global_InputProcessingThread@@YAXPAX@Z)
main.obj : error LNK2019: unresolved external symbol __imp__RegisterWindowMessageA@4 referenced in function _main
test cpp.exe : fatal error LNK1120: 15 unresolved externals
Build error occurred, build is stopped
Time consumed: 2438 ms.
I try to build cpp file using eclipse cdt. Linker throws "unresolved external symbol", however path to lib file that contains implementation for function is listed in LIB environment variable on Project properties->C/C++ Build->Environment
What am I doing wrong?
UPD I try to build file. There is lib RpcRT4.Lib
on the path C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\
And linker fails:
**** Build of configuration Debug for project test cpp ****
**** Internal Builder is used for build ****
link /debug /nologo /OUT:test cpp.exe main.obj
main.obj : error LNK2019: unresolved external symbol __imp__RpcStringFreeA@4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)"(?Initialize_CreateWindowClass@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__RegisterClassA@4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__UuidToStringA@8 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__UuidCreate@4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcA@16 referenced in function "long __stdcall SkypeAPITest_Windows_WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?SkypeAPITest_Windows_WindowProc@@YGJPAUHWND__@@IIJ@Z)
main.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage@4 referenced in function "long __stdcall SkypeAPITest_Windows_WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?SkypeAPITest_Windows_WindowProc@@YGJPAUHWND__@@IIJ@Z)
main.obj : error LNK2019: unresolved external symbol __imp__UnregisterClassA@8 referenced in function "void __cdecl DeInitialize_DestroyWindowClass(void)" (?DeInitialize_DestroyWindowClass@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function "bool __cdecl Initialize_CreateMainWindow(void)" (?Initialize_CreateMainWindow@@YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DestroyWindow@4 referenced in function "void __cdecl DeInitialize_DestroyMainWindow(void)" (?DeInitialize_DestroyMainWindow@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageA@4 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__GetMessageA@16 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__PostMessageA@16 referenced in function "void __cdecl Global_InputProcessingThread(void *)" (?Global_InputProcessingThread@@YAXPAX@Z)
main.obj : error LNK2019: unresolved external symbol __imp__SendMessageA@16 referenced in function "void __cdecl Global_InputProcessingThread(void *)" (?Global_InputProcessingThread@@YAXPAX@Z)
main.obj : error LNK2019: unresolved external symbol __imp__RegisterWindowMessageA@4 referenced in function _main
test cpp.exe : fatal error LNK1120: 15 unresolved externals
Build error occurred, build is stopped
Time consumed: 2438 ms.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全清楚您是否已经根据问题完成了此操作,但仅将目录添加到链接器的搜索路径对于我曾经使用过的任何编译器/链接器来说是不够的。其中可能有数百个不同的库,甚至是同一库的不同版本,并且链接器不知道您想要哪些和不想要哪些。您需要明确地告诉它使用适当的参数链接到库。
看起来您正在使用 Microsoft 链接器,我从未使用过它,所以我无法帮助您了解特定的标志,但如果这是问题所在,应该很容易在文档中找到它是什么。我认为 Eclipse 也有一种在 GUI 中指定这一点的方法,该方法在它支持的各种编译器中应该是通用的。
I'm not entirely clear on whether you've already done this based on the question, but just adding the directory to your linker's search path isn't enough for any compiler/linker I've ever used. There could be hundreds of different libraries in there, even different versions of the same library, and the linker has no idea which ones you do and don't want. You need to tell it, explicitly, to link against the library using the appropriate parameter.
It looks like you're using the Microsoft linker, which I've never used, so I can't help you with the specific flag but it should be easy enough to find what it is in the documentation if that's the issue. I presume Eclipse has a method of specifying this in the GUI as well which should be generic across the various compilers it supports.