链接器错误 - 未定义的符号
Linker error - Undefined symbols
问候语
我已经在 VS2013
(1.2.0-rc3) 中下载并编译了 log4cplus
。编译很好(调试和发布)我尝试在我的代码中使用它,但我收到很多 link 错误,我尝试的任何事情都没有删除它们。我正在使用来自 log4cplus 项目的相同包含,以及我编译的库,但我仍然得到这些。
1>------ Build started: Project: MYPROJECT, Configuration: Debug Win32 ------
1>utility.cpp.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>utility.cpp.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>device.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>path_tree.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>cim_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>pin_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>nautilus.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>ravis.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>ncr.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>wincore.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>atm_utility.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>banqit.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>grg.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>king_teller.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>supervisor_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>registry_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>device_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>atm_factory.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>database_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>user_interface.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>fit_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
我在这里缺少什么?!
提前致谢
找到问题了!!
我必须在我的项目 CMakeLists.txt
中将 /Zc:wchar_t
设置为 set_target_properties
。
set_target_properties(MYPROJECT PROPERTIES COMPILE_FLAGS "/W2 /Zc:wchar_t")
问候语
我已经在 VS2013
(1.2.0-rc3) 中下载并编译了 log4cplus
。编译很好(调试和发布)我尝试在我的代码中使用它,但我收到很多 link 错误,我尝试的任何事情都没有删除它们。我正在使用来自 log4cplus 项目的相同包含,以及我编译的库,但我仍然得到这些。
1>------ Build started: Project: MYPROJECT, Configuration: Debug Win32 ------
1>utility.cpp.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>utility.cpp.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>device.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>path_tree.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>cim_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>pin_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>nautilus.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>ravis.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>ncr.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>wincore.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>atm_utility.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>banqit.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>grg.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>king_teller.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>supervisor_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>registry_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>device_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>atm_factory.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>database_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>user_interface.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
1>fit_manager.obj : error LNK2001: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
我在这里缺少什么?!
提前致谢
找到问题了!!
我必须在我的项目 CMakeLists.txt
中将 /Zc:wchar_t
设置为 set_target_properties
。
set_target_properties(MYPROJECT PROPERTIES COMPILE_FLAGS "/W2 /Zc:wchar_t")