views:

391

answers:

1

I'm writing a plain C project. I'm using a Mac and I like working with Xcode and I want to use the Xcode project and build environment. I'd like to be able to build it on other platforms though. Not being overly familiar with Linux (yet) I assume this would involve a makefile. My project has no dependencies and it's about as vanilla as it gets.

Is there an easy way to do this? Will I have to keep track of two separate build scripts / configurations?

+2  A: 

It is possible to make Xcode use external build scripts but in your case that shouldn't be necessary. Xcode projects that do not have external dependencies build out of the box. You won't need to do anything for that to work. In order for your project to also build on other platforms a simple makefile should suffice. When you build on Mac OS X you let Xcode do the work and when you build on another platform you let the makefile and make utility do the work.

Once you start building more complex projects you may want to learn how to use a cross-platform build system. Two popular build systems are GNU autotools and Cmake. GNU autotools is very complex, made up of many different utilities and has a steep learning curve, but there is plenty of documentation available for it online. CMake is a single tool, easy to learn, but online documentation is sparse, to take full advantage of it one has to get a copy of the CMake book. CMake has the advantage that it can generate Xcode projects automatically, it can also generate projects for Microsoft's IDE on Windows. GNU autotools cannot do that.

trijezdci