How to compile Wesnoth on Mac OS X

Get help with compiling or installing the game, and discuss announcements of new official releases.

Moderator: Forum Moderators

Locked
ulissesroc
Posts: 70
Joined: December 28th, 2007, 12:02 pm
Location: Amsterdam
Contact:

Post by ulissesroc »

lwa wrote:As far as I know, you already have the right python framework on Leopart (in
/System/Library/Frameworks/Python.framework/Versions/) so you can skip the python installation step.

Also, I had trouble to compile an universal binary with Xcode 3.0, since many new errors occured (which can be fixed individualy with flags here and there) and the png library is not linked with universal library stuff. So I downgraded to Xcode 2.5 which works well.
I didn't have python installed, for example. I don't know why. Anyway, I am going to download the 2.5 too, if you're saying that the new one is not working. Luckily, my university connection allow me to download at 10 (!!) MB/s. In 90 second I downloaded it (I think that copying from a cd, with the iBook, is usually slower :D)
lwa
Inactive Developer
Posts: 271
Joined: June 11th, 2005, 8:19 am
Location: Paris, France

Post by lwa »

Xcode 3.0 should work in native mode, but it may require extra flags to disable some new features. Xcode 2.5 is closer than the well tested Tiger version and should be easier to use for now.
User avatar
anakayub
Moderator Emeritus
Posts: 526
Joined: May 3rd, 2007, 12:44 pm
Location: Malaysia
Contact:

Post by anakayub »

ulissesroc wrote: Edit: now these errors seem to be gone, since I was following the instruction in the front page, which is different from the one in the howto.txt present in the maccompiled stuff directory.

Currently I am compiling 110 out of 156 source files. Let's see.

Was it successful? :) On another note, regarding the directions in the first page, what does it mean by double-clicking the "project builder bundle"?

Edit:
Finally got 1.3.14 right this time, using XCode 3.0 the whole time. This is what I did:

1) Copied the whole MacCompileStuff into the wesnoth folder.
2) Opened the XCode project file in MacCompileStuff.
3) Checked the BattleForWesnoth>Wesnoth>src. If it's in red, right-click and go to info. Locate the correct location of the src folder, and all of it's contents should be properly located (all files are in black, not red).
Image
4) I don't know why, but when I tried to compile Translations, the script problem would not locate "makefile.am". What I did was changed the script - Go to Targets>Translations>Run Script (double-click). Change line 5 to [for domain in $(grep ^SUBDIRS "$wesnoth-1.3.14/po/Makefile.am" | cut -d= -f2)]. This specifically targets Makefile.am in Wesnoth-1.3.14/po. The problem was probably related to point (5), so I suggest trying to build first without the change, and only change if XCode cannot find makefile.am.
Image
5) Then just select "Disk Image" for active target and build. No need to have boost, as the MacCompileStuff already contains the boost iostream library as a framework (thanks, Iwa). The products should be in Wesnoth-1.3.14/MacCompileStuff/build. If I put the files (BFW xcode project file and MacOSX folder) in the MacCompileStuff instead of the folder itself, XCode would not be able to locate the data, sounds, images and fonts folders located in the BfW source folder during BfW>Run Scripts *No 1*
Image

I'm currently testing out using XCode with the current SVN, if I'm successful I'll post.

Got the SVN, too, using the boost source headers. Finally I can sleep in (relative) peace. :P
Take a breath.
ulissesroc
Posts: 70
Joined: December 28th, 2007, 12:02 pm
Location: Amsterdam
Contact:

Post by ulissesroc »

I was indeed successfull with Xcode 2.5

If someone wants a build optimized for ppc g4, send me a pm, I will upload to my university server.

By the way, I choosed not to have a ppc 386 build, but just ppc.

But I wonder why it was not working with 1.3.13's build stuff.

Anyhow, I am happy to have something optimized for my machine, and to have learned how to do it. If will problably don't depend anymore on Mac's packager (who I want to thank for the great work, and for helping me having this done).
radx
Posts: 2
Joined: March 23rd, 2008, 6:22 pm

Re: How To Compile On A Mac

Post by radx »

I compiled Wesnoth using xcode 3.0 running on 10.5. (Compiled on both of my macs - intel macbook and intel mac pro).

Took a bit of work. It seems the xcode project provided with the binary distribution links against 10.4u sdk. I couldn't get that to work no matter what. Switching from 10.4u to 10.5 seems to have broken other dependencies.

In the end I managed to compile Wesnoth from scratch by creating new xcode project, importing some obj-c files from the old project and manually linking/compiling all the required dependencies.

Also, provided xcode project does not have a debug build profile - you would either need to add it, or enable debug info generation for the existing profile (in your target preferences..)
User avatar
anakayub
Moderator Emeritus
Posts: 526
Joined: May 3rd, 2007, 12:44 pm
Location: Malaysia
Contact:

Re: How To Compile On A Mac

Post by anakayub »

Mind uploading your XCode compilation kit (project file, etc.) up to the forums? I've always wanted to try to build a binary distribution with XCode 3.0 using the 10.5 SDK.
Take a breath.
ulissesroc
Posts: 70
Joined: December 28th, 2007, 12:02 pm
Location: Amsterdam
Contact:

Re: How To Compile On A Mac

Post by ulissesroc »

radx wrote: Also, provided xcode project does not have a debug build profile - you would either need to add it, or enable debug info generation for the existing profile (in your target preferences..)
it would be great if you explain how to do it, precisely.

For the 10.4u sdk you'll need an hack (some compiler flags for libGL.dylib). However, the gcc version breaks everything if compiled in a ppc and played on an intel (users feedback).

That's why new versions are compiled with xcode 2.5.
User avatar
anakayub
Moderator Emeritus
Posts: 526
Joined: May 3rd, 2007, 12:44 pm
Location: Malaysia
Contact:

Re: How To Compile On A Mac

Post by anakayub »

This new MacBook Pro (just the low end version) just rocks. Previously compiling takes an hour, now it's less than 20 minutes, giving me lots of time to experiment! :D

I've just got BfW compiled on XCode 3.0 with the 10.5 sdk as a UB, finally. It's actually not hard either, as I just followed the errors encountered when using the one included with the BfW Mac binaries and modifying the settings etc. However, this is not fully tested at all other than going onto the server etc.; do at your own risk. The whole thing took me 30 minutes.

1) I copied libfreetype.a from the 10.4u sdk and copied it to the 10.5 sdk. Along with that I changed the path in the libfreetype linking script (XR... is a bit different comparing 10.5 to 10.4 sdk). Not based on a reputable source.
2) Any dylib problems encountered were solved by deleting those dylib files from the 10.4u sdk. This was among the advice given in the XCode mailing lists a while back.
3) There you have it!

Is there a good way to upload this test binary so that those with different macs can test to see if it works on other architectures?
Attachments
Picture-11.png
Picture-11.png (16.96 KiB) Viewed 5793 times
Take a breath.
radx
Posts: 2
Joined: March 23rd, 2008, 6:22 pm

Re: How To Compile On A Mac

Post by radx »

anakayub wrote:Is there a good way to upload this test binary so that those with different macs can test to see if it works on other architectures?
Doh! I completely forgot about this thread guys, sorry!! Yeah, upload your binary somewhere, 'll test it. If you still want my project files let me know.. but I did pretty much what you did.
ulissesroc wrote:it would be great if you explain how to do it, precisely.
That's pretty simple - select Battle of Wesnoth in targets, right click -> get info, build tab. Then enable 'generate debug symbols':

Image

Now you should be able to set breakpoints and step through the code using xcode's gdb.
fiddler.wo.a.roof
Posts: 1
Joined: October 7th, 2008, 5:07 am

Re: How To Compile On A Mac

Post by fiddler.wo.a.roof »

How can I compile 1.5.5 on a Mac... I have tried using the MacCompileStuff for 1.5.3 and it did not work
User avatar
anakayub
Moderator Emeritus
Posts: 526
Joined: May 3rd, 2007, 12:44 pm
Location: Malaysia
Contact:

Re: How To Compile On A Mac

Post by anakayub »

My apologies, as I've only been able to work on a start-stop basis for a few months.

Here's a problem I've been getting with both 1.5.4 and 1.5.5 (hence no Mac build):

Code: Select all

20081026 20:26:38 error config: No title image defined
20081026 20:26:38 error display: Could not find game logo
WML exception:
User message: The maximum text width is less than 1.
Dev message: Condition 'max_width > 0' failed at /Users/Amir/Projects/wesnoth-1.5.5/MacCompileStuff/../src/marked-up_text.cpp:365 in function 'word_wrap_text'.
logout
Based on IRC chats (with suokko iirc), the problem was solved by a patch after 1.5.4 was released, and worked for other build systems that encountered the same problem.

I hope that anyone familiar can help me with this. I'm forced to bring it here instead of IRC as I don't have the free time in long periods to work on it, so correspondence via the forums is the best way to go.
Take a breath.
penguin
macOS Packager
Posts: 239
Joined: April 17th, 2004, 5:16 pm
Location: Ontario, Canada
Contact:

Re: How To Compile On A Mac

Post by penguin »

I solved that problem with a quick fix to game.cpp; add after line 398:

Code: Select all

if (game_config::path == "." || game_config::path == "./")
{
	game_config::path = get_cwd();
}
The problem is caused by some new config stuff that wasn't fixed yet, but this fixes it (for me anyway).

Do you have pango working (UB, and on 10.4)? I have it linking, but it can't find any fonts, so all it displays is boxes... Other than that, my build works, I think.
User avatar
anakayub
Moderator Emeritus
Posts: 526
Joined: May 3rd, 2007, 12:44 pm
Location: Malaysia
Contact:

Re: How To Compile On A Mac

Post by anakayub »

I'll get back to you when I've tested it. Thanks.

But yes, 1.5.3 worked for me; all of the statics in the lib folder has to be linked to. I made them all UB, with 10.4 sdk, so they should work with ppc Tiger.
Take a breath.
penguin
macOS Packager
Posts: 239
Joined: April 17th, 2004, 5:16 pm
Location: Ontario, Canada
Contact:

Re: How To Compile On A Mac

Post by penguin »

Well, I got it to work. Turns out Pango isn't loading ttf files directly at all, and is instead using the OS X font services. Which means it doesn't want file names, it wants font names. I fixed that with a pango.aliases file. And I made it work inside the .app by editing the .dylib with a hex editor.

This means however, that if we want to use the free fonts shipped with Wesnoth, they have to be installed in /Library/Fonts or ~/Library/Fonts. I could hack together some Objective-C to do that (hack together because I don't really know Obj-C). But I'd prefer to use system fonts if anyone has good suggestions.

I do still have one problem though; Arabic doesn't display correctly - it does display, but the glyphs don't go together, which apparently was the main reason to switch to Pango in the first place... But at least it works. Anyway, I'm uploading a .dmg to be tested, and I'll make another post when it's up.
User avatar
anakayub
Moderator Emeritus
Posts: 526
Joined: May 3rd, 2007, 12:44 pm
Location: Malaysia
Contact:

Re: How To Compile On A Mac

Post by anakayub »

That sounds a bit...complicated, and I don't have the time to experiment until mid January.

You can install those Wesnoth fonts in the library/fonts folder if you use an installer, but since you've decided to reverse the process, I'm not sure of good font suggestions. You can try out Lucida Grande, as it's the default Mac font, or Helvetica, though I think the former is more "Mac-like".

If you post a test .dmg, I can probably test the Arabic a bit if it actually follows right to left writing, as I can read a little of it. Good luck.
Take a breath.
Locked