Reputation: 7867
I'm trying to cross compile a project and a library it depends on for use on an embedded system. Both the application and the dependency use automake. I was able to compile the library without much issue.
./configure --host=powerpc-none-linux-gnuspe --prefix=/home/me/build_dir
make
make install
I used --prefix
so that make install
didn't put the outputs in my filesystem with all of the x86 libs. I have also tried running configure without --prefix
and instead setting the DESTDIR
environment variable before running make install
. They appear to do the same thing. I want to be able to tar up /home/me/build_dir
and drop it on the root of the embedded target's file system. I'm hoping that --prefix
didn't hard code an absolute path on my host machine somewhere.
Then I tried to cross compile the application that uses this library:
./configure --host=powerpc-none-linux-gnuspe --with-sysroot=/home/me/build_dir
I ran into 2 things. The configure script completed successfully but the first make failed because it couldn't find one of the headers. It is looking under /usr/include
instead of /home/be/build_dir/usr/include
. Shouldn't the --with-sysroot
option also modify the include directories or am I missing something?
Also, I'm getting a warning
libtool: link: warning: library libstdc++.la was moved
I get the feeling that I've missed something. Is this warning something I can safely ignore or did I mess up somewhere?
To summarize my questions:
1) Is there a difference between ./configure --prefix=x
and make DESTDIR=x install
?
2) What's the right way to update the search path for the library headers?
3) Why am I getting the warning about libstdc++ and is it something I should worry about?
Upvotes: 4
Views: 8388
Reputation: 100781
For your situation you should use DESTDIR
. Setting --prefix
will mean the resulting program will expect to be installed at the location in --prefix
. DESTDIR
on the other hand is a purely make install artifact, it just prefixes that to the beginning of every path when it installs. The resulting product still expects to be installed at the --prefix
location. If you want to install the results on the target host, set --prefix
to the place it will go and use DESTDIR
to stage it somewhere else.
I believe that just setting --sysroot
in the configure
script is not sufficient, but I'm not sure. I think that sets the sysroot while configure
runs but it doesn't set the makefile.
What I usually do is create a shell script wrapper for the compiler which invokes the real compiler with the proper --sysroot=dir
option, then use that wrapper as the compiler name to configure
. It's simpler to do it that way, than to try to get all invocations of the compiler to add the --sysroot
flag externally.
I'm not sure about the libstdc++
warning. libstdc++
is a part of the compiler, not part of the sysroot...?
ETA:
By script wrapper I mean create a script named something like sysroot-gcc
:
#!/bin/sh
exec real-gcc --sysroot=/some/sysroot "$@"
then you can run configure CC=sysroot-gcc
. You can make this as fancy as you want to; I have a generic script that parses the name ($0
) and obtains the sysroot name and the tool name (gcc
, g++
, etc.) from it so I can reuse that one script for all tools.
Upvotes: 4