Compiling Irrlicht 1.7.2 with Mac OS 10.7 and XCode 4.1

Well yesterday I decided to try out the Irrlicht engine, and setting up the environment proved not to be a very easy or fun thing to do. Anyway I managed to google all the information and thought that I could put it all in one place here.

Step 1

First you should download Irrlicht from here. Unzip the file and open “Irlicht-1.7.2/source/Irrlicht/MacOSX.” Inside you will find “MacOSX.xcodeproj”, open it in Xcode.

Step 2

Now you will probably get an error like this.

The run destination My Mac 64-bit is not valid for Running the scheme.

You just need to fix your project settings. First select libirrlicht.a among your targets. These settings worked for me.

Now select 01.HelloWorld target and set the same settings and start the compilation again.

Step 3

Now you should see an error like this.

COpenGLSLMaterialRenderer.cpp:138: error: cast from ‘void*’ to ‘GLuint’ loses precision

Well it’s a bug in the sources that should be fixed in the next version. However I found the solution on Irrlicht forum.

You should replace this code inside the COpenGLSLMaterialRenderer.cpp.

#if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_shader4)
Driver->extGlProgramParameteri((GLuint)Program, GL_GEOMETRY_INPUT_TYPE_EXT, Driver->primitiveTypeToGL(inType));
Driver->extGlProgramParameteri((GLuint)Program, GL_GEOMETRY_OUTPUT_TYPE_EXT, Driver->primitiveTypeToGL(outType));
if (verticesOut==0)
Driver->extGlProgramParameteri((GLuint)Program, GL_GEOMETRY_VERTICES_OUT_EXT, Driver->MaxGeometryVerticesOut);
else
Driver->extGlProgramParameteri((GLuint)Program, 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

with this

#if defined(GL_ARB_geometry_shader4) || defined(GL_EXT_geometry_shader4) || defined(GL_NV_geometry_shader4)
Driver->extGlProgramParameteri((long GLuint)Program, GL_GEOMETRY_INPUT_TYPE_EXT, Driver->primitiveTypeToGL(inType));
Driver->extGlProgramParameteri((long GLuint)Program, GL_GEOMETRY_OUTPUT_TYPE_EXT, Driver->primitiveTypeToGL(outType));
if (verticesOut==0)
Driver->extGlProgramParameteri((long GLuint)Program, GL_GEOMETRY_VERTICES_OUT_EXT, Driver->MaxGeometryVerticesOut);
else
Driver->extGlProgramParameteri((long GLuint)Program, 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

Now recompile and (hopefully) enjoy the hello world demo. Notice that you need to change settings (step 2) for each target you wish to compile.

About these ads

6 responses to “Compiling Irrlicht 1.7.2 with Mac OS 10.7 and XCode 4.1

  1. radicalraid

    Also, don’t forget to change the “Compiler for C/C++/Objective-C” Build Option to LLVM GCC 4.2 under the project’s Build Settings

  2. Thank you for this! Been curious how to compile Irrlicht in OS X… hopefully I can set up some automated process to develop once and then compile for Linux, OS X, and Win. That would be perfect!

  3. Jason

    I’m trying to follow these steps using XCode 4.4 and OSX 10.7.4, but after I copied and pasted the code, I’m getting an error that there is an “Expected ‘)’ “. However, the parentheses appear to be balanced. Any help? I’m fairly new to all of this, and Irrlecht is required for another library I’m trying to experiment with.

    • If you follow radicalraid’s tip about switching to GCC, it works around this issue. However, you will still get one error where you have to change a long to a GLint. After that it builds fine. This was on OS 10.8.2 with XCode 4.5.1 and Irrlicht 1.7.3.

  4. Even after replacing it shows error: Expected ‘(‘

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: