我正在尝试用 make 编译一个程序,但我卡在了一个出现的错误上(见下文):
gcc -Wall -g -O2 -I. -I../include -I/usr/include/libxml2/ -I/usr/include/x86_64-linux-gnu/ -I/usr/include/geotiff/ -I/usr/local/hdf4/hdf-4.2.11/hdf4/include/ -I/usr/local/hdf-eos/hdfeos/include/ -I -I -o convert_lpgs_to_espa convert_lpgs_to_espa.o -L../lib -l_espa_format_conversion -l_espa_raw_binary -l_espa_common -L/usr/lib/x86_64-linux-gnu/ -lxml2 -L/usr/lib/ -lgeotiff -L/usr/lib/x86_64-linux-gnu/ -ltiff -L/usr/lib/x86_64-linux-gnu/ -ljpeg -L -ljbig -L/usr/local/hdf-eos/hdfeos/hdfeos2/lib -lgctp -L -lz -lm
/usr/lib/x86_64-linux-gnu/libicuuc.so.52: référence indéfinie vers « __cxa_throw_bad_array_new_length@CXXABI_1.3.8 »
collect2: error: ld returned 1 exit status
Makefile:95: recipe for target 'convert_lpgs_to_espa' failed
make[1]: *** [convert_lpgs_to_espa] Error 1
make[1]: Leaving directory '/project/$folders$/tools'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2
紧接着这个问题:program linking fails when using custom built gcc ,我清除并重新安装 libstdc++-4.9-dev。
我在跑 带有 gcc 的 Ubuntu 15.04 (Ubuntu 4.9.2-10ubuntu13) 4.9.2
我该如何解决这个问题?
最佳答案
这是因为您使用 gcc
而不是 g++
进行链接。不同之处在于g++
命令在链接时添加了C++运行时库。
您可以从使用 gcc
更改为 g++
,或者通过添加 -lstdc++
手动链接到 C++ runtme 库。
关于c++ - undefined reference gcc cxa,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31919725/