问题表现:
4>libeventmanager.lib(CommandLoop.obj) : error LNK2019: unresolved external symbol "double __cdecl tn::simple_time::steady_time(void)" (?steady_time@simple_time@tn@@YANXZ) referenced in function "public: bool __thiscall Tn::EventManager::CommandLoop::runNextCommand(void)"
(?runNextCommand@CommandLoop@EventManager@Tn@@QAE_NXZ)
4>libeventmanager.lib(CommandLoop.obj) : error LNK2019: unresolved external symbol "bool __cdecl tn::simple_time::wait_for(class boost::condition_variable &,class boost::unique_lock<class boost::mutex> &,double)" (?wait_for@simple_time@tn@@YA_NAAVcondition_variable@boost@@AAV?$unique_lock@Vmutex@boost@@@4@N@Z) referenced in function "public: void __thiscall Tn::EventManager::CommandLoop::run(unsigned int)" (?run@CommandLoop@EventManager@Tn@@QAEXI@Z)
4>D:\RhineSDKTrunk\bindings\cpp-events\TestProxy\build\TestProxy-win32\Debug\TestProxy.dll : fatal error LNK1120: 2 unresolved externals
4>libeventmanager.lib(CommandLoop.obj) : error LNK2019: unresolved external symbol "bool __cdecl tn::simple_time::wait_for(class boost::condition_variable &,class boost::unique_lock<class boost::mutex> &,double)" (?wait_for@simple_time@tn@@YA_NAAVcondition_variable@boost@@AAV?$unique_lock@Vmutex@boost@@@4@N@Z) referenced in function "public: void __thiscall Tn::EventManager::CommandLoop::run(unsigned int)" (?run@CommandLoop@EventManager@Tn@@QAEXI@Z)
4>D:\RhineSDKTrunk\bindings\cpp-events\TestProxy\build\TestProxy-win32\Debug\TestProxy.dll : fatal error LNK1120: 2 unresolved externals
问题原因:
大部分链接的问题都是找不到函数的定义,这里是找不到steady_time()函数的定义
解决方法:
在cmakelist.txt 里面增加下面内容,增加引用库libfoundation.lib, steady_time()的定义就在这个库里面
target_link_libraries(TestProxy
debug ${PROJECT_SOURCE_DIR}/../../modules/${TNPLATFORM}/lib/debug/libfoundation.lib
optimized ${PROJECT_SOURCE_DIR}/../../modules/${TNPLATFORM}/lib/release/libfoundation.lib)
debug ${PROJECT_SOURCE_DIR}/../../modules/${TNPLATFORM}/lib/debug/libfoundation.lib
optimized ${PROJECT_SOURCE_DIR}/../../modules/${TNPLATFORM}/lib/release/libfoundation.lib)
本文介绍了解决在构建过程中遇到的LNK2019错误的方法,特别是未解析外部符号问题,通过正确配置CMakeLists.txt文件并引入必要的库来解决。

被折叠的 条评论
为什么被折叠?



