0

I am in the process of installing SDL 2 on Mac OSX 10.9 via macports, and for reference I have been following the official documentation as well as any sdl-specific information I can find.

https://guide.macports.org/ is straight-forward, as is:

https://guide.macports.org/#using.variants.invoking

I see that sdl2lib is available...

libsdl2 has the variants:
universal: Build for multiple architectures
x11: Enable X11 support

but despite having looked through pages at the above links and having searched for documentation for "SDL with X11", I can't seem to find information about whether I need X11 (and/or universal AKA powerpc) support. I wouldn't want to install SDL only to find that something is broken or missing. Then again, there were some issues with X11 being enabled by default back when Mac OSX 10.1 was new: https://forums.libsdl.org/viewtopic.php?t=2871&sid=52ca72a72c285196dd25fd8619715ae9

(That is another problem: much of the information I discover applies to outdated operating systems.)

Apparently SDL wasn't thread-safe at one point unless you used X11, but this was mentioned when SDL verson 1 was the main version: http://forum.freegamedev.net/viewtopic.php?f=3&t=1078

How am I meant to proceed (Which flags, if any, are usually chosen?)

port install libsdl2 <???>

I would appreciate any help and follow-up warnings for the next stepsinstallation steps. Thank you in advance.

synchronizer
  • 1,955
  • 1
  • 14
  • 37
  • 1
    `port info libsdl2` gives the variants `universal` and `x11`. You don't need X11 for an OS X `libsdl2` installation - it will use OS X / Darwin stuff for GL, mouse / keyboard events, audio, etc., which is definitely what you want. In fact `port deps libsdl2` reports no dependencies (at least for my system). You shouldn't need any extra flags with what you have. If an x86-64 build build is found by MacPorts, it will install that. Otherwise, it will build automatically from a source repo. – Brett Hale Jan 16 '17 at 08:50

1 Answers1

1

Most people have moved to Homebrew as their package system, but Macports should work just fine.

Universal does not mean PowerPC necessarily. In fact almost no one needs it anymore. Universal means a fat binary, which architectures this defines is set in your Macports configuration.

SDL2 should work just fine under Quartz, no need to have X11 - as also makes deployment annoying and difficult as you need to have XQuartz installed.

Also don't be afraid to reinstall SDL2 with other options if you miss something, it shouldn't take to long.

TL;DR Just install it without any additional flags unless you discover you need something special.

Florian Zwoch
  • 6,764
  • 2
  • 12
  • 21
  • Ah, I would have used Brew, but even the official SDL website mentions only macports. I see that brew search lists the libraries. Should I install the main library, or do I need any of the others? Where can I find instructions for getting everything running afterwards? (Do I need to move any files or configure any settings?) This person seemed to have many problems: http://stackoverflow.com/questions/18425812/add-sdl-to-my-path so the same issues might or might not exist. What do you suggest? The answer compiles everything without homebrew, which I would rather use. @Florian Zwoch – synchronizer Jan 07 '17 at 15:39
  • Depends what you need. You can get quite far with the base sdl2 library. The other ones are addon packages from sdl2 itself. If you need them solely depends on what you are trying to accomplish. Macports as well as Brew should work right out of the box. For creating compile commands you can use `sdl-config`, that one should also be available once sdl is installed. Just trust the package managers for installation. People did a good job with them to provide you with everything you need 90% of the time. – Florian Zwoch Jan 07 '17 at 16:12
  • Okay, I am trying to install with homebrew then. How do I point compilation to the installed files, which are apparently here: "./configure --prefix=/usr/local/Cellar/sdl2/2.0.5" Is it a specific flag? – synchronizer Jan 07 '17 at 16:14
  • Don't bother with that. For a simple program try something like "gcc \`sdl-config --cflags --libs\` test.c o test". The `sdl-config` figures out where things are and creates necessary flags. You can run this `sdl-config` on the command line alone too so you can see that it actually does. – Florian Zwoch Jan 07 '17 at 16:18
  • Are you sure that this is the correct instruction? gcc 'sdl2-config -g -Wall -Wextra' hello.c -o hello doesn't work. "clang: error: no such file or directory: 'sdl2-config -g -Wall -Wextra'" – synchronizer Jan 07 '17 at 16:26
  • It may be that comments stripped the backticks. The answer in your previous link shows how to use it. Could also be sdl2-config.. – Florian Zwoch Jan 07 '17 at 16:28
  • @synchronizer You have used single quotes (`'`) in place of the suggested backticks, if you can't find backticks, use `gcc $(sdl-config --cflags --libs) program.c -o program` – Mark Setchell Jan 07 '17 at 22:17
  • Mark Setchell, I realized that, thankfully. Almost everything is set and I'm already playing with basic SDL, but I am having a lot of trouble figuring how to get a working make-file. This is my current step: http://stackoverflow.com/questions/41525071/sdl-max-osx-via-homebrew-makefile-not-quite-working – synchronizer Jan 07 '17 at 22:29