Compiling cross platform code can sometimes be tricky since the code often has to be modified slightly to satisfy different compilers. I’ll here describe the steps to compile the Irrlicht game engine for OS/X 10.8 Mountain Lion.
(Modified version of http://irrlicht3d.org/wiki/index.php?n=Main.InstallingIrrlicht )
Prerequisites: XCode 4.4 (or 4.5) installed. Install command line tools (Open XCode and goto preferences, choose the tab ‘Downloads’ and install next to the install line tools).
- Download the Irrlicht SDK 1.7.3 LINK
- Build the library (With Native Windowing Frameworks)
- Expand the archive, and navigate to ~/Downloads/irrlicht-1.7.3/source/Irrlicht/MacOSX
- Open MacOSX.xcodeproj with Xcode
- Select the build settings for the current project
- Change the following build settings (you may need to change from Basic to All in the line under build settings):
- Change Base SDK to Current OS X
- Change Architectures to Standard (32/64 bit Intel)
- Change Compiler for C/C++/Objective-C to LLVM GCC 4.2
- Do following changes in source code :
- CIrrDeviceMacOSX.mm:634 change to:
GLint order = -1; // below window - COpenGLSLMaterialRenderer.cpp:137-149 change to code block below
- CIrrDeviceMacOSX.mm:634 change to:
- Build all (this should create irrlicht/source/Irrlicht/MacOSX/build/Release/libIrrlicht.a )
- Install the library and headers:
- Open the Terminal and type: sudo cp ~/Downloads/irrlicht-1.7.3/source/Irrlicht/MacOSX/build/Release/libIrrlicht.a /usr/local/lib/
- Type: sudo cp -r ~/Downloads/irrlicht-1.7.3/include /usr/local/include/irrlicht
___
COpenGLSLMaterialRenderer.cpp:137-149:
#if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_shader4) long long pLong =reinterpret_cast<long long>(Program); GLuint p = (GLuint)pLong; Driver->extGlProgramParameteri(p, GL_GEOMETRY_INPUT_TYPE_EXT, Driver->primitiveTypeToGL(inType)); Driver->extGlProgramParameteri(p, GL_GEOMETRY_OUTPUT_TYPE_EXT, Driver->primitiveTypeToGL(outType)); if (verticesOut==0) Driver->extGlProgramParameteri(p, GL_GEOMETRY_VERTICES_OUT_EXT, Driver->MaxGeometryVerticesOut); else Driver->extGlProgramParameteri(p, GL_GEOMETRY_VERTICES_OUT_EXT, core::min_(verticesOut, Driver->MaxGeometryVerticesOut)); #elif defined(GL_NV_geometry_program4) if (verticesOut==0) Driver->extGlProgramVertexLimit(GL_GEOMETRY_PROGRAM_NV, Driver->MaxGeometryVerticesOut); else Driver->extGlProgramVertexLimit(GL_GEOMETRY_PROGRAM_NV, core::min_(verticesOut, Driver->MaxGeometryVerticesOut)); #endif
Hi! Thanks a lot for the guide, i’m running into a problem though… On mountain lion i’m trying to compile the code and when i start building it gives me the following error in MacOS_Prefix.pch:
/Users/shaun/Documents/irrlicht-1.7.3/source/Irrlicht/MacOSX/MacOSX_Prefix.pch:5: Architecture/byte_order.h: No such file or directory
It’s the first time i try to use irrlicht so i don’t even know where to create this file…
It would be great it you could give me hand. Thanks
By: shaun on October 10, 2012
at 16:29
ok sorry! Hadn’t downloaded the command line interface for xcode!
By: shaun on October 11, 2012
at 17:59
Hi Shaun. Good to hear that you have have solved the problem. And thanks for the feedback – I have updated the blog-post, so other people can avoid problems.
By: Morten Nobel-Jørgensen on October 11, 2012
at 18:26
I am getting 3 issues:
Redefinition of ‘NSWindow’ as different kind of symbol
Redefinition of ‘NSOpenGLContext’ as different kind of symbol
Redefinition of ‘NSBitmapImageRep’ as different kind of symbol
By: space55 on November 10, 2013
at 20:41
I have 3 errors, and I only have the LLVM 5.0 compiler. Errors:
Redefinition of ‘NSWindow’ as different kind of symbol
Redefinition of ‘NSOpenGLContext’ as different kind of symbol
Redefinition of ‘NSBitmapImage’ as different kind of symbol
By: sversesurvival on November 10, 2013
at 20:42
By the way, this is in CIrrDeviceMacOSX.h
Line 21-23
Code:
class NSWindow;
class NSOpenGLContext;
class NSBitmapImageRep;
By: sversesurvival on November 10, 2013
at 20:44
I have a problem too: I compiled and built irrlicht, but when I try to compile examples with “make” it gaves me
ld: library not found for -llibIrrlicht
I put libIrrlicht.a on /usr/local/lib. I tried to put it on project directory or in parent folder, but I had same problem.
By: Jacopo Prendin on December 11, 2013
at 01:34