I want to know how i can cross compile a library for ARM architecture. Suppose i have libcurl library for Intel architecture and now i want to run the application in ARM architecture using this library. What are the steps i need to perform for this cross compilation. I am using Ubuntu 32-bit machine.
I have gone through the basic steps like
./configure --host= ...
make
make install
but could not get the complete idea. Please provide some useful link or if anybody can explain the things. Any help would be greatly appreciated.
I know there is a post in SO for this already "http://stackoverflow.com/questions/5832734/cross-compiling-a-library-from-intel-to-arm" , but i did not get the things clarified by this.
Platform : linux , gcc compiler
You need to give toolchain for your architecture the host parameter, for example for arm-1808 which basically has an arm architecture, the host parameter would be arm-none-linux. I used the following configure command for my architecture, and it compiled successfully, and I am able to run the application on my arm board.
0.
If tool chain is not in your PATH, then you can include it with a command like this:
export PATH=/home/user/CodeSourcery/Sourcery_G++_Lite/bin/:$PATH
1.
./configure --host=arm-none-linux-gnueabi --build=i686-linux CFLAGS='-Os' --with-ssl=/usr/bin/openssl --enable-smtp
2.
make
3.
sudo make install
4. Now its time to build your application.
arm-none-linux-gnueabi-gcc -o email smtp-multi.c -I/usr/local/include -L/usr/local/lib -lcurl
Basically you need to give CPP and CF flags while compiling your application, to find out the CF and CPP flags you can use the following commands respectively:
curl-config --cflags
curl-config --libs
If above commands do not work then try:
arm-none-linux-gnueabi-gcc -o email smtp-multi.c -lcurl
Related
Hi, how can i download i386 elf cross compiler on linux
i need:
i386-elf-gcc
i386-elf-ld
what commands i need to write in to cmd to get this packages?
Please help me!
I think you could create your own binary cross compiler basing on sources from:
https://crosstool-ng.github.io/
The crosstool-ng are sources of the cross toolchain which you can configure on your own to achieve gcc and ld. The configuration process is similar to the configuration of linux kernel. It just uses "menuconfig" method for configuring all the things. Then you run compilation of this project and if everything go fine you will get cross toolchain.
While compiling some libraries (spatialite 3.0.1, geos 3.3.3 and others) I've noticed that running ./configure results in a makefile that contains lines like this
CFLAGS = -g -O2
CXXFLAGS = -g -O2
That means that debug symbol generation is enabled by default. What I want is to disable debug compiling mode without manual makefile editing. I've ran ./configure --help for both of libraries mentioned above, but I have not found any option to get desired result. I feel that the solution should be very simple, but I'm stuck on this since I'm not very familiar with building software from sources.
OS: Linux Red Hat Enterprise 6
Assuming you're talking about autoconf/automake:
Why not just keep the debugging symbols and let anybody who doesn't like them make install-strip?
You can pass CFLAGS and CXXFLAGS along with configure script
./configure CFLAGS="-O2" CXXFLAGS="-O2"
I'm trying to cross-compile libSDL version 1.2 for a custom made, debian based Linux system. The toolchain I'm using is already configured properly so that I just run gcc/g++ on my the desired code and the resulting output is compatible with the target machine.
When I run ./configure --help in the libSDL source directory, I see that I can basically just set some environment variables to point to my cross-compiler.
However, I also see the following options:
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
I looked into the configure.in, build-scripts/config.sub, and build-scripts/config.guess files but couldn't really figure out how it works.
Are these options required? If not, is it a good idea to use them?
With autotools, --build is what you are building on and --host is what you want it to run on (there's also --target, but that's only important if what you're compiling is itself a compiler). Autotools will generally figure out --build on their own, so don't specify it if you don't have to (but look in /usr/lib/gcc to see what your compiler probably thinks --build should be)
So, eg, if you're building for i686 on x86_64, do
./configure --host=i686-linux-gnu
(And use the -m32 options in CFLAGS, etc., but it sounds like you already have that ready.)
Whereas if you're building for x86_64 on i686, do
./configure --host=x86_64-linux-gnu
(You can build for all kinds of crazy hosts: rs6000-ibm-aix, sparc-sun-solaris, mips-idt-ecoff, etc..., assuming you have the appropriate gcc cross-compilers installed...)
GNU's page on it is here:
http://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html
I have installed LTIB from freescale (by way of Congatec) and would like to compile a "hello, world" program. gcc gives me the native executable. How do I compile for my ARM processor?
You need to install a cross compiler for ARM. gcc on your machine is the native compiler, a cross compiler has a different prefix that determines the target architecture, operating system and libc. In your case, the target system has probably an ARM architecture, is running a Linux kernel with the GNU libc.
arm-none-linux-gnueabi-gcc -o hello hello.cpp
Run ./ltib -m shell. In this mode all of the standard tools are setup to allow ./configure and other setups to build for an ARM by default. From this shell gcc -o hello hello.cpp will create an executable for you. It will be setup for your rootfs, be it uCLibc or glibc. You can also take external open-source packages and run the ./configure - make cycle.
The documentation in the LTIB FAQ has much more information on using LTIB. LTIB typically installs tools in the /opt/freescale directory. If you are not using a custom compiler you will find the compiler under /opt/freescale and can use it directly. In this directory, the compiler will be named something like arm-none-linux-gnuabi-gcc. With the ./ltib -m shell, it is aliased to gcc as are many other standard commands for cross-building.
Look at the -march=name option in the gcc man page. The exact architecture you will specify depends on the version of ARM you need to compile for. v5 ARM example:
gcc -o ARM.exe -march=armv5 source.c
First move to the LTIB folder.
cd "ltib folder"
Then enter the ltib shell
./ltib -m shell
then compile using
gcc -static "program name" .c -o "program name".sabre
Then run the command
file "program name".sabre
I got a little confused when it comes to QT and cross compiling
appliations for my arm-linux:
So far I have a linux running on my AT91SAM9263-EK and an appropriate
filessystem including QT libs build via buildroot.
Also I have build QT-4.8 on my ubuntu.
Now I want to build an example application:
I created a makefile in an examples folder in QT on my ubuntu using
qmake; I used the given qmake.conf in mkspecs/qws/linux-arm-g++.
when executing make I get an error because it includes qatomic_i386.h
and the message "error: impossible constraint in 'asm'".
this header file does obviously not match to my arm toolchain.
my question:
how to configure Qt on my ubuntu to build Qt binaries for my embedded linux
on arm? Do I need to include any libs build by the arm toolchain?
any help is appreciated!
regards
EDIT:
I use the -spec flag and pass the path to "mkspecs/qws/arm-linux-g++" where a "qmake.conf" is located. I did not change anything in here because I dont know wich qmake variable are relevant to link to my arm related libs.
So the right compiler is used, which I could verify when the make process starts. But I observed that in a config file called qconfig.h there is an ARCH flag which is set to i386 but I didnt figure out how one can configure this. I dont think I should manually edit this file.
EDIT2:
someone knows whats behind the file qconfig.h?? should I adjust it manually?
I will solve it by myself :)
After struggling a while and scanning the web I got a little deeper involved how everything works together. I did not understand how to generate an executable for my ARM target device. I figured out two things:
do not add your QT path for X11 at the beginning in your PATH variable. this might mess up your cross compilation.
edit the qmake.conf correspondingly. add your libs build for the target device which in my case are located within buildroot. Add theses lines to your qmake.conf file:
QMAKE_CFLAGS += -O3 -march=armv5te
QMAKE_CXXFLAGS += -O3 -march=armv5te
QMAKE_INCDIR_QT = /home/user/arm/toolchain/buildroot-2010.11/output/staging/usr/include
QMAKE_LIBDIR_QT = /home/user/arm/toolchain/buildroot-2010.11/output/staging/usr/lib
I got it running now. thanks to everyone!
Yes, either you provide the Qt libraries in your toolchain or you tell qmake where to find them. Also, I suspect you're calling qmake without the -spec parameters. If you are using the qmake you find in your distribution, it will use the default spec, which is not arm I guess. Add the -spec parameter and point it to the arm mkspec. Also, make sure the generated g++ commands link to the correct Qt libs compiled for arm.
You shall install QtSDK for embedded linux befor you use it to build your application. I'm afraid you just have QtSDK for x86 right now. After QtSDK for embedded linux installed, it has qws/linux-arm-g++ as the default mkspace typically. If you don't have QtSDK for embedded linux, you can build it from source. Then run qmake to create Makefile for you application.
$QTDIR_FOR_ARM/qmake
Reference:
Installing Qt for Embedded Linux and Cross-Compiling Qt for Embedded Linux Applications