nigels-com / glew

The OpenGL Extension Wrangler Library
Other
2.62k stars 614 forks source link

Mac OS with M1 encounters with an error when using its dylib #278

Closed MidCoard closed 2 years ago

MidCoard commented 3 years ago

ld: warning: ignoring file /opt/homebrew/Cellar/glew/2.2.0/lib/libGLEW.2.2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

Will GLEW support macOS-arm64? if it supports,when?

nigels-com commented 3 years ago

I wouldn't expect any particular difficulty for supporting the M1. But I don't have one, so can't be sure without others to confirm.

MidCoard commented 3 years ago

Please!!! Thanks!!!

aumuell commented 3 years ago

ld: warning: ignoring file /opt/homebrew/Cellar/glew/2.2.0/lib/libGLEW.2.2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

It appears that you have correctly installed an arm64 build of GLEW to /opt/homebrew. And I assume the error that you cite is showing up while building some other software, but this other software has been compiled for x86_64. So this other software is not compatible with the arm64 GLEW.

You can verify that /opt/homebrew/Cellar/glew/2.2.0/lib/libGLEW.2.2.dylib is indeed arm64, by running file /opt/homebrew/Cellar/glew/2.2.0/lib/libGLEW.2.2.dylib. It should output Mach-O 64-bit executable arm64.

Will GLEW support macOS-arm64? if it supports,when?

As far as I can see, GLEW supports arm64 on macOS just fine.

MidCoard commented 3 years ago

ld: warning: ignoring file /opt/homebrew/Cellar/glfw/3.3.2/lib/libglfw.3.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/glew/2.2.0/lib/libGLEW.2.2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "_glfwCreateWindow", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwDestroyWindow", referenced from:
      GLWindow::~GLWindow() in MagicCubeLauncher.cpp.o
  "_glfwGetKey", referenced from:
      Render::processInput() in MagicCubeLauncher.cpp.o
  "_glfwGetProcAddress", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwGetTime", referenced from:
      Render::initRenderLayer() in MagicCubeLauncher.cpp.o
      getTime() in MagicCubeLauncher.cpp.o
  "_glfwInit", referenced from:
      Shader::Shader(char const*, char const*) in MagicCubeLauncher.cpp.o
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwMakeContextCurrent", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwPollEvents", referenced from:
      Render::initRenderLayer() in MagicCubeLauncher.cpp.o
  "_glfwSetCursorPosCallback", referenced from:
      Render::init() in MagicCubeLauncher.cpp.o
  "_glfwSetFramebufferSizeCallback", referenced from:
      Render::init() in MagicCubeLauncher.cpp.o
  "_glfwSetInputMode", referenced from:
      Render::processInput() in MagicCubeLauncher.cpp.o
  "_glfwSetScrollCallback", referenced from:
      Render::init() in MagicCubeLauncher.cpp.o
  "_glfwSetWindowShouldClose", referenced from:
      Render::processInput() in MagicCubeLauncher.cpp.o
  "_glfwSwapBuffers", referenced from:
      Render::initRenderLayer() in MagicCubeLauncher.cpp.o
  "_glfwTerminate", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
      Render::clear() in MagicCubeLauncher.cpp.o
  "_glfwWindowHint", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwWindowShouldClose", referenced from:
      Render::initRenderLayer() in MagicCubeLauncher.cpp.o
ld: symbol(s) not found for architecture x86_64

I see. It seems that it is my mistake.


cmake_minimum_required(VERSION 3.17)
project(MagicCube)

set(CMAKE_CXX_STANDARD 11)

#set(GLEW_H /opt/homebrew/Cellar/glew/2.2.0/include/GLEW)
#set(GLFW_H /opt/homebrew/Cellar/glfw/3.3.2/include/GLFW)
#set(GLAD_H ${PROJECT_SOURCE_DIR}/include/glad)
#set(KH_H ${PROJECT_SOURCE_DIR}/include/KHR)
#include_directories(${GLEW_H} ${GLFW_H} ${GLAD_H} ${KH_H})

set(GLEW_LINK /opt/homebrew/Cellar/glew/2.2.0/lib/libGLEW.2.2.dylib)
set(GLFW_LINK /opt/homebrew/Cellar/glfw/3.3.2/lib/libglfw.3.dylib)
link_libraries(${OPENGL} ${GLEW_LINK} ${GLFW_LINK})

include_directories(include HeaderFiles)
add_executable(MagicCube glad.c MagicCubeLauncher.cpp)
if (APPLE)
    target_link_libraries(MagicCube "-framework OpenGL")
    target_link_libraries(MagicCube "-framework GLUT")
else ()
    target_link_libraries(MagicCube ${PROJECT_SOURCE_DIR}/lib/glfw3.dll)
endif ()

My whole project just codes with GLFW and GLEW. I just use some of the OpenGL.

my IDE is Clion.Maybe it is because Clion doesn't support ARM now ?

nigels-com commented 3 years ago

Is there anyone that can confirm/test a GLEW 2.2.1 release candidate for ARM Mac? I have an Intel MBP, but would be unable to do any runtime testing.

mbechard commented 2 years ago

I can confirm the visualinfo and glewinfo applications work after building everything from scratch on the M1.