Author Topic: create Project for Windows and Linux  (Read 4437 times)

Offline new-c::b-user

  • Single posting newcomer
  • *
  • Posts: 3
create Project for Windows and Linux
« on: September 14, 2007, 01:08:03 pm »
Hi everybody,

i'm quite new to codeblocks and i installed codeblocks (nightly) on windows without any problems. I also installed it on Ubuntu 7.04 successfully. I created a new wxwidget project under windows and this runs fine there. Now i wanted to use this project in linux too and setted up a svn for this.

But the project won't compile because of '-mthreads' is a typical MinGW option :-)
So my question is: What must i do to have a real cross OS project?
The next question is how to handle the compiler and linker options?
In Windows i linked against C:\Programme\wxWidgets-2.8.4\lib\gcc_dll\libwxmsw28u.a
And how to handle the windows resource? Ok maybe this can be handled via wxresources ...

I searched the forum and wiki, but found nothing about it.
Can anybody give me some hints about this topic?

TIA

mariocup

  • Guest
Re: create Project for Windows and Linux
« Reply #1 on: September 14, 2007, 01:48:31 pm »
Hi,

one solution is to have to build targets for windows and linux, or you may attach a script to a build target and test the operating system to switch between different settings.

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: create Project for Windows and Linux
« Reply #2 on: September 14, 2007, 06:47:22 pm »
i'm quite new to codeblocks and i installed codeblocks (nightly) on windows without any problems. I also installed it on Ubuntu 7.04 successfully. I created a new wxwidget project under windows and this runs fine there. Now i wanted to use this project in linux too and setted up a svn for this.

Create a blank wxWidgets project on Linux. Then add your sources to the project. You'll need to maintain two project files for your project. You can't use your Windows project file on Linux.
Be a part of the solution, not a part of the problem.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: create Project for Windows and Linux
« Reply #3 on: September 14, 2007, 10:03:21 pm »
There's no problem to use the same code and project files if you leave the OS specific settings under Build options ...empty.

You only have to use the same compiler(-name) under linux and windows and set the directories executables and so on under Settings -> Compiler and debugger.

If you need project specific settings you don't want to use for your any of the standard compilers you can create a special compiler there.

I tried it and it works fine. At least for me. It even works if change the OS and build without cleaning.

Of course you can also cross-compile and build win-executables under linux without the need to change to Win  :D.

mariocup

  • Guest
Re: create Project for Windows and Linux
« Reply #4 on: September 14, 2007, 10:37:55 pm »
Hi,

you may use something like that in the linker options or pre/postbuild steps:

[[ if (PLATFORM ==  PLATFORM_MSW) { print (_T("cmd /c")); } else { print (_T("sh ")); } ]] <command>

Offline new-c::b-user

  • Single posting newcomer
  • *
  • Posts: 3
Re: create Project for Windows and Linux
« Reply #5 on: September 15, 2007, 12:32:35 pm »
Thanks for your ideas. I will try them. I thought Codeblocks has some automatic way for this, and i didn't see it.

BTW: BIG thx to the devteam, great work!!

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: create Project for Windows and Linux
« Reply #6 on: September 15, 2007, 01:25:49 pm »
There's no problem to use the same code and project files if you leave the OS specific settings under Build options ...empty.

You only have to use the same compiler(-name) under linux and windows and set the directories executables and so on under Settings -> Compiler and debugger.

You do not have to use the same compiler under linux and windows. I am sharing project files and source files 100% transparently between XP and Kubuntu and I am using Visual Studio 2005 Express C++ compiler under Windows and GCC under linux. This can be done using 4 build targets, i.e. Debug/Release for windows and Debug/Release for linux.

cacb