Skip to content

Conversation

@sanssecours
Copy link
Contributor

👋 Hi,

this pull request adds Apple Silicon support to the Makefile for universal Mac builds. If I should change anything in the pull request, then please just comment below. Thank you.


BTW: Is there an easy way to only install the static version of the library? I was able to build the static version of GLEW with:

make -C auto
export MACOSX_DEPLOYMENT_TARGET=10.9 GLEW_DEST=/usr/local
make SYSTEM=darwin-universal glew.lib.static

However, installing the library with:

sudo make install

failed with the following error message on my machine:

install -d -m 0755 "/usr/local/include/GL"
install -m 0644 include/GL/wglew.h "/usr/local/include/GL/"
install -m 0644 include/GL/glew.h "/usr/local/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/local/include/GL/"
install -m 0644 include/GL/eglew.h "/usr/local/include/GL/"
cc -DGLEW_NO_GLU -DGLEW_BUILD -Os -Wall -W -Iinclude -dynamic -fno-common -pedantic -fPIC -std=c89  -o tmp/darwin/default/shared/glew.o -c src/glew.c
cc -dynamiclib -install_name /usr/local/lib/libGLEW.2.2.0.dylib -current_version 2.2.0 -compatibility_version 2.2 -o lib/libGLEW.2.2.0.dylib tmp/darwin/default/shared/glew.o  -framework OpenGL
ln -sf libGLEW.2.2.0.dylib lib/libGLEW.2.2.dylib
ln -sf libGLEW.2.2.0.dylib lib/libGLEW.dylib
strip -x lib/libGLEW.2.2.0.dylib
sed \
		-e "s|@prefix@|/usr/local|g" \
		-e "s|@libdir@|/usr/local/lib|g" \
		-e "s|@exec_prefix@|/usr/local/bin|g" \
		-e "s|@includedir@|/usr/local/include/GL|g" \
		-e "s|@version@|2.2.0|g" \
		-e "s|@cflags@||g" \
		-e "s|@libname@|GLEW|g" \
		-e "s|@libgl@|-framework OpenGL|g" \
		-e "s|@requireslib@||g" \
		< glew.pc.in > glew.pc
cc -DGLEW_NO_GLU -DGLEW_STATIC -Os -Wall -W -Iinclude -dynamic -fno-common -pedantic -fPIC -std=c89  -o tmp/darwin/default/static/glew.o -c src/glew.c
ar rv lib/libGLEW.a tmp/darwin/default/static/glew.o
ar: lib/libGLEW.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: lib/libGLEW.a: Inappropriate file type or format
make: *** [lib/libGLEW.a] Error 1

For now I just used the following commands as workaround:

sudo make install.include
sudo cp lib/libGLEW.a /usr/local/lib

@nigels-com
Copy link
Owner

Looks good, makes sense.

@nigels-com nigels-com added the bug label Feb 8, 2022
@nigels-com
Copy link
Owner

Does this work as expected?

sudo make SYSTEM=darwin-universal install

@sanssecours
Copy link
Contributor Author

Does this work as expected?

sudo make SYSTEM=darwin-universal install

The command above fails with a linker error on my machine:

install -d -m 0755 "/usr/local/include/GL"
install -m 0644 include/GL/wglew.h "/usr/local/include/GL/"
install -m 0644 include/GL/glew.h "/usr/local/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/local/include/GL/"
install -m 0644 include/GL/eglew.h "/usr/local/include/GL/"
mkdir lib
cc -DGLEW_NO_GLU -DGLEW_BUILD -Os -Wall -W -Iinclude -dynamic -fno-common -pedantic -fPIC -arch i386 -arch x86_64 -arch arm64 -std=c89  -o tmp/darwin-universal/default/shared/glew.o -c src/glew.c
cc -dynamiclib -install_name /usr/local/lib/libGLEW.2.2.0.dylib -current_version 2.2.0 -compatibility_version 2.2 -o lib/libGLEW.2.2.0.dylib tmp/darwin-universal/default/shared/glew.o -arch i386 -arch x86_64 -arch arm64 -framework OpenGL
ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks//OpenGL.framework/OpenGL.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks//OpenGL.framework/OpenGL.tbd (3 slices)
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd (3 slices)
Undefined symbols for architecture i386:
  "___bzero", referenced from:
      _glewContextInit in glew.o
  "___stack_chk_fail", referenced from:
      _glewContextInit in glew.o
  "___stack_chk_guard", referenced from:
      _glewContextInit in glew.o
  "_dlopen", referenced from:
      _NSGLGetProcAddress in glew.o
  "_dlsym", referenced from:
      _NSGLGetProcAddress in glew.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lib/libGLEW.2.2.0.dylib] Error 1

@nigels-com
Copy link
Owner

Ah, looks like it's time to retire i386 from the universal build.

Installing the library fails on macOS 12, if we use the compiler flags
for the i386 architecture.

See also:

- nigels-com#348 (comment)
@sanssecours
Copy link
Contributor Author

Ah, looks like it's time to retire i386 from the universal build.

I removed the flags for the i386 architecture in the latest commit. Installing the library with

sudo make SYSTEM=darwin-universal install

now works on my machine.

@nigels-com nigels-com merged commit 5dbae5a into nigels-com:master Feb 9, 2022
@sanssecours sanssecours deleted the 🍏 branch February 9, 2022 09:59
JALB91 pushed a commit to JALB91/glew-cmake that referenced this pull request Sep 26, 2023
Installing the library fails on macOS 12, if we use the compiler flags
for the i386 architecture.

See also:

- nigels-com/glew#348 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants