cross compile opencv for porting to TI DM6446 - gcc

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).

Related

Can we have a compiler running in embedded device

It may sound weird but I would like to know if we can have compiler in embedded device (lets say gcc support on imx6).
Of course, it is not uncommon to have target tools, but is is not trivial. A non-native (from the host perspective) compiler must be cross-compiled for the target architecture. You didn't provide any details, but maybe your build system can build target tools for you. Of course, you need much more than just a compiler. You probably need make, autotools, and probably more. It depends on what you are trying to compile on the target.
Your best bet would be to gain some proficiency using a cross-compiler environment. If you haven't already, you might check out the Yocto Project. It supports i.mx6 (and much more) and probably provides a path to get target tools on your board.
Good luck!
To arm arch, it will be easy to get target compiler, linaro ubuntu of linaro project will provide a completely solution for arm arch, it can provide GNOME desktop、toolchain and informative tools on your target.
You can get more info from the following link:
https://wiki.linaro.org/Platform/DevPlatform/Ubuntu
Yes that should easy enough.. What version of cross-compiler do you have in your machine, download the matching gcc compiler from here https://ftp.gnu.org/gnu/gcc/
Now what you want to do is cross-compile the GCC which you downloaded using the crosscompiler which you already have.
Following is an example of compiling 4.7.4, NOTE: replace the HOST and BUILD according to your platform:
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
../gcc-4.7.4/configure --build=$BUILD \
--host=$HOST \
--target=$HOST \
--prefix=/usr \
--disable-nls \
--enable-languages=c,c++ \
--with-float=hard
make -j $JOBS
make DESTDIR=<path_where_to_install> install

Cross Compile GMP and Openswan for ARM on Ubuntu 12.04 32 Bit

I have to cross compile opensawn for a OMAP4 Board and GMP is prerequisite. First I tried it on 64 bit OS but it gave me this error:
configure: error: Oops, mp_limb_t is 64 bits, but the assembler code in this configuration expects 32 bits.
Then I shifted to Ubuntu 12.04 32 Bit and the GMP V6.0.0 got compiled after few trials. Even after having the ARCH, TOOLCHAIN and CROSS_COMPILER variables in .bashrc I had to export the following:
export ARCH=arm<BR>
export PATH=/home/harsh32bit/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/bin/:$PATH<BR>
export CROSS_COMPILE=arm-none-linux-gnueabi-<BR>
Then following commands were observed:
./configure --build=i686-pc-linux-gnu --host=arm-none-linux-gnueabi --prefix=/home/harsh32bit/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/
make clean
make
make install
Then Soft-linking GMP Library to Toolchain
~/Work/Projects/BSQ_VVDN/BISQUARE/gcc-SourceryCodeBenchLite-arm/lib/gcc/arm-none-linux-gnueabi/4.7.3
# ln -s ~/Work/Projects/BSQ_VVDN/packages/gmp-6.0.0/.libs/libgmp.so libgmp.so
I had the GMP compiled successfully although the make check reported all test failed.
9 of 9 tests failed.
Now when I try to cross compile Openswan-2.6.41 after making changes in CROSSCOMPILE.sh and do this make programs I get this error:
In file included from /home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/include/certs.h:24:0,from /home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/lib/libopenswan/id.c:42:
/home/harsh32bit/Work/Projects/BSQ_VVDN/packages/openswan-2.6.41/include/secrets.h:20:41: fatal error: gmp.h: No such file or directory
compilation terminated
I have gone to TI E2E site for this, sniffed internet for pointers in last 4 weeks but I couldn't figure out. If anyone has any clue about cross compiling openswan and GMP for ARM please advise me.
So essentially
The static linkage of gmp files had to be done sans sudo - since when you call make programs from openswan package without sudo you are not root instead a normal user and if you use make programs with sudo it misses some exported variables particularly ARCH. It takes the default architecture instead of target architecture you want to compile for; like in my case it was for arm.
If you have to use the sudo, make it readable-writeable for all. That is after linking the library files in the toolchain you can call chmod 777 on that file - because then it will be available for rw for all user groups.

gcc dll - compiled under Linux

I have a project written in gcc - bison -flex on Linux environment. All the project is implemented into a *.so file and is called from python-tkinter graphic surface.
There is a need to run it on windows. However I'd avoid to install all the windows equivalent of gcc - bison -flex programs.
Is it possible to force gcc IN LINUX ENVIRONMENT to compile WINDOWS DLL instead of *.so? It could make life easier to use the same technics as I do now: just do calls from python-tkinter graphic surface.
You can, of course, cross-compile it.
You'll need some packages installed, though.
Your normal project would be able to build if you use the MINGW equivalent of GCC for the target architecture.
Also, take a look at this:
Manual for cross-compiling a C++ application from Linux to Windows?
The linking can be kind of troublesome though, since it could come a time where softlinking fails due to versions. In that case you'll need to create some symbolic links to the correct version.
The output of the compilation process should be with -o DYNAMIC-LIBRARIE-NAME.dll and of course use the -shared flag.
Hope it gives you some pointers..
Regards.

g++ produce executable for windows

I am using gcc/g++ to compile c/c++ applications - living on OpenSuSe btw.
Is there any way (some option i guess) so that g++ will produce an executable suitable for windows ?
You can search for a mingw32 package in OpenSuSE (I know there is one for Debian) or install it manually. Then if you have a configure script the command line would be something like this in order to have make use the MinGW cross-compilation toolchain:
./configure --prefix=/usr/local --target=i386-mingw32
mingw.org also has a tutorial on building a cross compiler, don't know if that works.
(As an aside: Some websites point to mirzam.it.vu.nl/mingw containing MinGW RPM packages but it seems like that site is down.)
You'll have to be running g++ on Windows to get a Windows executable out of the other end.
Check out mingw or cygwin.
Check out MinGW Cross and related links:
http://www.nongnu.org/mingw-cross-env/#see-also

Building crti.o for i386

I am trying to build a cross-compiler with x86_64 being the host and i386 being the target. I'm getting the (all to common) crti.o: No such file error. Instead of grabbing an already built crti.o and crtn.o from a distro... how might I go about building these files explicitly from glibc (or possibly gcc) sources?
FYI, I am well aware of the -m32 option for x86_64 compilers. I'd prefer to just have a 32bit-only compiler environment. Also, the reason I don't want to use any of the gazillion already build i386 compilers is because I plan on mixing and matching glibc/binutils/gcc versions depending on my testing needs.
Thanks,
Chenz
Here's one possibility (from here)
You need to install your distro's 32
bit libc-dev package, or you need to
--disable-multilib which will result in a compiler that doesn't support 32
bit mode.
Are you sure you're using configuring the cross-compile correctly? It should be
CBUILD = CHOST = x86_64-pc-linux-gnu
CTARGET = i386-pc-linux-gnu
as you're running a build on an x86_64, for a compiler to run on an x86_64, which generates code for an i386.
If you used CHOST = i386-pc-linux-gnu, you'll be trying to generate 32-bit binaries, which will need to link with a 32-bit libc. Which is fine, if you already have a 32-bit libc, but it sounds like you don't.
i.e.
$ tar xvjf gcc-*.tar.bz2
$ cd gcc-*/
$ mkdir build
$ cd build
$ ../configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=i386-pc-linux-gnu

Resources