-
Notifications
You must be signed in to change notification settings - Fork 865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-compilation and multiarch #42
Comments
I'm not sure you can generally use installed libs from raspbian when cross compiling.
Trying to link with libssh will pull in /usr/lib/arm-linux-gnueabihf/libk5crypto.so.3 from the host filesystem which won't exist (and if it didn't use arm-linux-gnueabihf it would be even worse as it may find an x86 library). There are schemes involving a chroot with arm libraries that may make it possible, but it's certainly not easy. I'm not aware of a crosstool-ng config option that makes this all easier, but if you find one, I'd like to hear. |
I think I might be running into the problem described by the OP: If I use a very simple test case (code available at the bottom) and I cross-compile it as follows: bcm2708hardfp-cc -march=armv6 -mfpu=vfp -mfloat-abi=hard -o tst tst.c -lpthread Now I log onto a board that has both of these: $ ls -1 /lib/arm-linux-gnueabi*/libpthread.so.0 ldd tells me that the hf/libpthread.so will be used as one would expect: $ ldd ./tst ... but that does not appear to be true because: $ LD_DEBUG=all ./tst So it is not loading the 'hf' library, which would have been the correct behaviour. This is probably not an issue on raspbian because only the 'hf' library is made available. But if both were made available like a regular Debian image, you would run into the same issue. It does look like the toolchain (probably the linker, I imagine) is failing to set some bit that forces the 'hf' lib to be loaded. This is the tst.c file: #include <stdio.h>
#include <pthread.h>
static void * body(void * args)
{
printf("Hello from %d\n", (int) pthread_self());
return 0;
}
int main() {
pthread_t me;
if (0 == pthread_create(&me, NULL, body, NULL)) {
printf("Thread launched...\n");
pthread_join(me, NULL);
}
return 0;
} |
@popcornmix , Is it possible to build with "--enable-mutiarch" as suggested by the OP? |
Moved comment to related issue #50 as it have more activity (#50 (comment)) |
Hi there,
I was using an old Raspbian sysroot (living in /opt/rpi_root on my building X86 system) which had it's libs, headers and .so LD scripts in "standard" routes like /usr/lib, /lib, /usr/include, etc...
Now (probably time ago, I just hadn't updated my Rpi crosscompilation sysroot) , the architecture-specific headers, libs and .so LD scripts have been moved their arm-linux-gnueabihf subdirs: that is, Raspbian has adopted the "multiarch" feature which allows the same lib to be present for different architectures on the same rootfs.
The problem here is that the cross-compiler in this repository is not build with the "--enable-mutiarch --target=arm-linux-gnueabihf" configure options, so it looks for libs, crt*.o files, headers and .so LD scrips in "standard" pre-multiarch locations like /usr/lib, /lib, /us/include... without the arm-linux-gnueabihf subdirs.
So, unless I am missing something here, I just don't understand how people can cross-compile these days. I have also tried building my own cross-compiler with crosstool-ng, but I can't see where it has support for "multiarch".
What am I missing here? Thanks
The text was updated successfully, but these errors were encountered: