-
-
Couldn't load subscription status.
- Fork 107
How would I go about setting up my linux environment to build for multiple targets (e.g. my host linux amd64 processor, and my raspberry pi arm processor) #80
-
Hi there,
I've gotten cross-compilation working in that I'm now able to build a binary executable for the raspberry pi.
How would I go about adding support to still build for the host processor (e.g. Linux running on amd64)?
Does anyone have experience on how to go about doing this?
Beta Was this translation helpful? Give feedback.
All reactions
-
😕 1
@emptor8 I didn't understand your question, can you elaborate with an example? Are you asking how to cross compile for raspberry pi as well as normally compile for your amd64 machine simuntaneously?
Replies: 1 comment 4 replies
-
@emptor8 I didn't understand your question, can you elaborate with an example? Are you asking how to cross compile for raspberry pi as well as normally compile for your amd64 machine simuntaneously?
Beta Was this translation helpful? Give feedback.
All reactions
-
@emptor8 I didn't understand your question, can you elaborate with an example? Are asking how to cross compile for raspberry pi as well as normally compile for your amd64 machine simuntaneously?
Yeah, exactly -- I'm wondering if you know a good way to cross compile for raspberry pi, and compile normally for amd64 simultaneously. The amd64 compilation would be for running host-based unit tests.
Beta Was this translation helpful? Give feedback.
All reactions
-
@emptor8 That's actually quite simple. All you need is seperate GCC toolchain and "make" tool like the CMake(can do both cross and native compiling) with seperate .cmake file for every target OS environment. You can find PI.cmake file used for raspbian OS cross-compiling in our wiki docs, and for other platforms make your own. Make sure to use seperate build folders as necessary.
Also, if you're running compilation parallelly make sure your available processing power and RAM is capable of doing so.
But I would also recommend you to have a continuous integration server somewhere with one client for every OS target and architecture rather than doing this one machine. This will ease the pain of incompatible changes that you make in one OS. And you will also be able to ensure installation by package manager or installer
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Thanks, with your help I I've gotten close to what I want to do. I'm running into one issue - is there a way to conditionally select which "subdirectories" are included in each of the .cmake files? Right now my CMakeLists.txt file lists all the subdirectories, but what if I don't want to build certain directories in the Raspberry Pi build?
For example, let's say I've got a src and a test directory. For my host.cmake build, I want to build both the src and test directories. However, for my rpi.cmake build, I only want to build the src folder.
Is there a good way to achieve this?
My top level CMakeLists.txt contains add_subdirectory(src) and add_subdirectory(test). I want a way to be able to have host.cmake use both directories, but rpi.cmake only use the src directory.
Beta Was this translation helpful? Give feedback.
All reactions
-
Okay never mind - I figured out how to do this using an if() / endif() in the CMakeLists.txt, and using option() in the host.cmake file.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1