Building libgdx for Mac

Anything libgdx related goes here!

Building libgdx for Mac

Postby oldskool73 » Sun Nov 14, 2010 6:29 pm

EDIT (Mario): we now officiall support MacOSX in the nightlies and will include the natives in the next release. Thanks to you people for providing us with the initial batch of natives!

[EDIT : I've condensed the good stuff into a blog post here if you don't want to read the whole thread...
http://www.dustypixels.com/blog/2010/11 ... dx-on-osx/]


Hi all,

I'm trying to build a version of libgdx.so for mac so I can do the whole 'run on desktop' thing, but I'm having some problems, wondering if anyone can help...

Following the info on the wiki here I've got everything checked out, CDT installed & $JAVA_HOME set, but I'm getting the error : 'JNIEXPORT does not name a type' at various points in the box2d stuff. Any ideas?

I'm guessing some additions/changes need to be made to the ant build script too as it's only got targets for win/linux at the moment, I can probably poke around and figure out what needs changing but any guidance would be great.

Would love to get this working, just about every dev I know moved over to Mac a few years ago and the desktop testing is a great selling point of the library.
Last edited by oldskool73 on Mon Nov 15, 2010 2:39 am, edited 1 time in total.
oldskool73
 
Posts: 21
Joined: Thu Nov 11, 2010 2:17 pm

Re: Building libgdx for Mac

Postby mzechner » Sun Nov 14, 2010 10:22 pm

I'll try to add mac support on monday. I don't have a mac and also don't have a hacintosh at my disposal (and i'm to poor to buy a mac mini :p).
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Building libgdx for Mac

Postby pirato » Mon Nov 15, 2010 12:09 am

Hi,

I'm new to libgdx (great work btw :)), but i have a working libgdx on os x.

In connection with a Java update, Apple seperated the Development Files (like jni.h) into another package. You need an Apple Developer Account and visit developer.apple.com. In the Java Downloads section you will find "Java for Mac OS X 10.6 Update 3 Developer Package", which you have to install.

Then a step which maybe is optional, i don't know:
Get the sources of libmpg123 and run ./configure && make && sudo make install, because in the build-wiki libmpg123 is marked as a dependency.

You have it, but for others: Install the CDT Plugin for Eclipse...

After checking out the gdx Project in Eclipse, go and edit the Project Settings.

- In the C/C++ Build Options create a new "Mac" Configuration based on the linux conf and set this as active.

- Settings for the C++ Compiler:
you have to include the java headers -> -I/System/Library/Frameworks/JavaVM.framework/Headers
No more "jni.h not found" errors...

- Settings for the C++ Linker:
uncheck the shared library checkbutton and instead add "-dynamiclib" as a flag

In the "Build Artifact"-tab you may also want to change the artifact extension to "dylib", but i think this is not necessary.

Hope this helps :?
pirato
 
Posts: 3
Joined: Sun Nov 14, 2010 11:45 pm

Re: Building libgdx for Mac

Postby oldskool73 » Mon Nov 15, 2010 12:20 am

wow, brilliant pirato, thanks.
May be a bit cheeky of me to ask after you gave such clear directions, but you couldn't just post your one on here could you (or hotfile or whatever) so I and others can grab it until the official one gets added to the repos? :oops:
oldskool73
 
Posts: 21
Joined: Thu Nov 11, 2010 2:17 pm

Re: Building libgdx for Mac

Postby oldskool73 » Mon Nov 15, 2010 12:54 am

Hmm, I'm stuck on 10.6.2 due to various silly hackintosh hardware issues, so I can't do this myself anyway as the Java package won't install (requires 10.6.3), so I'm down at the first hurdle :(

Guess I'm reliant on one of you guys ...
oldskool73
 
Posts: 21
Joined: Thu Nov 11, 2010 2:17 pm

Re: Building libgdx for Mac

Postby mzechner » Mon Nov 15, 2010 12:56 am

Damn, you need a developer account to get to the JNI headers? <3 Apple...

Pirato, if i give you commit rights, would you be willing to produce the natives for Mac OS X (x86) every now and then? That would really help me out. We have the (silly and non-professional) habit of including our native shared libs in the SVN trunk so that our CI server can fetch them without the need for cross-compilation. You'd be the #1 contributor of the month! (sorry Nate and lefthand :p)
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Building libgdx for Mac

Postby pirato » Mon Nov 15, 2010 12:57 am

Hi,

i don't know if this will work, but let's try :D

I'm no expert when it comes to shared libraries etc..., but otool -L libgdx.dylib gives me the following output
Code: Select all
otool -L libgdx.dylib
libgdx.dylib:
   libgdx.dylib (compatibility version 0.0.0, current version 0.0.0)
   /usr/local/lib/libmpg123.0.dylib (compatibility version 26.0.0, current version 26.6.0)
   /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)


So i assume you have to install libmpg123 to /usr/local/lib for this to work...
But as I said i really don't know.

Here is the dynamic library:
http://hotfile.com/dl/82618111/514436a/libgdx.dylib.html
pirato
 
Posts: 3
Joined: Sun Nov 14, 2010 11:45 pm

Re: Building libgdx for Mac

Postby oldskool73 » Mon Nov 15, 2010 1:09 am

YAY! You rock!
Appears to work fine for the helloworld & invaders samples so far, excellent!

I had built and installed libmpg123 before trying it so can't tell you if it's required either I'm afraid.
oldskool73
 
Posts: 21
Joined: Thu Nov 11, 2010 2:17 pm

Re: Building libgdx for Mac

Postby mzechner » Mon Nov 15, 2010 1:19 am

As it is dynamically linked the libmpg123.dylib file has to be installed on the target system i'm afraid. the lgpl libmpg123 uses as a license explicitely demands dynamic linking so there's no way around that i'm afraid. Thinks shouldn't blow up though as long as you don't use Mpg123Decoder (i think).

Thanks pirato, and please consider to become the official macos maintainer :) (you don't need to do anything except building the dylib and commiting it to svn at very infrequent times, e.g. once a month at most).
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Building libgdx for Mac

Postby pirato » Mon Nov 15, 2010 1:37 am

mzechner wrote:Thanks pirato, and please consider to become the official macos maintainer :) (you don't need to do anything except building the dylib and commiting it to svn at very infrequent times, e.g. once a month at most).


Oh oh oh, you think that's a good idea :roll:
Half the time I just used "guess/google, try and error" to get this to work, but if "my" version works i would love to help.
pirato
 
Posts: 3
Joined: Sun Nov 14, 2010 11:45 pm

Next

Return to Libgdx

Who is online

Users browsing this forum: Google [Bot] and 1 guest