New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

How do you compile command line args within Xcode?


Post Reply New Thread Subscribe

 
Thread Tools
Trev

 
Member Since: Jul 19, 2011
Posts: 3
Trev is on a distinguished road

Trev is offline
Hi folks.
I'm trying to compile RakNet for the mac. The readme portion pertaining to macs is the following:

Quote:
-----------------------------------------
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.
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,050
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Trev

 
Member Since: Jul 19, 2011
Posts: 3
Trev is on a distinguished road

Trev is offline
Quote:
Originally Posted by vansmith View Post
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?
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 18,050
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
Is there any particular reason you are using the 10.4 SDK? Are you running Tiger? If not, use a newer SDK.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
QUOTE Thanks
Trev

 
Member Since: Jul 19, 2011
Posts: 3
Trev is on a distinguished road

Trev is offline
Quote:
Originally Posted by vansmith View Post
Is there any particular reason you are using the 10.4 SDK? Are you running Tiger? If not, use a newer SDK.
I believe in order to support non-intel macs, I need to use 10.4 SDK.
QUOTE Thanks

Post Reply New Thread Subscribe


« Darwin 11 source code | C++ Problems »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Xcode refuses to launch after first launch. Havoc93 OS X - Development and Darwin 2 08-24-2010 02:51 PM
content.yieldmanager.edgesuite.net XCODE nachohi88 Internet, Networking, and Wireless 1 03-27-2010 09:41 PM
C Program Trouble Compiling w/GCC, Trouble Running in Xcode ebeccarayray OS X - Apps and Games 1 09-28-2009 09:41 PM
xcode porting question shelflife19 OS X - Development and Darwin 0 11-30-2007 08:35 PM
Question about exceptions in C++ via Xcode cipher OS X - Development and Darwin 2 06-25-2004 10:02 AM

All times are GMT -4. The time now is 07:40 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?