I'm trying to cross compile bluez 4.60 to a 32bit arm platform, when I try and cross compile using the following command:
./configure '--enable-shared=yes' '--enable-static=no' '--disable-network' '--enable-sap' '--disable-serial' '--enable-input' '--disable-audio' '--disable-service' '--enable-health' '--disable-pnat' '--disable-gstreamer' '--disable-alsa' '--enable-usb' '--disable-tools' '--disable-bccmd' '--disable-pcmcia' '--enable-hid2hci' '--enable-dfutool' '--enable-hidd' '--enable-pand' '--enable-dund' '--disable-cups' '--disable-test' '--disable-datafiles' '--enable-maemo6' '--enable-dbusoob' '--disable-wiimote' '--enable-hal' '--disable-gatt' '--disable-udevrules' '--disable-configfiles' --build=x86_64-linux-gnu --host=arm-linux-gnueabihf
I get:
<toolchain>/7.3.0/real-ld: cannot find crti.o: No such file or directory
<toolchain>/7.3.0/real-ld: cannot find crtbeginS.o: No such file or directory
<toolchain>/7.3.0/real-ld: cannot find -ludev
<toolchain>/7.3.0/real-ld: cannot find -lgcc
<toolchain>/7.3.0/real-ld: cannot find -lgcc_s
<toolchain>/7.3.0/real-ld: cannot find -lc
<toolchain>/7.3.0/real-ld: cannot find -lgcc
<toolchain>/7.3.0/real-ld: cannot find -lgcc_s
<toolchain>/7.3.0/real-ld: cannot find crtendS.o: No such file or directory
<toolchain>/7.3.0/real-ld: cannot find crtn.o: No such file or directory
after some search it seems that -lc and -lgcc etc., are from libc. the -ludev made me think it was failing to find any libraries at all in the toolchain but after further investigation it found glib just find which is what's so confusing.
Related
im trying to complie some operating system example code and when i run make (in running the default debian eviroment on a chromebook lunix termial) it gives me the folowing error:
kuzai_longmane#penguin:/mnt/chromeos/removable/32GB/Operating systems (source code)/my_cool_os/my_cool_os$ make
gcc -m32 -nostdlib -nodefaultlibs -lgcc start.o libc/string/memcmp.o libc/string/memset.o libc/string/strcat.o libc/string/strchr.o libc/string/strcmp.o libc/string/strcpy.o libc/string/strlen.o libc/string/strncmp.o libc/string/strstr.o libc/string/strutil.o libc/string/ctos.o kernel/tty.o kernel/io.o kernel.o -T linker.ld -o myos
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/10/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
make: *** [Makefile:28: myos] Error 1
any sugestions or things i overlooked?
You're trying to generate and link 32-bit code (the -m32 option), but the linker can't find a 32-bit version of libgcc. The message says its is finding a 64-bit version, so the problem is probably just that you don't have 32-bit libs installed. I think on debian, you need to install the ia32-libs package for that.
I am trying to set up static analysis for our code base which is cross compiled for a ARM based CPU. It appears that scan-build provided by clang is one of the best open source solutions for this. When I run scan-build, this is what I get.
$ scan-build-3.8 --use-cc=arm-linux-gnueabi-gcc --analyzer-target=arm-linux-gnueabi make
scan-build: Using '/usr/lib/llvm-3.8/bin/clang' for static analysis
echo "(Version file)"
(Version file)
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find crti.o: No such file or directory
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find crtbeginS.o: No such file or directory
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find -lgcc
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find -lgcc_s
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find -lc
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find -lgcc
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find -lgcc_s
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find crtendS.o: No such file or directory
/opt/sysroots/x86_64-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
Clearly, Linker is trying to find some files and not finding it. I dug a little more deeper into how the linker gets the files by running this command.
$ /opt/sysroots/x86_64-dspg-linux/usr/libexec/arm-linux-gnueabi/gcc/arm-linux-gnueabi/6.3.0/real-ld crti.o --verbose
This prints a lot of data, this what I found interesting.
SEARCH_DIR("=/opt/dspg/v2.4.0-rc2/sysroots/x86_64-dspg-linux/usr/arm-dspg-linux-gnueabi/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
My crti.o is not located in any of the paths above and hence ld is failing.
Now the question. When the scan-build calls the linker how does it inform the search directories and can I change it ?
Given a simple hello world code:
#include <stdio.h>
int main(void){
puts("hello");
return 0;
}
On a 64bit alpine linux installation I tried to compile it as 64bit and as 32bit.
The first works fine, but the second is missing 32bit libraries:
~ # gcc -Wall hello.c
~ # gcc -Wall -m32 hello.c
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../libssp_nonshared.a when searching for -lssp_nonshared
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible //usr/lib/libssp_nonshared.a when searching for -lssp_nonshared
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../libgcc_s.so when searching for -lgcc_s
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible //usr/lib/libgcc_s.so when searching for -lgcc_s
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../libc.so when searching for -lc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../libc.a when searching for -lc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible //usr/lib/libc.so when searching for -lc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible //usr/lib/libc.a when searching for -lc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../libgcc_s.so when searching for -lgcc_s
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible //usr/lib/libgcc_s.so when searching for -lgcc_s
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
Because I found no obvious way to fix this, I fetched the 32bit version of gcc, libgcc, and musl-dev extracted to a local directory and set LIBRARY_PATH:
~ # LIBRARY_PATH=usr/lib/gcc/i586-alpine-linux-musl/5.3.0:usr/lib gcc -Wall -m32 hello.c
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/crtbeginS.o' is incompatible with i386 output
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/crtendS.o' is incompatible with i386 output
collect2: error: ld returned 1 exit status
~ #
This partly fixed the issues, but gcc still tries the 64bit libraries first and finds tries to find the 64bit crt files.
So what is the correct way to compile a 32bit binary on alpine linux?
To make the last problem more clear, look at this:
~ # LIBRARY_PATH=/tmp gcc --verbose -Wall -m32 hello.c 2>&1|grep LIBRARY_PATH
LIBRARY_PATH=/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/:/tmp/:/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/lib/:/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../:/lib/:/usr/lib/
If I only set some LIBRARY_PATH, the compiler internally adds other directories to it. Especially it also prepends the "wrong" system directory, which contains the 64bit libraries. Therefore it uses the wrong crt libs and therefore the last error above.
I either need the correct alpine package (and not care about how it works), or I need to understand how to change that first path added internally by gcc.
According to gcc -v on alpine gcc is compiled without multilib support:
--disable-multilib
While multilib is enabled on debian:
--with-multilib-list=m32,m64,mx32 --enable-multilib
Multilib support is required for the -m32 to work reliable. Therefore the default compiler on alpine is really not suited for compiling 32bit binaries.
I am getting the below error during ./configure.
configure:3429: checking whether the C compiler works
configure:3451: gcc -m32 -D_FILE_OFFSET_BITS=64 -m32 conftest.c >&5
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
configure:3455: $? = 1
configure:3493: result: no
configure:3498: error: in `/root/cjk/1.x/src/externals/mecab':
configure:3500: error: C compiler cannot create executables
I have tried couple of solutions mentioned in internet but to no avail.
I have installed complete Developers package in the machine.
I have installed glibc-devel.i686 package as well.
I ran into the exact same issue (CentOS 6.5 x64, gcc 4.4.7). I made sure yum install glibc-devel.i686 was performed. A quick find / -name "libgcc_s.*" revealed:
/lib64/libgcc_s.so.1
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libgcc_s.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so
So, perhaps you can try the workaround suggested here:
Add the absolute path to the gcc_s library on the link line, OR
(Recommended) If the library's filename has any major and minor version numbers appended to it, simply create a soft link to the library in the same location without the major and minor version numbers in the target filename.
I settled for compiling/linking my application statically by adding -static to my gcc invocation. So,
gcc -static -m32 ...
In that case make sure yum install glibc-static.i686 is done.
I have a C++ library that is being cross-compiled by Gradle on a Mac for Windows, using mingw-w64. I get a "bad -rpath option" when the linker tries to link the binaries.
There are a complicated linker search paths in the debug output below that I have removed for clarity, but they are all ok. However, there is one part which seems to be wrong - it looks like something is being added to the search paths by mistake.
:linkWindows-x8664DebugTestSharedLibrary
Using built-in specs.
COLLECTGCC=/usr/local/bin/mingw-w64/mingw-w64-x8664/mingw/bin/g++
Target: x8664-w64-mingw32
Configured with: ../source/gcc-4.8.3/configure --build=x8664-apple-darwin13.2.0 --target=x8664-w64-mingw32 --disable-nls --disable-multilib --prefix=/usr/local/bin/mingw-w64/mingw-w64-x8664 --with-sysroot=/usr/local/bin/mingw-w64/mingw-w64-x8664 --with-mpc=/usr/local/bin/mingw-w64/pkgs/mpc/mpc-1.0.2-x8664 --with-mpfr=/usr/local/bin/mingw-w64/pkgs/mpfr/mpfr-3.1.2-x8664 --with-gmp=/usr/local/bin/mingw-w64/pkgs/gmp/gmp-6.0.0a-x8664 --with-host-libstdcxx='-lstdc++ ' --with-cloog=/usr/local/bin/mingw-w64/pkgs/cloog/cloog-0.18.0-x8664 --with-isl=/usr/local/bin/mingw-w64/pkgs/isl/isl-0.11.1-x8664 --enable-languages=c,c++ --enable-threads=win32 --enable-fully-dynamic-string --enable-lto
Thread model: win32
gcc version 4.8.3 (GCC)
COMPILERPATH=/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/bin/
LIBRARYPATH=/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/:/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/:/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/../lib/:/usr/local/bin/mingw-w64/mingw-w64-x8664/mingw/lib/../lib/:/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/:/usr/local/bin/mingw-w64/mingw-w64-x8664/mingw/lib/
COLLECTGCCOPTIONS='-shared' '-o' '/Users/john/git/test/build/binaries/testSharedLibrary/windows-x8664Debug/libtest.dylib' '-L/Users/john/git/test/build/nar-dependencies/compiletestWindows-x8664Debug/lib' '-v' '-fno-use-linker-plugin' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/bin/ld --sysroot=/usr/local/bin/mingw-w64/mingw-w64-x8664 -m i386pep --shared -Bdynamic -e DllMainCRTStartup --enable-auto-image-base -o /Users/john/git/test/build/binaries/testSharedLibrary/windows-x8664Debug/libtest.dylib /usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/../lib/dllcrt2.o /usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/../lib/crtbegin.o -LseriesOfSearchFoldersHereEachWithMinusLFlag **#/var/folders/75/fsklv28523d2gx1wth3rc7y0000101/T//ccOUlRAe** -lmingw32 -lgccs -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgccs -lgcc -lmoldname -lmingwex -lmsvcrt /usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/lib/../lib/crtend.o
Error message reads:
/usr/local/bin/mingw-w64/mingw-w64-x8664/x8664-w64-mingw32/bin/../lib/gcc/x8664-w64-mingw32/4.8.3/../../../../x8664-w64-mingw32/bin/ld: bad -rpath option
FAILED
This appears to be the offending bit that is causing the problem: #/var/folders/75/fsklv28523d2gx1wth3rc7y0000101/T//ccOUlRAe
What is that and why is it there?
Did you already solve it?
Most probably the paths to search for libraries is generated by Gradle Native as well. I have no clue about the directory structure. Which version of Gradle are you using? Did you read the user guide about native binaries? Are you able to share the gradle file? (As native support is incubating, it is likely to change quite a bit. It did for me, over the past versions)