首页 > 解决方案 > Multiple definition error while linking: multiple definition of `typeinfo name

问题描述

I'm very new to c++ (my background is in python and java) and I'm trying to build the cockroachdb project on a raspberry pi. To build I ran the command make build -j1.

However I am getting the error below:

[  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

I went to CMakeFiles/geos.dir/build.make and on line 4569 I see: $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/geos.dir/link.txt --verbose=$(VERBOSE) but I don't really know what is wrong and what to do next to fix this.

Can someone help out a c++ beginner? Thank you.

标签: c++linkerlinker-errors

解决方案


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


推荐阅读