User forums > Using Code::Blocks

Team cross-platform development with Code::Blocks?

<< < (2/5) > >>

rickg22:
Great. I get the right answer now that I managed to use scripting hacks to get it working. Go figure.

But it's a much cleaner solution, so I'll use JGM's suggestion. Thanks a lot, man! :)

Edit: It didn't work - I expected the virtual targets to also have compiler and linker options. I think C::B really needs either a "platform" level above the targets, or an additional flag on project/target settings that tells it to which platforms a setting applies.

This would make cross-platform devs' life much easier.

In any case, thanks everyone!

rickg22:
Here's my solution!

I hope this can become the default wxwidgets monolithic-dll project for Code::Blocks.

From my blog:

--- Quote ---Example: In your project settings:
Under "Compiler settings", "other options":


--- Code: ---[[if (PLATFORM == PLATFORM_MSW) print(_T("-mthreads -D__GNUWIN32__ -D__WXMSW__"));;]]
`wx-config --cflags`

--- End code ---

(Note: The double ;; at the end is a workaround a scripting bug)
As you can see, the one-line script is pretty much like C. the _T must have been incorporated for wxWidgets compatibility. In any case, Notice the compilation string: -mthreads, -D__GNUWIN32__ and -D__WXMSW__. The -D is a compiler define. I tried to add scripting to the #defines, but that didn't work, so I had to add them on the compiler command line.

The wx-config part is for Linux. I've found that experimentally, having this option in the project doesn't affect compilation under Windows.

The same can be done with the linker. Under Linker settings, other linker options:


--- Code: ---[[if (PLATFORM == PLATFORM_MSW) print(_T("-mthreads -lwxmsw28u -lintl.dll"));;]]
`wx-config --libs`

--- End code ---

Here I tell the linker to link two windows-only libraries: libwxmsw28u.a, and libintl.dll.a (libintl is used for internationalization). For posix environments (OS X or GNU/Linux), the backticked expressions are more than enough, but you could do the same with "if (PLATFORM != PLATFORM_MSW).

Under search directories, I add both the Windows and posix directories.

Compiler search dirs:


--- Code: ---$(#wx.include)
$(#wx)/contrib/include
$(#wx)/lib/gcc_dll/mswu

--- End code ---

Linker search dirs:


--- Code: ---$(#wx)/lib/gcc_dll

--- End code ---

Resource Compiler search dirs:


--- Code: ---$(#wx.include)
$(#wx)/lib/gcc_dll/mswu

--- End code ---

With this simple settings, you won't require having two different projects, one for GNU/Linux or Mac OS, and another for Windows.

--- End quote ---

killerbot:
H Rick,

I would also like 1 project file for both platforms. I do that already and I edit my project files manually, that way I have 4 targets (when creating an wx application ) :
 * Debug
 * Release
 * Win-Debug
 * Win-Release
Where the first 2 are set to be only for linux/mac platform, and the last 2 for the windows platform.
To be honest I prefer this setup since your solution with the #wx will cause me either :
 * to click a way at least 6 or more time the dialog that wants #wx to be defined (fixed a bug about this last week)
 * define that #wx, and as such I have to find out where it is on linux, where the cool wxconfig just makes not care about where it is

Plus In my setup each target puts it objects files and exe binary in different directories [most probably you can make this work with the script] so when you the project directory from one platform to another and some objects are still in place you won't get any strange compile or link errors.

So I would prefer (once asked the script project guru) to have a project wizard which creates the 4 targets, when done automatically I think I will be much clearer to the user and who knows what kind of defines might need to be added later on in platform a but not in platform b [you would always have to start scripting] or when you create projects where on platform a you need a special file A and on platform b you should not use file A but file B. Will be harder to maintain.

For *simple* projects (that stay simple) I think your suggestion might be sufficient, except from the #wx. That #wx should only be there in case of windows (unless in the wizard you specified you want to use it on any platform, but linux is the accepted wx-config way).

Biplab:

--- Quote from: killerbot on June 22, 2008, 09:42:09 am ---So I would prefer (once asked the script project guru) to have a project wizard which creates the 4 targets, when done automatically I think I will be much clearer to the user and who knows what kind of defines might need to be added later on in platform a but not in platform b [you would always have to start scripting] or when you create projects where on platform a you need a special file A and on platform b you should not use file A but file B. Will be harder to maintain.

--- End quote ---

Sorry for the delay. But unfortunately I don't get much time to code nowadays. I am redesigning the wizard to some extent. This is how it looks right now.



But the coding is not complete yet.

tuXXX:
I think, such crossplatform IDE as C::B defenitely NEED support of many platforms in ONE project...

Please, explain me, how to add new build targets in C::B project (not manually, but automatically through menus...)???
I need, for ex, DebugLinux, ReleaseLinux, DebugWindows, ReleaseWindows and etc... targets...

PS I using wxWidgets library ;)

ADDED:
I found how to create different targets... Project->Properties->Build targets and Add/Duplicate ...
But I found that in .cbp we have only one set of compiler options, and they incompatible on different platforms!
Please, help me, how to put two sets of compiler options in ONE project???
One for windows and one for Linux and assign that options to correct build targets?..

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version