I'm trying to compile a 32-bit binary on 64-bit Ubuntu using clang 3.4 and the -m32 option. However, I'm getting the following linker error:
/usr/bin/ld: cannot find crtbegin.o: No such file or directory /usr/bin/ld: cannot find -lgcc /usr/bin/ld: cannot find -lgcc_s clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have 64-bit versions of these libraries, but I can't seem to find the 32-bit versions.
brad@Brad-Laptop:/usr$ find . -name crtbegin.o ./lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o ./lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o brad@Brad-Laptop:/usr$ readelf -h ./lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: REL (Relocatable file) Machine: Advanced Micro Devices X86-64 Version: 0x1 Entry point address: 0x0 Start of program headers: 0 (bytes into file) Start of section headers: 456 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 0 (bytes) Number of program headers: 0 Size of section headers: 64 (bytes) Number of section headers: 16 Section header string table index: 13
Digging around in ubuntu packages I found that gcc-4.6:i386 has a crtbegin.o, but I can't seem to install it.
brad@Brad-Laptop:~/pebble/tintin$ sudo apt-get install gcc-4.6:i386 [sudo] password for brad: Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help resolve the situation: The following packages have unmet dependencies: gcc-4.6:i386 : Depends: binutils:i386 (>= 184.108.40.20630612) but it is not going to be installed Depends: libgomp1:i386 (>= 4.6.4-3ubuntu1) but it is not going to be installed Depends: libquadmath0:i386 (>= 4.6.4-3ubuntu1) but it is not going to be installed E: Unable to correct problems, you have held broken packages.