7

Following this guide, http://www.a2p.it/wordpress/tech-stuff/development/remote-debugging-raspberrypi/ , I was able to cross compile from Windows to Raspberry Pi. But is it possible to cross compile with external libraries such as PCL and OpenCV. Can I just build a project using Cmake tool using the cross toolchain?

  • 3
    You have to cross-compile the libraries first. – goldilocks Oct 25 '13 at 13:39
  • Does sudo apt-get install <library-package> downloads and install prebuilt binaries? – Xegara Oct 27 '13 at 17:47
2

If whatever you are compiling links to, e.g., libfoobar, then libfoobar has to be:

  • In the library path when you compile. The easiest way to do that is to set up a basic hierarchy (bin, lib, include) and install them to there. I'll refer to this as the "staging" directory.

  • Versions compiled for the pi. These could even be versions from the pi, although working out the linkage here can be much more trouble than it is worth, and you may easily end up banging your head against a wall. The ideal thing to do is get the library sources, cross-compile them, and install into the staging directory.

WRT the staging directory, you can use the cross-compiler's sysroot directory (which contains all the basic libs, e.g., glibc), however, it is probably a better idea to make one specifically for that purpose and add -L/wherever/ to LDFLAGS. I have not used the x-tool from your link, but I presume it uses crosstool-ng. If you look in the crosstool-ng docs at 5 - Using the toolchain.txt there are extensive notes about this. That pre-built x-tool may already have something configured along these lines.

If your library requirements are fairly straightforward, building them from source is not much of a hassle. However, one thing you could try is to mount the pi's root directory as an NFS share (or Samba? I don't know much about windows) and use that as a staging directory. Then you just need to install the '-dev' packages with apt-get.

| improve this answer | |
  • Regarding the latter part of your answer, I just want to confirm my understanding. Do you mean that I would be linking my project to the root of the pi (where the installed <lib packages>) are installed and I can now cross compile? – Xegara Oct 28 '13 at 1:13
  • Yeah. So then you would compile something like -L/mnt/lib -L/mnt/usr/lib -I/mnt/include -I/mnt/usr/include. – goldilocks Oct 28 '13 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.