gpt4 book ai didi

c++ - 神秘的链接器错误 "undefined reference to ` __gxx_personality_v 0'"在 cygwin 中使用 clang

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:37:36 26 4
gpt4 key购买 nike

我做了一些搜索,所有答案似乎都建议使用 clang++ 而不是 clang(或者更确切地说是 g++ 代替 gcc),这就是我最初所做的。尽管如此,问题仍然存在,无论是

clang++ -Wall -std=c++11 -o test.exe test.cpp A.cpp B.cpp etc.cpp

clang++ -lstdc++ -Wall -std=c++11 -o test.exe test.cpp A.cpp B.cpp etc.cpp

编译和链接在 Cygwin 中使用 g++ 工作正常。

g++ -Wall -std=c++11 -o test.exe test.cpp A.cpp B.cpp etc.cpp

更新:

这是链接期间的信息。 clang 是否尝试使用 gcc 而不是 g++ 进行链接?在那种情况下,为什么没有像下面建议的那样标记 -lstdc++ 和 -lsupc++ 起作用?

COMPILER_PATH=/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/lib/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-m64' '-o' 'testReSampling.exe' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/collect2.exe --build-id -m i386pep --wrap _Znwm --wrap _Znam --wrap _ZdlPv --wrap _ZdaPv --wrap _ZnwmRKSt9nothrow_t --wrap _ZnamRKSt9nothrow_t --wrap _ZdlPvRKSt9nothrow_t --wrap _ZdaPvRKSt9nothrow_t -Bdynamic --dll-search-prefix=cyg --tsaware -o testReSampling.exe /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib/crt0.o /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/crtbegin.o -L/usr/lib/gcc/x86_64-pc-cygwin/4.8.3 -L/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/lib/../lib -L/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/lib -L/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../.. -lsupc++ /tmp/misc-8020e8.o /tmp/DataStruct-b10944.o /tmp/HyperGeometricPVal-edef1c.o /tmp/Array2EG-3441bb.o /tmp/GOCats-ff22c1.o /tmp/UGraph-10cfd8.o /tmp/testReSampling-9fb18c.o -lstdc++ -lgcc_s -lgcc -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32 -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib/default-manifest.o /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/crtend.o
/tmp/misc-8020e8.o:fake:(.eh_frame+0x47): undefined reference to `__gxx_personality_v0'
/tmp/misc-8020e8.o:fake:(.eh_frame$_ZNSt6vectorISsSaISsEE5clearEv+0x13): undefined reference to `__gxx_personality_v0'
/tmp/misc-8020e8.o:fake:(.eh_frame$_ZNSt6vectorISt4pairIjS0_ItdEESaIS2_EE5beginEv+0x13): undefined reference to `__gxx_personality_v0'
/tmp/misc-8020e8.o:fake:(.eh_frame$_ZNSt6vectorISt4pairIjS0_ItdEESaIS2_EE3endEv+0x13): undefined reference to `__gxx_personality_v0'
/tmp/misc-8020e8.o:fake:(.eh_frame$_ZNSt6vectorISt4pairIjS0_ItSt5arrayIdLm2EEEESaIS4_EE5beginEv+0x13): undefined reference to `__gxx_personality_v0'
/tmp/misc-8020e8.o:fake:(.eh_frame$_ZNSt6vectorISt4pairIjS0_ItSt5arrayIdLm2EEEESaIS4_EE3endEv+0x13): more undefined references to `__gxx_personality_v0' follow
collect2: error: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)

最佳答案

找到这个解决方案:

https://cygwin.com/ml/cygwin/2015-06/msg00294.html

基本上只需在编译时在命令行上添加 -fno-exceptions 例如 clang++ helloworld.cpp -std=c++11 -fno-exceptions

关于c++ - 神秘的链接器错误 "undefined reference to ` __gxx_personality_v 0'"在 cygwin 中使用 clang,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27084182/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com