OpenWrt Forum Archive

Topic: Newbie, cross compiling

The content of this topic has been archived on 26 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi, I have just posted on stack overflow (I have just known this forum, sorry) many question about cross compiling (or not).

The link is http://stackoverflow.com/questions/3522 … mpilation.

Without paste the same message, could anybody answer to my questions?

Thank you very much!
Antonio

Is your software package GPLed? If so, you may want to update and/or maintain your software package on the OpenWRT packages feeds. Then, download the OpenWRT trunk source and start to cross compile from source.

Your questions:

1) It appears by the image names you gave, that your virtual machine image is x86 (32bit), while the toolchain is x86_64 (64_bit). Get the toolchain from the same directory as the image.

2) Raspberry Pi is brcm2708 (brcm2709 for RPi2 with ARMv7). I believe the first (brcm2708) will produce binaries that work also on RPi2 in most cases.

3) I dont know.

4) I dont know.

5) It should be possible. You can install gcc at least. Not sure about make. I think it is better you cross compile. It is quite easy once you get it to work.

6) Regardless... of cross compiling or not... if you need those libraries for your application you will need to build them from source somehow.

I suggest you start with a simple helloworld.c, and make sure you can cross compile it, and run it on your target.

Hi all, I have to return into this topic after several time and a fresh acquired experience writing software under linux and OpenWRT. Many thanks to anybody helped me solving a lot of issues, too.

Unfortunately I have paused my porting under OpenWRT due to a linking problem, but in order to go deeper into the above issue I need to briefly give you some details about my software.

It is made of three modules: LIB-1, LIB-2 and APP.

I'm developing it under LUbuntu with Netbeans/C++ and CMake. I'm cross compiling by CMake (I successfully followed this guide http://www.vtk.org/Wiki/CMake_Cross_Com … chain_file) and a I have built a toolchain and a target Generic-x86 OpenWRT image by the latest official BUILDROOT tool (it works under VirtualBox like a charm).

I set the CMAKE_LIBRARY_OUTPUT_DIRECTORY and CMAKE_RUNTIME_OUTPUT_DIRECTORY to a common folder (${CMAKE_BINARY_DIR}/bin) in order to have all the binaries into the same folder.

Now, I build the project for LUbuntu and inside the ouput folder I find LIB-1.so, LIB-2.so and APP, as expected. Then I execute 'ldd' on APP and I see it referencing LIB-1.so and LIB-2.so as expected. By the verbose CMake output I see also that CMake sets (as expected) the RPATH which points to '${CMAKE_BINARY_DIR}/bin'.

Now go into the issue details...

I build the project for OpenWRT and inside the output folder I find all the three files, as expected. Then I execute 'ldd' and 'objdump -x' and I see that APP links to '../bin/LIB-1.so' and '../bin/LIB-2.so' (file name plus a relative path prefix!!!). The other difference is that CMake (I don't know why) does not add the RPATH on the linking command line!

In order to get APP linked to the two libraries without the relative '../bin' path, I have to put the two SO files inside the APP linking folder, and manually run the linker stripping the '../bin/' prefix, and adding '-Wl,-rpath,${CMAKE_BINARY_DIR}/bin' too.

Could anybody explain me:

1) Why CMake links the two platforms using different command line parameters?

2) How can I link with CMake avoind embedding the relative .SO path?

3) If none of the readers uses CMake, could somebody tell me if exists an additional parameter for the G++ linker to strip relative paths from the referenced LIBs?

Thank you very much!
Antonio

The discussion might have continued from here.