The Ur-Quan Masters Discussion Forum

The Ur-Quan Masters Re-Release => Technical Issues => Topic started by: Kanhef on August 17, 2018, 12:19:12 am



Title: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 17, 2018, 12:19:12 am
So, I'm trying to build from source after making a few changes, and I've run into a familiar-looking error or two. When running
./build.sh uqm config
it gives me
fatal error: "SDL/SDL_version.h" file not found
Also, Rez is not found.

As per the installation instructions included with source, SDL and SDL_image have been placed in /Library/Frameworks. Instructions say SDL-devel is optional, so it is not installed. I've tried using CFLAGS to include the SDL headers directory, but it has no effect on the output.

Having read through much of this forum, I see that a number of people have had similar issues over the years, and a few even seem to have resolved them, but it is unclear how. This post (http://forum.uqm.stack.nl/index.php?topic=5353.0) seems to reference the issues I'm having, but doesn't say how to fix them. Detailed instructions on how to get everything where the build script can find it would be much appreciated. I'd prefer to not have to install fink/macports/etc just for this one thing, but can if it's the only way to make it work.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Serosis on August 17, 2018, 01:28:26 am
Which version of the source are you compiling from?

I know first hand building in macOS can be a pain so I'll do my best to help.

EDIT:

I checked out the most recent version of the source code and it does behave better in macOS than before but it still loves to give off the SDL.H is not found error.
Resulting in an uncountable amount of compiler errors.

EDIT:

I'm going to create a quick fix you can drop into the source code that will get you to be able to compile without any hitches, hopefully. But it's going to take me a minute.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 17, 2018, 02:32:37 am
UQM 0.7.0-1

Also, which version of SDL and SDL-image should be used? http://sc2.sourceforge.net/downloads.php says SDL-image 1.2.10, but INSTALL.macosx says there are issues with anything after SDL-image 1.2.7 .

Thanks!


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Serosis on August 17, 2018, 02:54:15 am
Unzip and move the two resulting files to the sc2/build/unix directory: http://files.serosis.net/Misc/macOS-Fix.zip

That should get you to build on High Sierra for the time being until the code is properly fixed.

Use the latest SDL and SDL_Image that you can, which would be 1.2.15 and 1.2.12 respectively.
Anything lower I believe does not work on macOS anymore.

(https://i.imgur.com/nTD6zA0b.jpg) (https://i.imgur.com/nTD6zA0.jpg)


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 17, 2018, 05:57:58 am
Well, it gets through config now, after some tweaking. In config_proginfo_host:
LIB_SDL_LDFLAGS='-F/Library/Frameworks -framework SDL -framework Cocoa -lobjc'

Preprocessor is throwing a fit with "unterminated conditional directive" errors. Noticed that I have a somewhat older version of Xcode installed, updating it to see if that fixes things.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Serosis on August 17, 2018, 06:07:38 am
I simply used the command line tools without Xcode.

Maybe that's the problem.

Since you're using full-blown Xcode pop open your config_proginfo_build, search for PROG_Rez_NAME="Rez resource compiler (Apple Developer Tools)"
Right below that there's a line that says PROG_Rez_FILE="Rez", change that to say PROG_Rez_FILE="/usr/bin/Rez".


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 18, 2018, 03:05:24 am
So, somehow a newline got deleted from src/libs/compiler.h, putting a #endif on the same line as a #define. No wonder the preprocessor had issues.

Adapted your fix to set LIB_SDL_image_CFLAGS and LDFLAGS. A few warnings, most of which look relatively inconsequential (though the array bounds violation in src/libs/input/sdl/vcontrol.c:1266 might cause issues). Only error is that it's trying to compile Ogg Vorbis support, even though that's supposed to be optional and it's configured not to use Ogg. Ah well, not the worst thing to have to deal with.

Edit: A bit less straightforward than I expected. Building Ogg/Vorbis only seems to produce x86-64 code, but UQM needs a i386 library to link to. Can't seem to find a precompiled framework, except for one that's meant for iOS. Even with that, linking fails:
Undefined symbols for architecture i386:
  "_IMG_Load_RW", referenced from:
      _sdluio_loadImage in sdluio.c.o

There are a bunch more similar errors if I configure it to not use Ogg, all from oggaud.c


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: CelticMinstrel on August 21, 2018, 05:10:22 am
That missing symbol is from SDL_Image - do you have that installed?


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 21, 2018, 07:39:24 am
Yeah, it compiles to object code just fine, so it's finding the SDL image header files, but it seems like it can't find the shared library when it goes to link everything. The build script is fairly convoluted, so I'm having trouble understanding what exactly is going on at this step, and why it doesn't work right.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Serosis on August 21, 2018, 07:48:28 am
Are you using the latest SDL & SDL_Image or what the Install file recommends?
Because the older versions of SDL absolutely do not behave with High Sierra at all.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 21, 2018, 01:25:27 pm
SDL 1.2.15, SDL-image 1.2.12


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Serosis on August 21, 2018, 02:10:54 pm
Try this for me.

Get a fresh copy of the source, slap those two edited files I uploaded for you into it and see if it compiles.
It definitely should compile with a few warnings.

Another option to try is to clear the frameworks you downloaded by instruction from the Install file and instead pull them straight out of the official macOS release: https://sourceforge.net/projects/sc2/files/UQM/0.7/uqm-0.7.0-1-macosx.dmg/download

That way you know you are using the frameworks that were actually used to build it.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 22, 2018, 12:27:59 am
Fresh copy of source plus Sarosis' config files.

Config fails: Simple DirectMedia Layer not found.

Add '-F/Library/Frameworks' to LIB_SDL_LDFLAGS in config_proginfo_host. Get errors about 'SDL/SDL.h' not found.

Okay, the full path to SDL.h is /Library/Frameworks/SDL.framework/Versions/Current/Headers/SDL.h, not contained in an SDL directory. 'cd /Library/Frameworks/SDL.framework/Headers ; ln -s . SDL' makes a symlink so the path will resolve.

No more SDL.h errors, but can't find 'SDL_image/SDL_image.h'.
LIB_SDL_image_CFLAGS='-I/Library/Frameworks/SDL_image.framework/Headers'
LIB_SDL_image_LDFLAGS='-F/Library/Frameworks -framework SDL_image'

And the same symlink trick.

Compiles and links. Okay, pull out FileMerge to figure out what's different.

Derp.

Lib_SDL_image_LDFLAGS="-F/Library/Frameworks -framework SDL

Copy-and-paste without double-checking got me. Working 50-60 hour weeks probably hasn't been helping either.

Try to install, can't find SDL/SDL.h and SDL_image/SDL_image.h again. Looking at build.config, it's trying to copy frameworks into the app, but nothing in the command to locate them is telling it to look in /Library/Frameworks, rather than the standard include directories.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: CelticMinstrel on August 22, 2018, 02:46:37 pm
Rather than

Code:
LIB_SDL_image_CFLAGS='-I/Library/Frameworks/SDL_image.framework/Headers'

I believe you're supposed to use

Code:
LIB_SDL_image_CFLAGS='-framework SDL_image'


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 22, 2018, 11:38:04 pm
Compiling process is working; it doesn't find the frameworks without using -I. Current hangup is in this part of build.config:
   # Find Frameworks and copy them into the application.
   echo "Copying dependancy Frameworks..." >&2
   HEADERS="ogg/ogg.h SDL.h SDL_image.h vorbis/vorbisfile.h"
   if [ "$uqm_SOUNDMODULE" = openal ]; then
      HEADERS="$HEADERS OpenAL/al.h"
   fi
   for HEADER in $HEADERS; do
      HEADER_FILE=`basename $HEADER`
      eval FRAMEWORK=`echo '' | \
            $PREPROC_C -D__MACOSX__ -include $HEADER - | \
            awk '(/'$HEADER_FILE'/ && $2 == 1) { print $3; exit }' | \
            $SED 's/.Headers.*$/"/'`
      cp -r "$FRAMEWORK" "$INSTROOT/Frameworks"
   done

It's checking standard include directories, but not /Library/Frameworks/ .


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: CelticMinstrel on August 23, 2018, 05:22:00 am
To add a framework search directory, try:
Code:
-F/Library/Frameworks/

Like -framework, it probably needs to be in both LDFLAGS and CFLAGS.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 25, 2018, 02:05:22 am
So I finally managed to get the install to function by bypassing the framework-finding code and just hardcoding the locations of the frameworks into the script. Then had to fix some of the framework directory structures. App opens, but I get an unresponsive black window. Console is filled with
CGBitmapContextInfoCreate: CGColorSpace does't support output
CGContextDrawImage: invalid context 0x0.


At this point, it feels like it would be easier to set up a Linux or Windows VM and do everything there.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Serosis on August 25, 2018, 10:12:22 am
If you don't mind my asking but what exactly are you going for?

Also, as another test, try out the UQM-MegaMod and see if that compiles and installs for you: https://github.com/Serosis/UQM-MegaMod

I did a lot of work on it to get it to compile in OS X cleanly so you could possibly port the changes into Vanilla UQM.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Kanhef on August 28, 2018, 12:40:12 am
Getting some of the same problems when trying to compile MegaMod 0.8.0 rev7; not sure if it's my computer in particular or 10.13 in general.

Hadn't really looked at MegaMod before, but it seems to include most of the changes I was trying to make, so I suppose I don't really need to build from source at this point. There's one new feature I'd like to see, but I'll request that in the appropriate thread.


Title: Re: Problems compiling on Mac OS 10.13.3
Post by: Death 999 on March 06, 2019, 11:48:23 pm
I wonder what it would take to apply your mac-building magic to the balance mod. I'd like to actually be able to try that out some time…

Well, I have windows machines available. But it'd still be nice.