User forums => Embedded development => Topic started by: vpprof on April 20, 2017, 06:36:08 pm
I am a total newbie to Linux but I have to do a C++ project for school and compile it for Linux. I am coding a fairly simple console app in C::B on Win7, using the GNU GCC Compiler. I want it to be able to run on a Linux (fedora) platform.
Someone told me I need to use the
configure --target=something utilities. I understand I have to change some setting in C::B for this but I looked under Project|Properties and Project|Build options and haven't found anything useful.
Could anyone please quickly guide me through the process of cross-compiling?
You should tell that "someone" that your project is not make and configure based but CodeBlocks based :P.
Setting up a cross-compiling environment is not an easy task, regarding what you have written i assume it will be MUCH easier for you to just setup a Linux VM and compile your CodeBlocks project there, CodeBlocks does run on Linux as well ;).
You should tell that "someone" that your project is not make and configure based but CodeBlocks basedI see :) As I said, I have no idea how this works, I thought these are tools that C::B uses.
So it's definitely not a matter of opening my C::B project as usual and inserting a switch or two in the right places, right?
Do you recommend Virtal Box as the VM?
Does the specific version of Linux (ubuntu/fedora etc.) enter into the business? Do I need to compile my project in a different way for each of them? I think I only want fedora but I may need more...
You should definitively forget cross compiling ;)
IYou probably have to create a second project file for your program on linux, but i am not sure. The steps that should work:
1) Create a VM with your preferred linux
2) Install gcc and binutils on this vm
3) Install codeblocks on this vm (from the official repo, or download from the main codeblock site
4) Test you installation by creating a hello world example and compile it
5) Copy your project folder from windows to linux
6) You can try to open the project file and compile it. If it works ok, if not:
7) Create a new project file in the same folder:
7.1) New->Project->Empty project in the same folder of your windows project, but with a different name (like append unix)
7.2) Add your source files by Project->Add files or Project->Add files conclusively
7.3) Make the propitiate project settings
8) Compile and have fun
VirtualBox is just fine, for the used linux it should be close to your target system, at least it should be the same architecure (x32, x64), should not use a newer gcc and there should exist a precompiled CodeBlocks for it. Otherwise, see above.