Author Topic: Problems compiling lastest on Mac OS X 10.8.5  (Read 11032 times)

Offline mawaldne

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Problems compiling lastest on Mac OS X 10.8.5
« on: December 20, 2013, 06:41:30 pm »
Hey guys, I'm having some issues getting latest (git-sha ba73a7b) to compile on MacOS 10.8.5.

I ran the normal install steps through homebrew:

Code: [Select]
brew install sdl sdl_gfx sdl_mixer sdl_image yaml-cpp
cd ~/OpenXcom/src && make -f Makefile.gcc-pch -j 4

Compile initially failed because of the yaml-cpp version. It appears you can use the latest yaml-cpp version now so I didn't install 0.3 like this post suggested. After I fixed that and recompiled, I got the following at the very end:

Code: [Select]
ld: library not found for -lGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [../bin/openxcom] Error 1

I also tried to apply the OSX_kludge.patch but that failed.  I think it's out of date:

Code: [Select]
$ git apply OSX_kludge.patch
error: patch failed: src/pch.h:1
error: src/pch.h: patch does not apply

Looking at the OSX_kludge.patch there were some changes in the makefile so I'll play around with that. Otherwise anyone had this problem? Any suggestions?

Thanks
« Last Edit: December 20, 2013, 06:44:50 pm by mawaldne »

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #1 on: December 21, 2013, 05:19:48 pm »
Git builds for OSX 10.9 are auto-uploaded to

https://bitbucket.org/grrussel/openxcomosx/src

The build commands for that are essentially

export CXXFLAGS="-Wall -Wextra -O2"
export PATH=$PATH:/usr/local/bin
cd src && make -f Makefile.simple clean && make -f Makefile.simple 2>&1 | tee build_log.txt

So, it may simply be the wrong makefile ?

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #2 on: December 21, 2013, 06:07:03 pm »
Maybe someone should update the wiki as it might be out of date.

Edit: Btw grrussel, since you're an OSX user, could you help us debug these OSX issues? They've been driving us nuts since we don't have a system to test them on and can't really figure out any possible causes:
https://openxcom.org/bugs/openxcom/issues/403
https://openxcom.org/bugs/openxcom/issues/14
https://openxcom.org/bugs/openxcom/issues/202
« Last Edit: December 21, 2013, 06:10:38 pm by SupSuper »

Offline mawaldne

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #3 on: December 21, 2013, 11:02:19 pm »
Hey grrussel, thanks for the help. Using the commands above I was able to compile, but when I try to run ../bin/openxcom I'm getting a segmentation fault. Probably the same as this bug: https://openxcom.org/bugs/openxcom/issues/403

I decided to just upgrade to OSX 10.9 today since it's a free upgrade. I tried grabbing the latest compiled macosx version from https://bitbucket.org/grrussel/openxcomosx/src, but it also throws a segmentation fault on startup. Are you able to run it?  I'll try going back a few versions to see if they run.

How do I find out which git-sha the builds on openxcomosx are built from?

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #4 on: December 21, 2013, 11:30:36 pm »
I reproduced the crash of #403 with the latest build from the openxcomosx repo;

as for what git aha each build corresponds to, its at present guess work based on the relative time of the commit to git and the build appearing; the polling is probably hourly? for changes, so any build should be mappable onto a small number of revisions based on date and time

If there is a handy git command to show the info, it can be run as part of the build, and uploaded as a part of the uploaded build log.

Offline mawaldne

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #5 on: December 22, 2013, 01:11:39 am »
You could add "git rev-parse HEAD" and that will print out the current git commit then just append that to the build_log.txt.

Code: [Select]
echo "build git-sha: $(git rev-parse HEAD)" >> build_log.txt
Currently I'm just going back one build at a time to see when the seg fault started happening.  Will let you know...
« Last Edit: December 22, 2013, 01:30:06 am by mawaldne »

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #6 on: December 22, 2013, 01:50:53 am »
OK, I have found a cause of #403 (really, a workaround for the crash, not loading graphics for TFTD kneel/drain TU buttons), and cannot reproduce either #14 or #202 on OSX 10.9

I'll add git sha echoing to the jenkins job building the git builds!

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #7 on: December 22, 2013, 06:24:06 am »
Thanks for the help grrussel, I'll keep you on my pager if any more OSX issues pop up. :)

Also if you want I can add your builder to the service hooks so it gets notified whenever there's a new commit.

Offline mawaldne

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #8 on: December 22, 2013, 06:57:45 am »
Hey grussel, saw your comment here: https://openxcom.org/bugs/openxcom/issues/403

I commented out the code in XcomResourcePack.cpp and the project is compiling for me! Horay! (Probably not a final solution but I'll leave it for now. ;) )

But I'm having one more issue. When I run ./bin/openxcom I just see the following:

$ ./openxcom
basic_string

I see a "Loading . . ." window pop up, but it closes and I just see "basic_string" at the console.  Any idea?

Offline grrussel

  • Captain
  • ***
  • Posts: 72
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #9 on: December 22, 2013, 09:29:11 am »
To debug,

run openxcom in a debugger e.g. gdb or lldb

gdb ./openxcom
run
...
backtrace

to show where the crash occurs; no idea what the cause is, it works for me (tm)

May also be worth doing
    make -f Makefile.simple clean
before rebuilding, to not mix and match .o files between old and new OSX versions

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #10 on: December 22, 2013, 05:54:23 pm »
OK, I have found a cause of #403 (really, a workaround for the crash, not loading graphics for TFTD kneel/drain TU buttons), and cannot reproduce either #14 or #202 on OSX 10.9

I'll add git sha echoing to the jenkins job building the git builds!
Ok I have worked around the crash. This doesn't fix the issue, but at least it'll keep OpenXcom from immediately crashing about it. :P

It seems OSX SDL_image doesn't support 8-bit PNGs, which causes some weird behavior. The only workaround is to compile it yourself with a define set so it doesn't use CoreImage. If you wanna look into it, here's an explanation: https://sdl.5483.n7.nabble.com/PNG-with-8bit-colormap-loaded-as-full-32-bits-per-pixel-td19998.html

Offline mawaldne

  • Squaddie
  • *
  • Posts: 5
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #11 on: December 22, 2013, 08:36:41 pm »
grrussel, Thanks again.  I found my problem. I'm able to compile and run openxcom latest.

To anyone looking at this later, make sure you turn on debugging and compile with -g so gdb is more meaningful. It'll help to find problems:

Code: [Select]
export CXXFLAGS="-Wall -Wextra -O2 -g -D_DEBUG"
My problem was my locale wasn't set. getLocale() in CrossPlatform.cpp was trying to parse an empty string and it was throwing an exception. I set my locale in my terminal, and also set the language in the options.cfg and things are fine now.



Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: Problems compiling lastest on Mac OS X 10.8.5
« Reply #12 on: December 23, 2013, 03:15:22 am »
grrussel, Thanks again.  I found my problem. I'm able to compile and run openxcom latest.

To anyone looking at this later, make sure you turn on debugging and compile with -g so gdb is more meaningful. It'll help to find problems:

Code: [Select]
export CXXFLAGS="-Wall -Wextra -O2 -g -D_DEBUG"
My problem was my locale wasn't set. getLocale() in CrossPlatform.cpp was trying to parse an empty string and it was throwing an exception. I set my locale in my terminal, and also set the language in the options.cfg and things are fine now.
Nice catch, it's fixed now. :)