FS#1386 - Mac OS X 10.5 Nightly cocoa_s.cpp failure.

Attached to Project: OpenTTD
Opened by Bantam (Bantam) - Thursday, 01 November 2007, 17:09 GMT
Last edited by Remko Bijker (Rubidium) - Saturday, 10 November 2007, 23:18 GMT
Type Bug
Category Core
Status Closed
Assigned To Bjarni (Bjarni)
Operating System Mac OS X
Severity High
Priority Normal
Reported Version trunk
Due in Version 0.6.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


After recently upgrading to the new Mac OS X 10.5 I can no longer successfully build openttd, Revision 11368 fails to build:

[SRC] Compiling sound/cocoa_s.cpp
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp: In member function ‘virtual const char* SoundDriver_Cocoa::Start(const char* const*)’:
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp:46: error: aggregate ‘AudioUnitInputCallback callback’ has incomplete type and cannot be defined
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp:68: error: ‘kAudioUnitComponentType’ was not declared in this scope
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp:69: error: ‘kAudioUnitSubType_Output’ was not declared in this scope
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp:70: error: ‘kAudioUnitID_DefaultOutput’ was not declared in this scope
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp:96: error: ‘kAudioUnitProperty_SetInputCallback’ was not declared in this scope
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp: In member function ‘virtual void SoundDriver_Cocoa::Stop()’:
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp:112: error: aggregate ‘AudioUnitInputCallback callback’ has incomplete type and cannot be defined
/Users/chris/desktop/openttd/src/sound/cocoa_s.cpp:123: error: ‘kAudioUnitProperty_SetInputCallback’ was not declared in this scope
make[1]: *** [sound/cocoa_s.o] Error 1
make: *** [all] Error 2
This task depends upon

This task blocks these from closing
 FS#1385 - Nightly Builds won't start on Mac OS X 10.5 
Closed by  Bjarni (Bjarni)
Thursday, 27 December 2007, 15:06 GMT
Reason for closing:  Fixed
Additional comments about closing:  r11709
Now it should work after running configure again. If not then request this task reopened.
Comment by Emil Djupfeldt (egladil) - Saturday, 03 November 2007, 10:05 GMT
This might fix the issue. It works on Tiger, but I don't have access to Leopard so I can't test it there too.
Comment by Bantam (Bantam) - Saturday, 03 November 2007, 10:20 GMT
I can confirm this fixes cocoa_s.cpp compile issues, however there are more issues with building on leopard after that fix. I would guess a developer needs to build on 10.5

[SRC] Compiling music/qtmidi.cpp
/Users/chris/desktop/openttd/src/music/qtmidi.cpp: In function ‘void SetMIDITypeIfNeeded(const FSSpec*)’:
/Users/chris/desktop/openttd/src/music/qtmidi.cpp:92: warning: ‘FSpMakeFSRef’ is deprecated (declared at /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h:7477)
/Users/chris/desktop/openttd/src/music/qtmidi.cpp:92: warning: ‘FSpMakeFSRef’ is deprecated (declared at /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Files.h:7477)

[SRC] Compiling unix.cpp
/Users/chris/desktop/openttd/src/unix.cpp: In function ‘const char* convert_tofrom_fs(void*, const char*)’:
/Users/chris/desktop/openttd/src/unix.cpp:246: error: invalid conversion from ‘const char**’ to ‘char**’
/Users/chris/desktop/openttd/src/unix.cpp:246: error: initializing argument 2 of ‘size_t iconv(void*, char**, size_t*, char**, size_t*)’
make[1]: *** [unix.o] Error 1
make: *** [all] Error 2

Comment by Emil Djupfeldt (egladil) - Monday, 05 November 2007, 23:10 GMT
This should fix those errors, please let me know how it works.
Comment by Bantam (Bantam) - Tuesday, 06 November 2007, 01:53 GMT
After a lot of wresting and consulting the apple community it would appear that X11 shipped with leopard is very broken, after applying some of the fixes there were missing X11 files that prevented the linking openttd stage from completing. After listening to some advice I uninstalled X11 and installed the Tiger X11 from my old disc, that seems to have fixed most of the problems. I am able to compile and run again.

I did have some errors remaining but It doesn't stop me from running nightly anymore.

[SRC] Compiling os/macosx/
/Users/chris/desktop/openttd/src/os/macosx/ In function ‘const char* GetCurrentLocale(const char*)’:
/Users/chris/desktop/openttd/src/os/macosx/ warning: ‘cString’ is deprecated (declared at /System/Library/Frameworks/Foundation.framework/Headers/NSString.h:345)

chris$ ./bin/openttd
2007-11-06 09:51:58.090 openttd[29941:10b] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
Comment by Emil Djupfeldt (egladil) - Tuesday, 06 November 2007, 17:46 GMT
So the patch compiles alright, except that you get linking errors at the end when using X11 from Leopard? What were those errors?
Did it warn about NSQuickDrawView during compilation?

Could you attach a complete build log and a copy of your config.log, if possible from when compiling with the broken X11?
Comment by Bantam (Bantam) - Tuesday, 06 November 2007, 20:27 GMT
I'll get back to you with a clean leopard compile when I update my macbook pro to leopard as well. Linking openttd was prevented by broken references to libpng.a and libfreetype.a, despite both libraries being installed.

I tried compiling on the unpatched source with both tiger and leopard X11 and neither will work, the patch gets it working though on tiger X11. There were no previous warnings about QuickDraw, only when running openttd.
Comment by Emil Djupfeldt (egladil) - Wednesday, 07 November 2007, 22:51 GMT
I've committed the fixes I've done so far. However, part of the problem lies in Apple shipping a broken X11 with Leopard and the solutions available for that is:
* Wait for Apple to fix X11 on Leopard.
* Use the old Tiger X11.
* Use darwinports or some similar project to get the libraries needed.
The proper solution would be the first one, but in the meantime one of the other should make do.

The warning about NSQuickDrawView will be addressed in  FS#1411 .
Comment by Bantam (Bantam) - Thursday, 08 November 2007, 02:19 GMT
One of the fixes in the latest version seems to be missing:

Latest revision on clean leopard with leopard X11

Updated to revision 11391.
Noob-Computer:openttd chris$ ./configure
checking awk... awk
checking build system type... i686-apple-darwin9
checking host system type... i686-apple-darwin9
detecting OS... OSX
checking universal build... no
checking build cc... gcc
checking host cc... gcc
checking build c++... g++
checking host c++... g++
checking host strip... strip
checking makedepend... makedepend
detecting cpu-type... 32 bits
checking static... yes
checking unicode... no
using debug level... no
checking SDL... OSX, skipping
checking COCOA... found
checking GDI video driver... not Windows, skipping
checking dedicated... not selected
checking network... found
checking translator... no
checking assert... enabled
checking zlib... found
checking libpng... found
checking libfreetype... found
checking libfontconfig... not found
checking iconv... found
checking if iconv has non-const inbuf... yes
checking psp-config... not PSP, skipping
checking libtimidity... not found
checking direct-music... not Windows, skipping
checking sort... sort
checking endianess... PREPROCESSOR
suppress language errors... no
checking stripping... strip
checking distcc... no (only used when forced)
checking ccache... no (only used when forced)
checking OSX sysroot... no (use system default)
madetecting G5... no
checking revision... svn detection
personal home directory... Documents/OpenTTD
installation directory... /
ke using CFLAGS... -O3 -funroll-loops -fsched-interblock -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-jumps-max-skip=15 -falign-loops-max-skip=15 -mdynamic-no-pic -DOSX -Wall -Wno-multichar -Wsign-compare -Wundef -Wwrite-strings -Wpointer-arith -Wno-uninitialized -W -Wno-unused-parameter -fno-strict-aliasing -DUNIX -DWITH_COCOA -DWITH_ZLIB -DWITH_PNG -I/opt/local/include/libpng12 -DWITH_FREETYPE -I/opt/local/include/freetype2 -I/opt/local/include -DWITH_ICONV -DHAVE_BROKEN_ICONV -DHAVE_BROKEN_ICONV -DHAVE_BROKEN_ICONV -DENABLE_NETWORK -DWITH_PERSONAL_DIR -DPERSONAL_DIR="Documents/OpenTTD" -DGLOBAL_DATA_DIR="/usr/local/share/games/openttd" -Wstrict-prototypes -Wdeclaration-after-statement -Wold-style-definition
using LDFLAGS... -lstdc++ -lc -framework QuickTime -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit -lz /opt/local/lib/libpng.a /opt/local/lib/libfreetype.a -liconv -framework Cocoa
Generating Makefile...
cGenerating lang/Makefile...
Generating objs/Makefile...
Noob-Computer:openttd chris$ make clean
[LANG] Cleaning up language files
[SRC] Cleaning up object files
Noob-Computer:openttd chris$ make
[LANG] Compiling and Linking endian_check
[LANG] Testing endianness for host
[LANG] Compiling string.cpp
[LANG] Compiling strgen/strgen.cpp
[LANG] Compiling and Linking strgen
[LANG] Generating table/strings.h
[LANG] Compiling language afrikaans
[LANG] Compiling language american
[LANG] Compiling language brazilian_portuguese
[LANG] Compiling language bulgarian
[LANG] Compiling language catalan
[LANG] Compiling language croatian
[LANG] Compiling language czech
[LANG] Compiling language danish
[LANG] Compiling language dutch
[LANG] Compiling language english
[LANG] Compiling language esperanto
[LANG] Compiling language estonian
[LANG] Compiling language finnish
[LANG] Compiling language french
[LANG] Compiling language galician
[LANG] Compiling language german
[LANG] Compiling language hungarian
[LANG] Compiling language icelandic
[LANG] Compiling language italian
[LANG] Compiling language japanese
[LANG] Compiling language korean
[LANG] Compiling language lithuanian
[LANG] Compiling language norwegian_bokmal
[LANG] Compiling language norwegian_nynorsk
[LANG] Compiling language origveh
[LANG] Compiling language piglatin
[LANG] Compiling language polish
[LANG] Compiling language portuguese
[LANG] Compiling language romanian
[LANG] Compiling language russian
[LANG] Compiling language simplified_chinese
[LANG] Compiling language slovak
[LANG] Compiling language slovenian
[LANG] Compiling language spanish
[LANG] Compiling language swedish
[LANG] Compiling language traditional_chinese
[LANG] Compiling language turkish
[LANG] Compiling language ukrainian
[SRC] Compiling and Linking endian_check
[SRC] Testing endianness for target
[SRC] DEP CHECK (all files)
[SRC] Compiling ai/ai.cpp
[SRC] Compiling ai/default/default.cpp
[SRC] Compiling ai/trolly/build.cpp
[SRC] Compiling ai/trolly/pathfinder.cpp
[SRC] Compiling ai/trolly/shared.cpp
[SRC] Compiling ai/trolly/trolly.cpp
[SRC] Compiling aircraft_cmd.cpp
[SRC] Compiling aircraft_gui.cpp
[SRC] Compiling airport.cpp
[SRC] Compiling airport_gui.cpp
[SRC] Compiling articulated_vehicles.cpp
[SRC] Compiling autoreplace_cmd.cpp
[SRC] Compiling autoreplace_gui.cpp
[SRC] Compiling aystar.cpp
[SRC] Compiling blitter/32bpp_anim.cpp
[SRC] Compiling blitter/32bpp_base.cpp
[SRC] Compiling blitter/32bpp_optimized.cpp
[SRC] Compiling blitter/32bpp_simple.cpp
[SRC] Compiling blitter/8bpp_base.cpp
[SRC] Compiling blitter/8bpp_debug.cpp
[SRC] Compiling blitter/8bpp_optimized.cpp
[SRC] Compiling blitter/8bpp_simple.cpp
[SRC] Compiling blitter/null.cpp
[SRC] Compiling bmp.cpp
[SRC] Compiling bridge_gui.cpp
[SRC] Compiling bridge_map.cpp
[SRC] Compiling build_vehicle_gui.cpp
[SRC] Compiling callback_table.cpp
[SRC] Compiling cargopacket.cpp
[SRC] Compiling cargotype.cpp
[SRC] Compiling clear_cmd.cpp
[SRC] Compiling command.cpp
[SRC] Compiling console.cpp
[SRC] Compiling console_cmds.cpp
[SRC] Compiling currency.cpp
[SRC] Compiling date.cpp
[SRC] Compiling debug.cpp
[SRC] Compiling dedicated.cpp
[SRC] Compiling depot.cpp
[SRC] Compiling depot_gui.cpp
[SRC] Compiling disaster_cmd.cpp
[SRC] Compiling dock_gui.cpp
[SRC] Compiling driver.cpp
[SRC] Compiling dummy_land.cpp
[SRC] Compiling economy.cpp
[SRC] Compiling elrail.cpp
[SRC] Compiling engine.cpp
[SRC] Compiling engine_gui.cpp
[SRC] Compiling fileio.cpp
[SRC] Compiling fios.cpp
[SRC] Compiling fontcache.cpp
[SRC] Compiling genworld.cpp
[SRC] Compiling genworld_gui.cpp
[SRC] Compiling gfx.cpp
[SRC] Compiling gfxinit.cpp
[SRC] Compiling graph_gui.cpp
[SRC] Compiling group_cmd.cpp
[SRC] Compiling group_gui.cpp
[SRC] Compiling heightmap.cpp
[SRC] Compiling helpers.cpp
[SRC] Compiling industry_cmd.cpp
[SRC] Compiling industry_gui.cpp
[SRC] Compiling intro_gui.cpp
[SRC] Compiling landscape.cpp
[SRC] Compiling main_gui.cpp
[SRC] Compiling map.cpp
[SRC] Compiling md5.cpp
[SRC] Compiling mersenne.cpp
[SRC] Compiling minilzo.cpp
[SRC] Compiling misc.cpp
[SRC] Compiling misc/dbg_helpers.cpp
[SRC] Compiling misc_cmd.cpp
[SRC] Compiling misc_gui.cpp
[SRC] Compiling mixer.cpp
[SRC] Compiling music.cpp
[SRC] Compiling music/extmidi.cpp
[SRC] Compiling music/null_m.cpp
[SRC] Compiling music/qtmidi.cpp
[SRC] Compiling music_gui.cpp
[SRC] Compiling namegen.cpp
[SRC] Compiling network/core/core.cpp
[SRC] Compiling network/core/packet.cpp
[SRC] Compiling network/core/tcp.cpp
[SRC] Compiling network/core/udp.cpp
[SRC] Compiling network/network.cpp
[SRC] Compiling network/network_client.cpp
[SRC] Compiling network/network_data.cpp
[SRC] Compiling network/network_gamelist.cpp
[SRC] Compiling network/network_gui.cpp
[SRC] Compiling network/network_server.cpp
[SRC] Compiling network/network_udp.cpp
[SRC] Compiling newgrf.cpp
[SRC] Compiling newgrf_canal.cpp
[SRC] Compiling newgrf_cargo.cpp
[SRC] Compiling newgrf_commons.cpp
[SRC] Compiling newgrf_config.cpp
[SRC] Compiling newgrf_engine.cpp
[SRC] Compiling newgrf_gui.cpp
[SRC] Compiling newgrf_house.cpp
[SRC] Compiling newgrf_industries.cpp
[SRC] Compiling newgrf_industrytiles.cpp
[SRC] Compiling newgrf_sound.cpp
[SRC] Compiling newgrf_spritegroup.cpp
[SRC] Compiling newgrf_station.cpp
[SRC] Compiling newgrf_storage.cpp
[SRC] Compiling newgrf_text.cpp
[SRC] Compiling newgrf_town.cpp
[SRC] Compiling newgrf_townname.cpp
[SRC] Compiling news_gui.cpp
[SRC] Compiling npf.cpp
[SRC] Compiling oldloader.cpp
[SRC] Compiling oldpool.cpp
[SRC] Compiling openttd.cpp
[SRC] Compiling order_cmd.cpp
[SRC] Compiling order_gui.cpp
[SRC] Compiling os/macosx/splash.cpp
[SRC] Compiling os_timer.cpp
[SRC] Compiling pathfind.cpp
[SRC] Compiling player_gui.cpp
[SRC] Compiling players.cpp
[SRC] Compiling queue.cpp
[SRC] Compiling rail.cpp
[SRC] Compiling rail_cmd.cpp
[SRC] Compiling rail_gui.cpp
[SRC] Compiling rev.cpp
[SRC] Compiling road.cpp
[SRC] Compiling road_cmd.cpp
[SRC] Compiling road_gui.cpp
[SRC] Compiling road_map.cpp
[SRC] Compiling roadveh_cmd.cpp
[SRC] Compiling roadveh_gui.cpp
[SRC] Compiling saveload.cpp
[SRC] Compiling screenshot.cpp
[SRC] Compiling settings.cpp
[SRC] Compiling settings_gui.cpp
[SRC] Compiling ship_cmd.cpp
[SRC] Compiling ship_gui.cpp
[SRC] Compiling signs.cpp
[SRC] Compiling signs_gui.cpp
[SRC] Compiling smallmap_gui.cpp
[SRC] Compiling sound.cpp
[SRC] Compiling sound/cocoa_s.cpp
[SRC] Compiling sound/null_s.cpp
[SRC] Compiling spritecache.cpp
[SRC] Compiling spriteloader/grf.cpp
[SRC] Compiling spriteloader/png.cpp
[SRC] Compiling station.cpp
[SRC] Compiling station_cmd.cpp
[SRC] Compiling station_gui.cpp
[SRC] Compiling string.cpp
[SRC] Compiling strings.cpp
[SRC] Compiling subsidy_gui.cpp
[SRC] Compiling terraform_gui.cpp
[SRC] Compiling texteff.cpp
[SRC] Compiling tgp.cpp
[SRC] Compiling thread.cpp
[SRC] Compiling tile.cpp
[SRC] Compiling timetable_cmd.cpp
[SRC] Compiling timetable_gui.cpp
[SRC] Compiling town_cmd.cpp
[SRC] Compiling town_gui.cpp
[SRC] Compiling train_cmd.cpp
[SRC] Compiling train_gui.cpp
[SRC] Compiling transparency_gui.cpp
[SRC] Compiling tree_cmd.cpp
[SRC] Compiling tunnel_map.cpp
[SRC] Compiling tunnelbridge_cmd.cpp
[SRC] Compiling unix.cpp
/Users/chris/Desktop/openttd/src/unix.cpp: In function ‘const char* convert_tofrom_fs(void*, const char*)’:
/Users/chris/Desktop/openttd/src/unix.cpp:246: error: invalid conversion from ‘char**’ to ‘const char**’
/Users/chris/Desktop/openttd/src/unix.cpp:246: error: initializing argument 2 of ‘size_t libiconv(void*, const char**, size_t*, char**, size_t*)’
make[1]: *** [unix.o] Error 1
make: *** [all] Error 2
Noob-Computer:openttd chris$
Comment by Emil Djupfeldt (egladil) - Thursday, 08 November 2007, 21:36 GMT
The commit was the same as the leopard_fixes.diff I posted earlier with the addition of one more unrelated fix, so none of the fixes are missing. But from reading your configure log and build log, there seem to be an issue with the testing for the broken iconv declaration.

Could you rerun configure after applying the patch I attached here, and then post a copy of your config.log (not just the output from configure, but the actual log file)?
Comment by Bantam (Bantam) - Thursday, 08 November 2007, 22:05 GMT
Hope this helps!
Comment by Bantam (Bantam) - Friday, 09 November 2007, 02:56 GMT
I fixed the iconv problem by reinstalling fink, i then installed libpng and freetype, I came up with this message:

[SRC] Linking openttd
i686-apple-darwin9-g++-4.0.1: /usr/X11/lib/libfontconfig.a: No such file or directory
i686-apple-darwin9-g++-4.0.1: /usr/X11/lib/libfreetype.a: No such file or directory
make[1]: *** [openttd] Error 1
make: *** [all] Error 2

freetype is installed, however it's looking for the wrong file I guess, this may be fink's problem though, they aren't fully 10.5 compatible yet.

I tried fixing it in a roundabout way, using tigers X11 libfreetype files

sudo cp /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/libfreetype.a /usr/X11/lib/libfreetype.a
sudo cp /Developer/SDKs/MacOSX10.4u.sdk/usr/X11R6/lib/libfontconfig.a /usr/X11/lib/libfontconfig.a

[SRC] Linking openttd
Undefined symbols:
"_FcFini", referenced from:
LoadFreeTypeFont(char const*, FT_FaceRec_**, char const*)in fontcache.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [openttd] Error 1
make: *** [all] Error 2

Obviously that's not gonna work. It comes very close to compiling with Leopard X11 now, works fine with Tiger X11, here's my config.log from this attempt.
Comment by Bantam (Bantam) - Saturday, 10 November 2007, 03:00 GMT
I have a solution to the leopard install problem. I removed fink and use macports ( package system instead. I then ran:

sudo port install freetype libpng fontconfig

After that openttd would compile as normal, I hope this helps any other leopard users having the same problems as me.
Comment by slafs (slafs) - Sunday, 11 November 2007, 19:42 GMT
I've installed freetype, libpng and fontconfig with macports as Chris Hutchinson described.
However, major problem in configure:

% ./configure --enable-static
checking revision... no detection
WARNING: there is no means to determine the version.
WARNING: please use a subversion or git checkout of OpenTTD.
WARNING: this version is only allowed by game servers that
WARNING: have been compiled without version detection.
WARNING: there is a great chance you desync.

I tried compiling with --revision=11413, but I get "version mismatch" when trying to join network games.
Comment by Bjarni (Bjarni) - Friday, 16 November 2007, 17:52 GMT
Try to use "--disable-static" instead of enabling it as the problem appears to be the fact that Apple included dynamic libs only in Leopard.