错误:未定义对"静脉类型信息::电池访问"的引用



我在基于David Eckhoff Veins/Sumo项目的Omnet++项目中收到此错误。

错误是(也许(因为该omnet++中使用的版本是4.6,而我正在使用的版本是5.0。 尽管如此,我一直试图找到一个逻辑解决方案,但没有任何成功。

make MODE=debug all 
src/TutorialAppl.cpp
In file included from src/TutorialAppl.cpp:3:
In file included from src/TutorialAppl.h:12:
In file included from C:/Users/konra/OneDrive/Escritorio/SUMO_VEINS_OMNET/veins-5.0/veins-veins-5.0/srcveins/modules/messages/WaveShortMessage_m.h:33:
C:/Users/konra/OneDrive/Escritorio/SUMO_VEINS_OMNET/veins-5.0/veins-veins-5.0/srcveins/base/utils/Coord.h:329:27: warning: 'veins::Coord::info' redeclared inline; 'dllimport' attribute ignored [-Wignored-attributes]
inline std::string Coord::info() const
^
1 warning generated.
Creating executable: out/clang-debug//VeinsTutorial_dbg.exe
out/clang-debug//src/TutorialAppl.o:(.rdata[_ZTIN5veins9BaseLayerE]+0x10): undefined reference to `typeinfo for veins::BatteryAccess'
out/clang-debug//src/TutorialAppl.o:(.rdata[_ZTIN5veins12BaseMobilityE]+0x10): undefined reference to `typeinfo for veins::BatteryAccess'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:101: out/clang-debug//VeinsTutorial_dbg.exe] Error 1
"make MODE=debug all" terminated with exit code 2. Build might be incomplete.

哦,这是一个编译器错误(clang(。

clang 编译器不会将类型信息符号标记为可在 Windows 上导出。这通常不会被注意到,除非您尝试在依赖于它的项目中使用来自基本项目(静脉(的抽象类。抽象类也经常用于定义 Veins、INET 和 OMNeT++ 中的接口。

INET中有一个解决方法,也可以在您自己的项目中实现(也可以在静脉中实现(,但它非常丑陋,每次都需要重新链接库,因此链接时间大大增加。

其他更直接的解决方法:

  • -Wl,--export-all-symbols添加到 Veins 中的链接器命令行以强制导出所有符号。(静脉足够小,不会导致 Windows 上导出符号数量的 65K 限制出现问题(
  • 在Windows上使用GCC而不是clang(你也应该重建omnet++(
  • 使用 Linux/macOS
  • 使用静态链接

最新更新