Eclipse CDT中无法解析的外部符号 [英] unresolved external symbol in eclipse cdt

查看:266
本文介绍了Eclipse CDT中无法解析的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Eclipse CDT构建cpp文件.链接器抛出无法解析的外部符号",但是Project properties->C/C++ Build->Environment

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

我在做什么错了?

UPD 我尝试构建链接器失败:

**** 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'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.

您似乎正在使用从未使用过的Microsoft链接程序,因此无法为您提供特定的标志,但是如果出现问题,应该很容易找到文档中的内容.我认为Eclipse也有一种在GUI中指定此方法的方法,该方法应该在它支持的各种编译器中通用.

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.

这篇关于Eclipse CDT中无法解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆