【问题标题】:Multiple definition error while linking: multiple definition of `typeinfo name链接时出现多重定义错误:`typeinfo name 的多重定义
【发布时间】:2021-02-09 02:45:17
【问题描述】:

我对 c++ 很陌生(我的背景是 python 和 java),我正在尝试在树莓派上构建 cockroachdb 项目。为了构建,我运行了命令 make build -j1。

但是我收到以下错误:

[  0%] Linking CXX shared library lib/libgeos.so
/usr/bin/ld: CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o:(.rodata+0x0): multiple definition of `typeinfo name for geos::noding::BasicSegmentString'; CMakeFiles/geos.dir/src/inlines.cpp.o:(.rodata+0x6c): first defined here
/usr/bin/ld: CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o:(.data.rel.ro+0x0): multiple definition of `typeinfo for geos::noding::BasicSegmentString'; CMakeFiles/geos.dir/src/inlines.cpp.o:(.data.rel.ro+0x20): first defined here
/usr/bin/ld: CMakeFiles/geos.dir/src/noding/BasicSegmentString.cpp.o:(.data.rel.ro+0xc): multiple definition of `vtable for geos::noding::BasicSegmentString'; CMakeFiles/geos.dir/src/inlines.cpp.o:(.data.rel.ro+0xac): first defined here
collect2: error: ld returned 1 exit status
make[4]: *** [CMakeFiles/geos.dir/build.make:4569: lib/libgeos.so.3.8.1] Error 1
make[3]: *** [CMakeFiles/Makefile2:569: CMakeFiles/geos.dir/all] Error 2
make[2]: *** [CMakeFiles/Makefile2:616: CMakeFiles/geos_c.dir/rule] Error 2
make[1]: *** [Makefile:418: geos_c] Error 2
make: *** [Makefile:757: libgeos_inner] Error 2

我去了CMakeFiles/geos.dir/build.make,在第4569行我看到: $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/geos.dir/link.txt --verbose=$(VERBOSE) 但我真的不知道出了什么问题以及接下来要做什么来解决这个问题。

有人可以帮助 C++ 初学者吗?谢谢。

【问题讨论】:

    标签: c++ linker linker-errors


    【解决方案1】:

    显然the issue 已经存在了一段时间。解决方法是按照该页面的说明提供 -DDISABLE_GEOS_INLINE=ON。
    虽然GEOS Website 上各个开关的名称不同,但这似乎是过时的信息并且不起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-23
      • 2012-04-15
      • 1970-01-01
      • 2013-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多