cesss
cesss

Reputation: 893

X11 headers not in El Capitan 10.11 SDK?

In OSX versions prior to Lion, I built X11 applications with the /usr/X11 path. It worked fine in Tiger and Snow Leopard.

After Lion, and because of a reason I no longer remember (I believe it was related to avoiding header mismatches from different SDK versions), I changed this approach and compiled all X11 apps avoiding /usr at all and using instead this: -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.x.sdk (where the 'x' in 'MacOSX10.x.sdk' was the SDK version being used). This approach for building X11 apps has worked fine for me in Mountain Lion and Yosemite.

However, now I updated my system to El Capitan, and X11 applications configure scripts cannot find X11 anymore with -isysroot.

See, this is what I'm getting now with El Capitan, doing exactly the same that worked fine in Mountain Lion and Yosemite:

creating cache ./config.cache
checking whether to enable maintainer-specific portions of Makefiles... no
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal-1.4... missing
checking for working autoconf... missing
checking for working automake-1.4... missing
checking for working autoheader... missing
checking for working makeinfo... found
checking for gcc... gcc
checking whether the C compiler (gcc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.11 -L/usr/X11R6/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.11) works... yes
checking whether the C compiler (gcc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.11 -L/usr/X11R6/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.11) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ANSI C... none needed
checking for Cygwin environment... no
checking for mingw32 environment... no
checking host system type... i386-apple-darwin15.0.0
checking build system type... i386-apple-darwin15.0.0
checking for ld used by GCC... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm
checking for a sed that does not truncate output... /usr/bin/sed
checking whether ln -s works... yes
checking how to recognise dependent libraries... file_magic Mach-O dynamically linked shared library
checking for object suffix... o
checking for executable suffix... no
checking command to parse /usr/bin/nm output... ok
checking for dlfcn.h... yes
checking for ranlib... ranlib
checking for strip... strip
checking for objdir... .libs
checking for gcc option to produce PIC... -fno-common
checking if gcc PIC flag -fno-common works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.lo... yes
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking whether the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking how to hardcode library paths into programs... unsupported
checking whether stripping libraries is possible... no
checking dynamic linker characteristics... darwin15.0.0 dyld
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
creating libtool
checking for executable suffix... (cached) no
checking for byacc... no
checking for flex... flex
checking for flex... (cached) flex
checking for yywrap in -lfl... no
checking lex output file root... lex.yy
checking whether yytext is a pointer... no
checking for a BSD compatible install... /usr/bin/install -c
checking whether ln -s works... (cached) yes
checking whether make sets ${MAKE}... (cached) yes
checking for X... no

I see however that /usr/X11 exists in my system (it's actually a link to /opt/X11 because El Capitan disallows /usr for non-Apple users, but /opt/X11 is correctly there, with all the X11 headers and libs).

Does this mean that X11 applications cannot be built with -isysroot anymore? Do I need to build them with the system root include path (which exists in /usr/include, BTW) ? (my system even has /usr/include/stdio.h and all standard headers, I've no idea why, because I believed all headers had been moved to the SDKs).

If affirmative, I don't feel confident with including from /usr/include instead of from the SDK include path... it makes me feel fear of SDK mismatches...

Thanks!!

Upvotes: 1

Views: 1637

Answers (1)

cesss
cesss

Reputation: 893

Not sure if this solution is correct from an SDK-correctness perspective, but in 10.11 El Capitan it seems setting '-isysroot' is no longer enough for compiling X11 applications.

So, trying to use headers only from the SDK, and complementing them with X11 headers only (so the only "outsiders" are the X11 headers), I found that this solution works:

Options for the compile line: -I/opt/X11/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

Options for the link line: -L/opt/X11/lib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

As I said, I don't know if this is the correct way of doing it, but it (seems to) work. I'm using XQuartz 2.7.7, which is the latest release at the time of writing this.

Upvotes: 1

Related Questions