Compiling under OS X

Compiling under OS X

Postby Knitter » 10 Aug 2011, 21:40

Hi,

I just did a quick test to see what errors I would get while trying to compile LoS under OS X 10.6.8, but I lack experience in compiling by hand (though thanks to LW and now LoS I think I'll learn how to do this properly :) ) and would like to ask some questions.

I'm following the wiki page on how to compile from source, and I'm getting a configuration error from waf (one tool I've never heard about or used ).

{l Code}: {l Select All Code}
Checking for header inotifytools/inotify.h : not found
Checking for header sys/inotify.h          : not found
Checking for header windows.h              : not found
Checking for 'bullet' >= 2.77              : not found
Checking for library linearmath            : not found
Checking for library LinearMath            : not found


All were green except for the above. Bullet and the last two libraries I was expecting that it would fail since I never installed it but the header files are confusing. As far as I can tell, inotify.h is a header file from inotify and that is a Linux kernel extension, windows.h is unknown to me.

I've searched a bit but I think there is no inodify port for OS X.

So, does anyone know if I can get by without inodify.h and where can I find windows.h? I can attach the log file if needed.

Regards,

Knitter
Last edited by Knitter on 18 May 2012, 21:40, edited 1 time in total.
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling 0.5.0 under OS X

Postby amuzen » 11 Aug 2011, 02:53

Configure fails when something necessary isn't found. If something isn't found but configure doesn't stop there, the checked thing is either optional or a usable alternative was found. It works approximately the same way with autotools configure scripts.

Header files not being found is generally harmless because many of them are platform specific. You shouldn't have a windows.h if you're not in Windows, for example. The same applies to a few libraries as well. Libraries also have a lot of fallbacks due to them being distributed in several different ways so you can get an error for one check but another may success. As long as configure continues, it's not a problem.

In your case, the only problem is that you don't have Bullet installed.
User avatar
amuzen
LoS Moderator
 
Posts: 327
Joined: 05 Dec 2009, 02:49

Re: Compiling 0.5.0 under OS X

Postby Knitter » 11 Aug 2011, 11:12

Ah, I see.

So considering that I'll ignore those header files not found, I have a problem with the Bullet libraries that could be easy to solve (I haven't had the time to check) but I would like to run by you.

I compiled the Bullet libraries from the source found in the project's page, it compiled properly with no errors and I chose to create Frameworks (it's a OS X concept, don't know if anyone else is familiar with it). I placed those frameworks in my ~/Library/Frameworks folder but waf doesn't find them.

There are 3 places to look for frameworks: /System/Library/Frameworks, /Library/Frameworks and ~/Library/Frameworks. Should I move the frameworks to /System or /Library? Shouldn't waf be looking in all 3 places? Was the option to create Frameworks instead of traditional libraries a mistake?

I'll have a look at waf as soon as I can but if anyone has some suggestions place post them.

Regards,

Knitter
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling 0.5.0 under OS X

Postby TheAncientGoat » 11 Aug 2011, 12:32

Might help in detecting frameworks:

(in the wscript file)

# Add some specific OSX things
if Options.platform == 'darwin':
conf.check_tool("osx")
conf.env["LINKFLAGS"] += ['-multiply_defined suppress']
conf.env["explicit_install_name"] = True
else:
conf.env["explicit_install_name"] = False
User avatar
TheAncientGoat
Community Moderator
 
Posts: 518
Joined: 27 Dec 2009, 19:06

Re: Compiling 0.5.0 under OS X

Postby Knitter » 14 Aug 2011, 15:00

Those options cause errors :(.

I've tried reducing the changes to only calling the method check_tool, but python complains there is no module named "osx".

I've been looking at log file and I think I have found on problem with the build process. At some point the pkg-config is found and used to locate libraries, the problem is that in pkg-config comes with macports and finds libraries in the macports libraries folder not on the rest of the system. It works for some libraries (sqlite) that are part of macports but not for bullet that is a system library and not available from macports.

This is the log related to the first library failure:
{l Code}: {l Select All Code}
Checking for 'bullet' >= 2.77
['/opt/local/bin/pkg-config', '--atleast-version=2.77', 'bullet']
not found
from /Users/sergiolopes/Working/OpenSource/lipsofsuna: The configuration failed


I've been reading the waf book but have yet to find a way to specify some paths manually in the configure step or even to state them in the wscript file. I'm lost, any suggestions?
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling 0.5.0 under OS X

Postby TheAncientGoat » 14 Aug 2011, 15:20

Try

{l Code}: {l Select All Code}
# Add some specific OSX things
   if Options.platform == 'darwin':
       ctx.check_tool("c_osx")
       ctx.env["LINKFLAGS"] += ['-multiply_defined suppress']
       ctx.env["explicit_install_name"] = True
   else:
       conf.env["explicit_install_name"] = False
User avatar
TheAncientGoat
Community Moderator
 
Posts: 518
Joined: 27 Dec 2009, 19:06

Re: Compiling 0.5.0 under OS X

Postby Knitter » 14 Aug 2011, 15:30

Changing "osx" to "c_osx" makes the script run without the previous error but the library detection stays the same, still trying to use pkg-conf and naturally failing.
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling 0.5.0 under OS X

Postby TheAncientGoat » 16 Aug 2011, 12:42

You have to add it before line #base dependencies and after line ctx.env.LINKFLAGS_TEST
User avatar
TheAncientGoat
Community Moderator
 
Posts: 518
Joined: 27 Dec 2009, 19:06

Re: Compiling 0.5.0 under OS X

Postby Knitter » 16 Aug 2011, 13:23

Which I did and the result is always the same. It is always trying to use pkg-conf that can't find any library installed in my system that is not part of macports.

I'll rebuild Bullet without creating a Framework and see if I can make pkg-conf find the libraries this way, but making the config script detect system libraries would be best.
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling 0.5.0 under OS X

Postby Knitter » 16 Aug 2011, 13:42

Some updates: After recompiling Bullet as "naked" dynamic libraries and installing them cmakes sends the libs to /usr/local/include/. The script now detects linearmath but fails trying to find btBulletCollisionCommon.h. It also fails trying to find the correct version of bullet, I have the current trunk (2.8) and pkg-conf says it's not > 2.7 :(
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling 0.5.0 under OS X

Postby TheAncientGoat » 16 Aug 2011, 13:46

change

if not ctx.check_cfg(package='bullet', atleast_version='2.77', args='--cflags --libs', mandatory=False):

to

if not ctx.check_cfg(package='bullet', args='--cflags --libs', mandatory=False):
User avatar
TheAncientGoat
Community Moderator
 
Posts: 518
Joined: 27 Dec 2009, 19:06

Re: Compiling 0.5.0 under OS X

Postby Knitter » 16 Aug 2011, 16:20

I hate CMAKE but it seems way so much simpler, I just put the path to were my libraries are an voilá, the thing finds them, waf and pkg-config on the other hand are getting on my nerves!

So, removing the version check seems to make it find some libraries, I had to remove that "atleast_version" flag on some other validations since it never considered that my versions were valid.

I'm trying to configure the build using the following line, since I didn't want to change my bash profile at the moment and it allows me to test things:
{l Code}: {l Select All Code}
PKG_CONFIG_PATH=/Library/Frameworks/lib/pkgconfig:/opt/local/lib/pkgconfig ./waf configure


Those paths are for the *.pc files that pkg-config needs. Now I get some errors on detecting: GL and OpenGL32

OpenGL32 is the library name on Windows, I don't know about GNU Linux, but in OS X it's called OpenGL. GL is installed and if I use pkg-config it finds it, though it won't find OpenGL since I have no OpenGL.pc file that pkg-config needs. But looking at the log, it's not using pkg-config to find these two so I should probably be giving waf a path to use when including my libraries if he can't find them...

Stuck again :(
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling 0.5.0 under OS X

Postby TheAncientGoat » 16 Aug 2011, 16:31

try replacing everything under #GL with
{l Code}: {l Select All Code}
   # GL
   if not ctx.check_cc(lib='GL', mandatory=False, uselib='CORE TEST', uselib_store='GLEW'):
      if not ctx.check_cc(lib='OpenGL', mandatory=False, uselib='CORE TEST', uselib_store='GLEW'):
         ctx.check_cc(lib='OpenGL32', mandatory=True, uselib='CORE TEST', uselib_store='GLEW')


Also, thanks for sticking through this! You're doing us a /big/ favour, sorry nekotaku and I are so useless with mac stuff :(
User avatar
TheAncientGoat
Community Moderator
 
Posts: 518
Joined: 27 Dec 2009, 19:06

Re: Compiling 0.5.0 under OS X

Postby Knitter » 16 Aug 2011, 16:55

Had tried that also :), and made a few more changes that I don't understand but managed to get me a successful configuration, though I suspect it's not a proper one :(

The code for GL and AL are as follows, I removed most of AL stuff from the wscript:
{l Code}: {l Select All Code}
if not ctx.check_cfg(package='gl', args='--cflags --libs', mandatory=False):
   ctx.check_cc(lib='OpenGL', mandatory=True, uselib='CORE TEST', uselib_store='GLEW')

# AL
ctx.check_cc(header_name='OpenAL/al.h', mandatory=True, uselib='CORE TEST', uselib_store='OpenAL')


I have no idea what uselib_store does, if I leave it at AL the configuration passes, if I use OpenAL the configuration also passes. I end up with a lua5.1 not found, though lua is, and the initial header files that are not available in this platform.

Still, when I try to build I get compilation errors, that I hadn't had the time to try and figure out, I'll update as soon as I have more info. The errors are:
{l Code}: {l Select All Code}
Build failed
 -> task failed (exit status 1):
   {task 4312603216: c ai-sector.c -> ai-sector.c.0.o}
 -> task failed (exit status 1):
   {task 4312602960: c ai-manager.c -> ai-manager.c.0.o}


The first time I run ./waf shows no other error, but if I run ./waf again I end up with:
{l Code}: {l Select All Code}
n file included from /Users/sergiolopes/Working/OpenSource/lipsofsuna/src/lipsofsuna/system.h:21,
                 from ../src/lipsofsuna/ai/ai-manager.c:25:
/Users/sergiolopes/Working/OpenSource/lipsofsuna/src/lipsofsuna/system/system.h:49: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘lisys_time’
In file included from /Users/sergiolopes/Working/OpenSource/lipsofsuna/src/lipsofsuna/system.h:21,
                 from ../src/lipsofsuna/ai/ai-sector.c:25:
/Users/sergiolopes/Working/OpenSource/lipsofsuna/src/lipsofsuna/system/system.h:49: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘lisys_time’
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling 0.5.0 under OS X

Postby TheAncientGoat » 13 Sep 2011, 19:07

Try with ./waf build -v
User avatar
TheAncientGoat
Community Moderator
 
Posts: 518
Joined: 27 Dec 2009, 19:06

Re: Compiling under OS X

Postby Knitter » 18 May 2012, 22:04

Just changed the title since I'm back at this.

After my initial try I've migrated to OS X Lion, gotten a bit more experience with macports and compiling things from source, but LoS still eludes me.
I got a new copy of the git repo and I'm using the latest code, I installed all the needed libraries using macports and waf finds almost all of them.

waf wasn't finding enet, though it is installed and there were other games using it. I installed libenet from source and now I have the libenet.a in macports and enet.h in my /usr system's folder. waf now finds enet.h. I should note that pkg-config finds the library if I use the --cflags and --libs options.

Same problem with OIS, it is installed and since it is required by ogre and was used when compiling ogre I think it is correctly installed, also pkg-config finds OIS, like with enet. Still waf fails saying that OIS is not installed/found. How are this libraries being detected? How can I get a more verbose output than that offered by -v, mainly how can I see exactly the commands being executed, I mean a verbatim version of the executed command and not the "processed" output of waf.

I didn't want to install OIS system wide if I could use the existing macports version.
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Re: Compiling under OS X

Postby amuzen » 19 May 2012, 04:45

The commands that configure runs can be found from `.build/config.log'. I don't know what kind of quirks there are in OS X, but generally pkg-config not finding libraries tends to be caused by either the OS using different names for the .pc files or pkg-config not looking for them in the right directory. You might want to pay attention to those possibilities when examining the log file.
User avatar
amuzen
LoS Moderator
 
Posts: 327
Joined: 05 Dec 2009, 02:49

Who is online

Users browsing this forum: No registered users and 1 guest