Best approach for cross-platform development?

Hi!

I was wondering what the best approach would be to work on a cross-platform project (i.e. work&code&compile in and IDE one project on Ubuntu 32 and 64bit and Windows).

Are the make files fully cross-platform? (I think so)
Are the Codeblocks project files cross-platform? (I don’t think so - the createprojects.py is different for win and linux. Is there a way to avoid two sets of project files?)
Are Eclipse projects cross-platform? (I think it’s doable this way, if one maintains different workspaces for win and linux. Sadly Eclipse crashes on me as soon as I add the oF project)

Are you referring to OF or c++ projects in general?

I agree with what you have listed so far and and think those approaches are semi functional. Quite often a library has different dependencies on different systems, so the project settings are different. Because of that , we usually had a multiple projects for all systems with a shared, version controlled src folder. This is a lot of (unnecessary?) double work, but is reliable and controllable.

To have a more complete cross platform compatibility, the best approach but also a quite complicated one, would probably be to use a build system like a configure script, cmake, scons …

was thinking about oF.
how much of that platform-specific stuff is handled by the makefiles (cause I think they’re identical for all platforms)? I’d have thought most of this already handled by the new makefiles, addons.configure, etc…

yes, only version-controlling the src and data folders (or something to that effect) sounds like a reasonable approach. I just wanted to avoid having two sets of (e.g.) codeblocks files in my project folder.

how much of that platform-specific stuff is handled by the makefiles (cause I think they’re identical for all platforms)?

I was wondering the same thing. But I do think that the makefile can be rather platform specific. I don’t see any problems with compiling, but the linker might be tricky?

OF compile on linux links against gtk-x11-2.0, gthread and other libraries. Of course you could alter the makefile so it knows what to link depending on the platform, but I guess that’s what the GNU configure and build system is for?

But it would be great to have makefiles on all platforms. Imagine you check out your project on windows, run make and there you go…

in its current state, does a makefile automatically distinguish between 32 and 64bit architecture? Meaning: can I code on Ubuntu 64bit, then take the project folder, open on a 32bit machine, and continue work there? My experience so far suggests that this is possible without problems, but can this trigger bugs?

I’d agree. I didn’t try it extensively but so far all the 64bit projects worked on 32 bit machines. I did however experience a difference once, when compiling a project 64 bit without modifying the config.make and then on 32 bits, it needed the extra linker -lX11. But I think that is pretty much an isolated event.Because it used a system library, which is hardly the case…

yes, the makefiles are exactly the same for linux32/64 and android. For android you need to use a different target but that’s it. At some point i’ve make them work for osx but never committed the changes. For windows is more difficult since the makefiles use things like sed, grep or find which are not present in win although there should be a way of making them work using msys or cygwin

ha, so a viable approach could be makefile&eclipse development on linux, and codeblocks on windows. this way, the eclipse projects live in the eclipse workspace anyway, by default, and the linux makefile and windows codeblocks project files can coexist peacefully in the project directory, right? barring any action by scripts like createprojects.py of course…

At some point i’ve make them work for osx but never committed the changes

Wow. Do you still have it? It’s really annoying to use XCode after working on linux with makefiles. Also I switch a lot between mac and linux, that way it’d be way less work.

I heard a lot of people are using eclipse. Is it even a majority on linux? (I don’t use eclipse) But with make files it’s not as big an issue…

no, but i plan on refactoring the makefiles some time soon to have different common files like Makefile.linux Makefile.android… common to all examples so it’s easier to add new platforms. I’ll add osx then

this sounds like an awesome plan (in light of the topic of this thread) - would be easy to differentiate.
Eclipse: Personally, I started when I started playing with Android apps; I thought, might as well take the complete jump to Eclipse, so I’ll get to know a “professional” IDE which can be a competitor to Visual Studio.

yes, great plan! A huge +1 from my side.

Personally I really dislike eclipse, but that’s also because I used it heavily on a mac and java on a mac is like flash on linux. But that’s another plus for makefiles, you can use any IDE on linux or mac. A feature I think is really important…

edit: [bilderbuchi] sry, just inadvertantly hit “edit” instead of “reply” ::slight_smile:
[underdoeg] np :slight_smile:

that’s the beauty of it… if I decide to kick eclipse into a bucket, I’ll just fire up codeblocks instead…

Hi,

Coming from the linux world, using emacs for most of my coding and willing to make what I am doing cross-platform, I am really interested in using only one make system for all targets.

Cmake seems interesting (http://forum.openframeworks.cc/t/cmake-as-crossplatform-solution-testers/1058/30) but I did not have the time to test it today and since the thread is 2/3 years old I am wondering if it is a good choice since there is no visible trace of it in the main repository.

In the meanwhile, I modified the Makefile from another thread (http://forum.openframeworks.cc/t/compile-of-from-makefile-on-os-x-for-web-os/6187/0) to make it work on my OSX lion and put it on github (https://gist.github.com/1190981). Please, feel free to improve it!

It is a bit ugly and I am still learning about MacOS .app/ structure and where to put the data/ directory but it seems to work for my little project.

In the hope that it will be useful to someone else :slight_smile:

By the way, since it is my first post: Thank you Arturo for this great project!

Labe, I´m looking forward to use emacs for editing oF projects. Can you share your “.emacs” . I´m not getting the auto-complete work properly.
For some installations I´m editing and compiling, all through ssh… so making emacs work properly it will bee a great advance! Also, thanks Arturo for the makesfiles… they are wonderfull peace of work!

Hello Patricio,

Currently I don’t have autocomplete with emacs (the autocomplete feature an ide like xcode or codeblocks gives you).

If like me you don’t really like CEDET you might be interested in this : http://www.emacswiki.org/emacs/AutoComplete

I use it as is and did not have the time to customize it for C++ or snippets but judging from the comments it should be possible.

I will gladly share my .emacs files but there’s mainly org-mode, proel and anything stuff the remaining is garbage :slight_smile:

Anyway, I will put it on github later.

Best regards
laurent