How To Build Irrlich On MacOSX

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
kkrizka
Posts: 70
Joined: Sun Sep 30, 2007 3:10 am

How To Build Irrlich On MacOSX

Post by kkrizka »

Hi there,

I'm trying to test out my irrlicht based application on MacOSX, so I need to compile the latest trunk (using some stuff from there) of Irrlicht on MacOSX. However I'm having some trouble. I am using MacOSOX 10.4.11

Here is what I've tried:

I tried to use the supplied XCode project in source/Irrlicht/MacOSX/MacOSX.xcodeproj and build irrlicht in release mode. That part worked. Then I copied the build library from source/Irrlicht/MacOSX/build/Release/libIrrlicht.a to lib/Linux (that is where the examples makefiles look for it). Finally, I tried to build the 01.HelloWorld example using make. The result was this:

Code: Select all

g++ -I../../include -I/usr/X11R6/include  -O3 -ffast-math main.cpp -o ../../bin/Linux/01.HelloWorld  -L../../lib/Linux -lIrrlicht -L/usr/X11R6/lib -lGL -lXxf86vm -lXext -lX11
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols:
.objc_class_name_NSApplication
.objc_class_name_NSAutoreleasePool
.objc_class_name_NSBundle
.objc_class_name_NSEvent
.objc_class_name_NSOpenGLContext
.objc_class_name_NSOpenGLPixelFormat
.objc_class_name_NSString
.objc_class_name_NSWindow
_CFArrayApplyFunction
_CFArrayGetCount
_CFArrayGetTypeID
_CFArrayGetValueAtIndex
_CFBooleanGetValue
_CFDictionaryGetTypeID
_CFDictionaryGetValue
_CFGetTypeID
_CFNumberGetValue
_CFRelease
_CFStringGetCString
_CFStringGetSystemEncoding
_CFUUIDGetConstantUUIDWithBytes
_CFUUIDGetUUIDBytes
_CGCaptureAllDisplays
_CGDisplayAvailableModes
_CGDisplayBestModeForParameters
_CGDisplayBounds
_CGDisplayCurrentMode
_CGDisplayHideCursor
_CGDisplayIDToOpenGLDisplayMask
_CGDisplayPixelsHigh
_CGDisplayPixelsWide
_CGDisplayShowCursor
_CGDisplaySwitchToMode
_CGLChoosePixelFormat
_CGLClearDrawable
_CGLCreateContext
_CGLDestroyContext
_CGLDestroyPixelFormat
_CGLFlushDrawable
_CGLSetFullScreen
_CGLSetParameter
_CGMainDisplayID
_CGSetLocalEventsSuppressionInterval
_CGWarpMouseCursorPosition
_IOCreatePlugInInterfaceForService
_IOIteratorNext
_IOMasterPort
_IOObjectRelease
_IORegistryEntryCreateCFProperties
_IORegistryEntryGetParentEntry
_IOServiceGetMatchingServices
_IOServiceMatching
_NSApp
_NSDefaultRunLoopMode
_SetSystemUIMode
___CFConstantStringClassReference
_kCFAllocatorDefault
_objc_msgSend
_objc_msgSend_fpret
.objc_class_name_NSObject
_objc_msgSendSuper
_objc_msgSend_stret
.objc_class_name_NSArray
.objc_class_name_NSPasteboard
_NSStringPboardType
collect2: ld returned 1 exit status
make: *** [all_linux] Error 1
So I tried doing what your wiki suggests to do for MacOSX 10.5 and added the following to the 01.HelloWorld Makefile:

Code: Select all

LDFLAGS += -dylib_file \
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:\
/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib \
-framework Cocoa -framework OpenGL -framework Carbon
That reduced the linking errors to

Code: Select all

_IOCreatePlugInInterfaceForService
_IOIteratorNext
_IOMasterPort
_IOObjectRelease
_IORegistryEntryCreateCFProperties
_IORegistryEntryGetParentEntry
_IOServiceGetMatchingServices
_IOServiceMatching
My next step was to try to build the Irrlicht library from commandline using make sharedlib_osx and make staticlib_osx. Both failed with the following message:

Code: Select all

g++ -I../../include -Izlib -Ijpeglib -Ilibpng -DIRRLICHT_EXPORTS=1 -MM -MF COSOperator.d COSOperator.cpp
COSOperator.cpp:14:26: error: OSXClipboard.h: No such file or directory
The OSXClipboard.h file, along with some other OSX specific files, is located in sources/Irrlicht/MacOSX. So I copied all .h and .mm files from there to sources/Irrlicht/.
make sharedlib_osx failed with the following error:

Code: Select all

ld: Undefined symbols:
__ZN3irr16CIrrDeviceMacOSX5flushEv
_OSXCopyFromClipboard
_OSXCopyToClipboard
__ZN3irr14createDeviceExERKNS_27SIrrlichtCreationParametersE
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/libtool: internal link edit command failed
make staticlib_osx succeeded, but building the 01.HelloWorld example failed with:

Code: Select all

/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols:
irr::createDeviceEx(irr::SIrrlichtCreationParameters const&)
Any suggestions on what I am doing wrong?
Cheers,
Karol Krizka

http://www.krizka.net
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The example compilation can be fixed by adding -framework IOKit (at least that's what google says 8) ). The officially supported way is to use XCode projects, though, which should be part of the OSX SDK. Don't know why they are still missing in the repository.
The .mm files need not be copied, but added as object files to the compile dependencies. I'll have to create the necessary targets and (implicit) rules probably. The final error is due to the same problems
kkrizka
Posts: 70
Joined: Sun Sep 30, 2007 3:10 am

Post by kkrizka »

Thank you for the information. It cleared up what the official way to work on MacOSX is. :)

I still can't build using make *lib_osx, because it ends with the following error:

Code: Select all

tinys-computer:~/Karol/irrlicht/source/Irrlicht TINY$ make sharedlib_osx
g++ -I../../include -Izlib -Ijpeglib -Ilibpng -DIRRLICHT_EXPORTS=1 -MM -MF COpenGLSLMaterialRenderer.d COpenGLSLMaterialRenderer.cpp
In file included from COpenGLSLMaterialRenderer.cpp:22:
COpenGLDriver.h:15:31: error: CIrrDeviceMacOSX.h: No such file or directory
make: *** [COpenGLSLMaterialRenderer.d] Error 1
This can be solved by adding -IMacOSX to the command line, which the Makefile is already doing (see line 85), but for some reason it is not being picked up. I'm not very good with manually editing Makefiles, so I'm not really sure what the problem is. I'll play around with it for a bit though.
Cheers,
Karol Krizka

http://www.krizka.net
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hmm, okay. I've changed it again :wink:
kkrizka
Posts: 70
Joined: Sun Sep 30, 2007 3:10 am

Post by kkrizka »

It's still not working, but now I can at least I think I can tell you why. When you add -IMacOSX to CXXINCS, you don't update the CPPFLAGS variable never gets updated with this change. The same problem is happening with updating the IRROTHEROBJ variable and the LINKOBJ variable not being updated.
Cheers,
Karol Krizka

http://www.krizka.net
kkrizka
Posts: 70
Joined: Sun Sep 30, 2007 3:10 am

Post by kkrizka »

And one more thing, the .mm compile command needs to have -c -o added to it (~line 151) needs to have:

Code: Select all

%.o:%.mm
        $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
Cheers,
Karol Krizka

http://www.krizka.net
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Oh yes, this was a definitely not well-thought change. Fixed.
Post Reply