How do you compile command line args within Xcode?

Joined
Jul 19, 2011
Messages
3
Reaction score
0
Points
1
Hi folks.
I'm trying to compile RakNet for the mac. The readme portion pertaining to macs is the following:

-----------------------------------------
Mac Users
-----------------------------------------
From My Community - Index
Open a Terminal window and type: cd ~/Desktop/RakNet/Source

Give the following command:

Code:
g++ -c -DNDEBUG -I -isysroot /Developer/SDKs/MacOSX10.5u.sdk/ -arch i386 *.cpp
Use whichver SDK you have. However, the 10.4 SDK is bugged and will not compile unless you use GCC 4.0 from inside XCODE

The sources should build cleanly. This gives you a bunch of PowerPC binaries, compiled against the 10.3.9 SDK which is a good thing.

Give the following command:

Code:
libtool -static -o raknetppc.a *.o

This will stitch together a static library for the PowerPC architecture. There may be warnings that some .o files do not have any symbols. If you want to be prudent, remove the named files (the .o files, not the .cpp files!) and re-run the libtool command.

Now, we build the source files for Intel:

Code:
gcc -c -I ../Include -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch i386 *.cpp

..and stitch it into a i386 library:

Code:
libtool -static -o rakneti386.a *.o

Now, type:

Code:
ls *.a

which should list the two .a files. Now, we make them into a universal binary:

Code:
lipo -create *.a -o libraknet.a

You now have a file named libraknet.a. This is the RakNet library, built to run on both PowerPC and Intel Macs. Enjoy! ;-)

If you try to compile this, it gives you errors when you get to the "gcc -c -I ../Include -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch i386 *.cpp" part. I am wondering if this refers to the part I highlighted in red about compiling it within Xcode.

Is there a way to compile GCC command lines from within Xcode? If so, please let me know where I put the arguments in xcode. Or is there some special terminal command I need to enter so that the terminal command runs it through Xcode somehow?

If anyone has any pointers, I'd really appreciate it.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
There's no reason you can't use gcc from the command line and I highly doubt that adding compile options in Xcode will solve this. What was the error?

Check your SDK folder as you may not even have the 10.4 one and make sure you're using the right one.
 
OP
T
Joined
Jul 19, 2011
Messages
3
Reaction score
0
Points
1
There's no reason you can't use gcc from the command line and I highly doubt that adding compile options in Xcode will solve this. What was the error?

Check your SDK folder as you may not even have the 10.4 one and make sure you're using the right one.

Following the readme instructions, when I enter the "gcc -c -I ../Include -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch i386 *.cpp" command, I start to get a bunch of errors.

trevors-imac:Source trevor$ gcc -c -I ../Include -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ -arch i386 *.cpp
In file included from BitStream.h:17,
from BitStream.cpp:12:
RakMemoryOverride.h:14:15: error: new: No such file or directory
In file included from RakString.h:8,
from BitStream.h:21,
from BitStream.cpp:12:
/Developer/SDKs/MacOSX10.4u.sdk//usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from BitStream.h:25,
from BitStream.cpp:12:
/Developer/SDKs/MacOSX10.4u.sdk//usr/include/float.h:8:24: error: float.h: No such file or directory
BitStream.cpp:35:17: error: cmath: No such file or directory
...
And then many more such errors.

Ya, I do have /Developer/SDKs/MacOSX10.4u.sdk/

I wonder if it's just bugged?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Is there any particular reason you are using the 10.4 SDK? Are you running Tiger? If not, use a newer SDK.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top