我一直试图用gcc在solaris建立一个库,并不断地碰到wrong ELF class: ELFCLASS64错误。我搜索并发现,这是由于试图链接到一个32位文件,编译为64位库。但是,我确保使用-m64编译器选项将rakesh.o构建为64位。
/rdcomb/run/pd/gcc/32-bit/4.4.1/bin/g++ -Wall -W -Wunreachable-code -Winline -Wshadow -Weffc++ -Wfloat-equal -Wunsafe-loop-optimizations -Wcast-qual -Wdisabled-optimization -shared -fPIC -m64 -c -DDEBUG -I../include -I/home/radha/ali/trunk/src/top//src/ -I../../../top/include -g -o Suni386/dll/rakesh.o rakesh.cpp
xmake: /home/radha/ali/trunk/src/tools/bin/Suni386/xlink -g -o Suni386/dll/rakesh -p../../../top/gtcpp/Suni386/dll -lgtcpp -lsocket -lnsl Suni386/dll/rakesh.o
ld: fatal: file Suni386/dll/rakesh.o: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to Suni386/dll/rakesh
collect2: ld returned 1 exit status
/rdcomb/run/pd/gcc/32-bit/4.4.1/bin/g++ -g -o Suni386/dll/rakesh -L../../../top/gtcpp/Suni386/dll Suni386/dll/rakesh.o -lgtcpp -lsocket -lnsl
xmake: /home/radha/ali/trunk/src/tools/bin/Suni386/xlink: error 1 (0x1)我在这里做错什么了?是因为使用或缺少了某个编译器标志吗?
发布于 2015-04-27 10:38:50
您还必须为链接器提供-m64标志,以便它知道预期的二进制文件类型。
https://stackoverflow.com/questions/29892945
复制相似问题