Cross compiling, missing packages - gcc

I'm working on Linux PC x86_64.
I've set up a cross compile toolchain for raspberry pi and I can compile basic helloworld and run it on raspberry.
I'm stuck at compiling some open-source programs as ./configure is complaining about missing packages, for example:
configure: No package 'glib-2.0' found
I'm using this. ./configure --host=arm-linux-gnueabihf to cross compile and it looks good until that error above.
Should I tell ./configure to use libs from target system or? How to do it?

Pass options to the configure script so that it finds the development headers and libraries. It uses using LDFLAGS and CFLAGS.

Related

How do I use the --with-cpu and --with-arch when cross compiling stuff like gcc binutils and glibc

I need to target armv7-a I dont know how to make it compile for armv7. It is instead using armv5te when the binaries are installed using make install
I want to do
./configure --host=arm-eabi --target=arm-eabi --with-arch --with-cpu
I instead used the ./configure CFLAGS='-mcpu=cortex-a7 -mfpu=neon-vfpv4' and the binaries are no longer compiled for armv5te. Thanks Everyone

Issues in Cross compiling when linking GMP to GCC

Using the How To Build GCC 4.8.2 ARM Cross-Compiler, I have installed and setup everything and it works just fine as mentioned in the post i.e., I was able to cross compile a simple C code. But, when I try to compile a simple GMP code, I get this error.
fatal error: gmp.h: No such file or directory
Compilation terminated
How should I fix this? My goal is to compile a gmp program. If possible, refer me to good tutorials.
Thanks!
If you want GMP compiled for the target system (ARM), you must compile it by itself using the newly built cross-compiler, not as a part of building GCC. GMP (along with MPFR, MPC, ISL, CLooG, etc.) being placed in the GCC toplevel source directory simply means that it gets compiled and linked for the cross-compiler you're building.
Since the cross-compiler will run on the host system, GMP will also be compiled for the host system, else linking the library would fail, and you wouldn't get a cross-compiler. It may sound silly, but there are reasons for doing it this way, such as buggy prebuilt packages provided by the package manager on the host system or merely to avoid installing those libraries on the host system when all you want is the cross-compilation toolchain.

How to compile glib using gcc

I have a cross compiler and I know how to cross compile a file.
But I am doing all just for glib compilation that I do not know how to do.
Anyone to guide me.
or generally just inform me how can I compile a complete library using gcc
If the source code of library has a configure script try :
./configure --host=TARGET_PLATFORM
you must have TARGET_PLATFORM gcc installed .
e.g. : target=arm-linux-androideabi , so you should have arm-linux-androideabi-gcc and arm-linux-androideabi-ar & ... in your $PATH
If the source code does not provide 'configure' then export CROSS_COMPILE=TARGET_PLATFORM.

building my own gcc version

My distro (CentOS 6.3) comes with gcc 4.4.6. Since I wanted to try out the Fortran2003 features I decided to compile gcc 4.7.
I followed the steps I found online: compiled separately first gmp, mpc, mpfr, ppl and cloog and the compiled gcc.
I run the configured script as:
configure --prefix=... --with-gmp=... --with-mpfr=... --with-mpc=... --program-suffix=-4.7 --enable-cloog-backend=isl --with-ppl=... --with-cloog=... --disable-multilib
This worked all right and I was able to compile with make & make install.
Now, when trying my new compiler with a simple test program (a hello world kind of thing) I get the error:
gfortran-4.7 -o test test.F90
/home/amcastro/gcc-4.7/output/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/f951: error while loading shared libraries: libcloog-isl.so.1: cannot open shared object file: No such file or directory
So I decide to set LD_LIBRARY_PATH=/home/amcastro/gcc-4.7/output/lib
and then I can compile.
When running I get the error:
./test
./test: error while loading shared libraries: libquadmath.so.0: cannot open shared object file: No such file or directory
So I set LD_LIBRARY_PATH=/home/amcastro/gcc-4.7/output/lib:/home/amcastro/gcc-4.7/output/lib64
and now the program runs normally.
The question is: Why is that my distro version of gcc (4.4.6) does not need me to set LD_LIBRARY_PATH? how does the distro gcc know where to look for these dynamically liked libraries? should I somehow make them to link statically?
I read also that setting LD_LIBRARY_FLAG is not a good idea. Is there another solution?
Thank you in advance
A.

cross compile opencv for porting to TI DM6446

I have set up target fs on
/home/myself/filesys/bin..etc//
GCC
compile:
host $ arm_v5t_le-gcc hello.c -o hello
run:
target $ cd /opt/hello
target $./hello
I have installed opencv2.3 on host ubuntu machine now I want opencv to be ported to DM6446
so i follow
uncompress opencv2.3 tarball
sudo cmake OpenCV-2.3.1
sudo make ARCH=arm CROSS_COMPILE=arm_v5t_le-
but when I run the sample test from bin it runs on x86 machine which was made for ARM
I think I am not following the correct procedure to make opencv.
Is there anything I have to do to make opencv for ARM architecture,
what are the steps to follow in cross compiling?
The 2nd command you executed should provide a clue as to whether you are cross-compiling or not. If you look closely it would have shown that it was building for the i686 and not for the ARM platform.
This blog discusses how to Cross Compile using cmake.
cmake uses different environment variables from standard make (so don't use ARCH, and CROSS-COMPILE).

Resources