How do I get GCC to compile object files correctly without “file was built for unsupported file format”?

StackOverflow https://stackoverflow.com/questions/12254907

문제

I get this error when compiling:

ld: warning: ignoring file /Users/matt/Programming/BitEagle_Projects/cbitcoin/build/obj/CBNetworkFunctions.o, file was built for unsupported file format ( 0x7f 0x45 0x4c 0x46 0x 2 0x 1 0x 1 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 0x 0 ) which is not the architecture being linked (x86_64): /Users/matt/Programming/BitEagle_Projects/cbitcoin/build/obj/CBNetworkFunctions.o

And for every other object file when compiling object files with:

gcc -c -O2 -Wall -Wno-overflow -pedantic -std=c99 -I/Path/To/Headers -m64 -o objFile.o srcFile.c

I try to link the files using:

gcc -dynamiclib -Wl -flat_namespace -undefined dynamic_lookup -o libwhatever objFile1.o objFile2.o

So what is causing this problem?

The gcc version is: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

Thank you.

도움이 되었습니까?

해결책

The header information in the first error message indicates that CBNetworkFunctions.o is an ELF (probably Linux) object file, not an OS X Mach-O object file.

If this object file is not being created by your build process, you will need to remove it and replace it with one built by the Mac OS X toolchain.

If it is being created by your build process, something very odd is going on, and you will need to give us some more details on what you're doing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top