Cross compilation requirements for C

I have some basic knowledge about C compilation, but you need to get a couple of general cross-compilation answers. In my case, I am trying to cross-compile a program on my Fedora Linux box, which will run on a single board ARM computer.

  • My first question is about headlines. I downloaded the Linux toolkit for Linux and contains header files, such as stdio.h, in the include directory. Should I use this "target" include directory and not my system, including directories, when I cross-compile? Or is it okay to point to my system, including dirs, such as / usr / include? (These header files seem different when I distinguish them.)

  • What happens if the header file does not exist. In my case, I also plan to use the cURL library on the ARM board. Can I just point to the include directory present in the curl source package that I downloaded without worrying about the target architecture? If so, does that mean my first question doesn't matter?

  • Say I want to statically reference a library. Do I need to build this static library for the target ARM platform before this? Or can I use the static libraries installed on my system directly (hoping that the cross-compilation process will take care of the business)?

  • If I decide to dynamically link to a library, the only requirement would be that the target system has this library compiled for ARM and installed in one of the LD_LIBRARY_PATH directories on the ARM board, is that correct?

Thanks for the help.

+7
c arm cross-compiling
source share
2 answers
  • Always use target headers. They may differ from your host headers. The compiler should already have them as part of the default default path for a standard problem, such as libc.
  • You will need to create cURL, using a cross-compiler, in the fake "target" system directory and create your application using cURL in this target directory. Since you need a cURL library, you MUST use a cross-compiler. For compilations that are not cross-compiled (for example, they build programs and then run as part of the compilation), you will need to change the build process. Sometimes fakeroot can be useful for dirty build systems.
  • You cannot arbitrarily use a static library for another architecture of your system. They must be built by cross-compiler.
  • Wrong. Usually a library should be present.
+10
source share

Any library that you intend to use, including libc, must be created for the target platform before you can link it. Use target headers instead of host headers to create so you are sure to use the correct API.

+3
source share

All Articles