Page 1 of 1

Compiling from source on a mac?

Posted: Sat Jan 16, 2010 4:21 pm
by Ithulta
I got interested in compiling from the source instead of using one of the universal disk images when I found a few cool patches that I wanted to use, but I encountered several issues when I tried make -f makefile.osx. I got a little farther along with the help of a few people's comments in a thread of mine about installing patches of a mac, but I never got it to compile. There were a few links on the wiki to a discussion of how to compile tome for a mac, but I'm guessing that of course was lost along with everything else when the forum was hacked. Anybody have any experience with this kinda thing?

Re: Compiling from source on a mac?

Posted: Sat Jan 16, 2010 7:16 pm
by madmonk
Which version of ToME?

Re: Compiling from source on a mac?

Posted: Sat Jan 16, 2010 9:33 pm
by Ithulta
2.3.5

Re: Compiling from source on a mac?

Posted: Sat Jan 16, 2010 9:49 pm
by madmonk
Can you put the output up so we can see what errors you are getting, please!

Re: Compiling from source on a mac?

Posted: Sat Jan 16, 2010 10:31 pm
by Ithulta
A post from the other thread (http://forum.t-o-m-e.net/viewtopic.php?f=1&t=21319; it's got some stuff other people suggested, so take a look if you want more information):
admins-macbook:~ NameHere$ cd Downloads/tome-235-src/src
admins-macbook:src NameHere$ make -f makefile.osx
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/lapi.o lua/lapi.c
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/lcode.o lua/lcode.c
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/ldebug.o lua/ldebug.c
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/ldo.o lua/ldo.c
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/lfunc.o lua/lfunc.c
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/lgc.o lua/lgc.c
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/llex.o lua/llex.c
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/lmem.o lua/lmem.c
MACOSX_DEPLOYMENT_TARGET="10.1" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/lobject.o lua/lobject.c
In file included from lua/lobject.c:8:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lua/lobject.c: In function ‘luaO_verror’:
lua/lobject.c:86: warning: implicit declaration of function ‘va_start’
lua/lobject.c:88: warning: implicit declaration of function ‘va_end’
In file included from lua/lobject.c:8:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lua/lobject.c: In function ‘luaO_verror’:
lua/lobject.c:86: warning: implicit declaration of function ‘va_start’
lua/lobject.c:88: warning: implicit declaration of function ‘va_end’
lipo: can't open input file: /var/folders/jE/jEfdAyyMG3Wg84fbKz8VLE+++TM/-Tmp-//cc28fHxr.out (No such file or directory)
make: *** [lua/lobject.o] Error 1
I know for a fact that stdarg.h does exist at that location. The next two errors I'm not sure about. The last file (/var/folders/jE/jEfdAyyMG3Wg84fbKz8VLE+++TM/-Tmp-//cc28fHxr.out) doesn't exist. I'm running 10.6, not 10.4 (or 10.1). Would that cause problems with compiling from the source? It seems to be trying to build for an earlier version.

Re: Compiling from source on a mac?

Posted: Sat Jan 16, 2010 11:13 pm
by madmonk
Yes, I saw that, I did not make the connection!!! My bad!

I am not a MAC expert, I was hoping to get you some help!

Re: Compiling from source on a mac?

Posted: Sat Jan 16, 2010 11:18 pm
by madmonk
Are the Developer libraries installed?

Re: Compiling from source on a mac?

Posted: Sat Jan 16, 2010 11:59 pm
by Ithulta
Yes, if you mean all the SDKs (/Developer/SDKs/MacOSX10.4u.sdk, /Developer/SDKs/MacOSX10.5.sdk, etc.).

Re: Compiling from source on a mac?

Posted: Sun Jan 17, 2010 4:22 am
by Derakon
Here's the contents of my stdarg.h in its entirety:

Code: Select all

/* This file is public domain.  */
/* GCC uses its own copy of this header */
#if defined(__GNUC__)
#include_next <stdarg.h>
#elif defined(__MWERKS__)
#include "mw_stdarg.h"
#else
#error "This header only supports __MWERKS__."
#endif
It's the #include_next line that is giving you problems. I looked up the include_next directive; if I understand it correctly, basically it tells the compiler "skip to the second instance in your include paths that has this file". So if your include path is /usr/include;~/include;~/projects/angband/include, for example, and stdarg.h exists in /usr/include and ~/projects/angband/include, then the version in ~/projects/angband/include would be #included. Per the comments, this file is doing this to allow for different behavior between GCC and whatever MWERKS is (at a guess, XCode).

The practical upshot of this is that, yes, /usr/include/stdarg.h exists, but you need another file with the same name (but presumably different contents) somewhere else, since that file just #include_next's itself. Where it should be or what should be in it, I don't know.

I'd wager that the other error you're getting is just an error cascade from this error (that is, fix this one, and the other will go away). As for the warnings, if the game doesn't work once you've fixed this problem, then I'd worry about them, but not otherwise.

Re: Compiling from source on a mac?

Posted: Mon Jan 18, 2010 9:51 pm
by Ithulta
Well, I tried replacing the original stdarg.h (backing it up first, of course) with one I found at /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/starg.h. It got rid of most of the previous errors, but make returned an even more esoteric (at least to me) message this time.

Code: Select all

Last login: Mon Jan 18 16:12:24 on ttys000
admins-macbook:~ Name$ cd tome-src/tome-235-src/src
admins-macbook:src Name$ make -f makefile.osx
MACOSX_DEPLOYMENT_TARGET="10.5" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/lapi.o lua/lapi.c
MACOSX_DEPLOYMENT_TARGET="10.5" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/lcode.o lua/lcode.c
...cc compiling various other stuff...
MACOSX_DEPLOYMENT_TARGET="10.5" cc -Wall -Os -g -pipe -fpascal-strings -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -Ilua -I. -DUSE_MACOSX -DMACH_O_CARBON -DUSE_PRECISE_CMOVIE -DUSE_UNIXSOCK -DUSE_EGO_GRAPHICS -DUSE_TRANSPARENCY -DSUPPORT_GAMMA -DUSE_LUA -c -o lua/tolua_bd.o lua/tolua_bd.c
MACOSX_DEPLOYMENT_TARGET="10.5" cc  -o tolua lua/lapi.o lua/lcode.o lua/ldebug.o lua/ldo.o lua/lfunc.o lua/lgc.o lua/llex.o lua/lmem.o lua/lobject.o lua/lparser.o lua/lstate.o lua/lstring.o lua/ltable.o lua/ltests.o lua/ltm.o lua/lundump.o lua/lvm.o lua/lzio.o lua/lauxlib.o lua/lbaselib.o lua/ldblib.o lua/liolib.o lua/lstrlib.o lua/tolua_lb.o lua/tolua_rg.o lua/tolua_tt.o lua/tolua_tm.o lua/tolua_gp.o lua/tolua_eh.o lua/tolua_bd.o lua/tolua.c lua/tolualua.c -framework CoreFoundation -framework QuickTime -framework Carbon -arch i386 -arch ppc -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
ld: library not found for -lcrt1.10.5.o
collect2: ld returned 1 exit status
ld: library not found for -lcrt1.10.5.o
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/jE/jEfdAyyMG3Wg84fbKz8VLE+++TM/-Tmp-//cclhPjzw.out (No such file or directory)
make: *** [tolua] Error 1
ld and lipo are both failing for weird reasons. I have no idea what file "-lcrt1.10.5.o" or "/var/folders/jE/jEfdAyyMG3Wg84fbKz8VLE+++TM/-Tmp-//cclhPjzw.out" are referenced in. Apparently the stuff in /var/folders consists of caches and the like (everything there has big intimidating names to prevent users fiddling around in there). I don't know why ToME would need something from there. The path up till "/cclhPjzw.out" exists, and two files named "ccxz4ZcQ.out" and "cckS9wm1.out" are in that directory.

EDIT:
Apparently, "/var/folders/jE/jEfdAyyMG3Wg84fbKz8VLE+++TM/-Tmp-/" is the value of my TMPDIR variable. The tacked on slash seems rather strange, so I tried removing it to see what would happen. That got rid of the double slash in the second error message, but the file doesn't exist so there was of course still an error.

EDIT:
Also, MWERKS is for CodeWarrior (Metrowerks).

Re: Compiling from source on a mac?

Posted: Tue Jan 19, 2010 5:11 am
by Derakon
You're missing the crt1 library .o file. A quick Googling suggests trying adding this:

-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib

Assuming that location exists, of course.

In general, you should deal with errors from the top down, because errors can cascade: something fails early on, which causes some process to not complete successfully, but the rest of the system continues on as if it had, and throws more errors when it discovers the problem again.

Re: Compiling from source on a mac?

Posted: Fri Jan 22, 2010 2:57 am
by Ithulta
Well, I wasn't missing crt1.o, but I was missing crt1.10.5.o, which is (unsurprisingly) in the 10.5 SDK, which you mentioned. I finally patched everything, compiled, and it all seems to be working great. Thanks for helping me.