开发者

Cross Compiling a library from intel to arm

开发者 https://www.devze.com 2023-03-02 03:27 出处:网络
I am using open source C++ library DCMTK from http://dicom.offis.de/dcmtk.php.en. I have successfully compiled this library on Windows using VC++ IDE, MacOS Xcode, Mac iOS simulator.

I am using open source C++ library DCMTK from http://dicom.offis.de/dcmtk.php.en. I have successfully compiled this library on Windows using VC++ IDE, MacOS Xcode, Mac iOS simulator. But I am not able to compile this library on iOS device as it is ARM based architecture. DCMTK library compiled very well on Intel architecture.

Now my problem statement is :-

I need to compile this DCMTK C++ library on ARM architecture by cross compilation. I am using Ubuntu 64 bit machine for cross compilation. I have installed binaries from GNU ARM tool chain from http://www.gnuarm.com/ I am using GCC toolchain 4.0 binutils-2.16.1, gcc-4.0.2-c-c++, newlib-1.14.0, insight-6.4, TAR BZ2 [65.5MB] bi开发者_Python百科naries for Ubuntu 64 bit machine for ARM cross compilation.

After Installing these binaries on Ubuntu I have set PATH environment variable to PATH=$PATH/gnu_arm/bin

For configuring the DCMTK C++ library I have run the following command on shell

CC=arm-elf-gcc CXX=arm-elf-g++ AR=arm-elf-ar RANLIB=arm-elf-ranlib ARFLAGS=cruv ./configure –prefix=$home_dicom –target=arm-elf –host=arm-elf –enable-std-includes –disable-threads

It creates a make file properly. Now I am trying to compile the code by using make command, but facing so many compilation errors like :- 1) I tried to compile my first dependent C++ library that is ofstd. I got error for DIR*, struct dirent, opendir(), closedir() calls. It includes for these calls, but I did not found any definitions for the above calls in this header file.

2) When I compile another library oflog I got the following errors like error: nthos was not declared in this scope error: ntohl was not declared in this scope error: htons was not declared in this scope error: htonl was not declared in this scope. These calls are networking calls and are not defined in any of the header file from GNU ARM tool.

I tried to download the sources of ARM binaries and extracted the tar files and try to copy missing header files to installed GNU ARM on Ubuntu. For some files it compiles after doing changes to copied header files, and for some again it gives compilation errors.. There is a loop of compilation errors for every file present under DCMTK library as some of the standard header files are missing.

Please suggest if there is any other tool chain available for ARM cross compilation on Ubuntu 64 bit machine. Or any other good solution apart from this.

Thanks!!! Amit


There are many areas for problems when it comes to cross compiling. There are three main flags for cross compiling. -host , -target, and -build. The -host flash is the machine in which the resulting binaries will run on. The -build flash is the system in which you will be compiling on. The -target flag is for building libraries that will be used in cross compiling. So if you were to build your own gcc tool chain. So in your case you won't set the target flag as we're not building a tool chain. the -host flag will be arm-elf. And the -build flag will be amd64.


Usually a cross compilation fails if there are inconsistencies between the regular c compiler and the cross compiler. I have compiled several libraries for the avr32 with a toolchain generated by buildroot, but in some cases (socat project for example) it hasn't been possible.

Your host, your target and the CXX flags look ok. I think it is not necessary to put the AR flag (that is the idea with the host and target option).

In other hand, this is an example for the expat libraries for the avr32:

./configure --host=avr32-linux --prefix=/home/juan/builds/build_expat/ CC=avr32-linux-gcc
make; make install 

I can recommend you that tries to cross compile from an ia32 architecture. I had several problems with that ubuntu in the past.

0

精彩评论

暂无评论...
验证码 换一张
取 消