Author Topic: Cross-compiling Win7 -> Linux fedora, using GNU GCC  (Read 868 times)

Offline vpprof

  • Single posting newcomer
  • *
  • Posts: 2
Cross-compiling Win7 -> Linux fedora, using GNU GCC
« on: April 20, 2017, 06:36:08 pm »
Hi there!

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
Code: [Select]
make and
Code: [Select]
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?

Offline sodev

  • Multiple posting newcomer
  • *
  • Posts: 108
Re: Cross-compiling Win7 -> Linux fedora, using GNU GCC
« Reply #1 on: April 20, 2017, 07:34:15 pm »
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 ;).

Offline vpprof

  • Single posting newcomer
  • *
  • Posts: 2
Re: Cross-compiling Win7 -> Linux fedora, using GNU GCC
« Reply #2 on: April 20, 2017, 07:42:32 pm »
Quote
You should tell that "someone" that your project is not make and configure based but CodeBlocks based
I 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...

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1582
Re: Cross-compiling Win7 -> Linux fedora, using GNU GCC
« Reply #3 on: April 21, 2017, 10:51:36 am »
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

Offline sodev

  • Multiple posting newcomer
  • *
  • Posts: 108
Re: Cross-compiling Win7 -> Linux fedora, using GNU GCC
« Reply #4 on: April 21, 2017, 12:42:09 pm »
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.