knightcrawler25 / GLSL-PathTracer

A toy physically based GPU path tracer (C++/OpenGL/GLSL)
MIT License
1.87k stars 176 forks source link

Running [Make] in Apple M2 : Undefined symbols for architecture arm64 #87

Open liumu96 opened 1 year ago

liumu96 commented 1 year ago

Hi! I tried running this program on macOS with Apple Silicon (M2) Chip, but when running make I got an error:

Undefined symbols for architecture arm64:
  "_oidnSetFilter1b", referenced from:
      GLSLPT::Renderer::Update(float) in Renderer.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [PathTracer] Error 1
make[1]: *** [CMakeFiles/PathTracer.dir/all] Error 2
make: *** [all] Error 2

I guess it doesn't work yet on macOS with Apple Silicon (M1) Chip? Any recommendations how to bypass that?

knightcrawler25 commented 1 year ago

Hey. The OIDN (OpenImageDenoise) library (v1.2.4) that this project uses probably doesn't support Apple Silicon and I haven't looked into the newer releases for the library.

For now, you can try disabling the denoiser. The dev branch has code that moves the denoiser behind a cmake option (defaulted to OFF)

liumu96 commented 1 year ago

Does that mean this error won't happen if I run this program at the dev branch? I'm not familiar with these code so I didn't find the code that moves the denoiser behind a cmake option.

knightcrawler25 commented 1 year ago

Does that mean this error won't happen if I run this program at the dev branch?

Yes, and to confirm, you can try compiling the code from the dev branch and see if the linker error pops up again.

liumu96 commented 1 year ago

I tried compiling the code from the dev branch and there was a new error, the compile failed.

mkdir build && cd build
cmake build -DCMAKE_BUILD_TYPE=RELEASE ..
make

Error

ld: library not found for -lSDL2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [PathTracer] Error 1
make[1]: *** [CMakeFiles/PathTracer.dir/all] Error 2
make: *** [all] Error 2
knightcrawler25 commented 1 year ago

Do you have SDL2 installed?

https://github.com/knightcrawler25/GLSL-PathTracer/blob/master/INSTALL-MAC.txt

liumu96 commented 1 year ago

Yeah, I installed sdl2 and open-image-denoise. The sdl2 version is 2.26.5.

brew install sdl2
Warning: sdl2 2.26.5 is already installed and up-to-date.
To reinstall 2.26.5, run:
  brew reinstall sdl2
flaricy commented 10 months ago

I've encountered the same problem in M2 chip. I've tried to build it in dev mode, which yields the following error info: ld: Undefined symbols: _oidnCommitDevice, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o _oidnCommitFilter, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o _oidnExecuteFilter, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o _oidnGetDeviceError, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o _oidnNewDevice, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o _oidnNewFilter, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o _oidnReleaseDevice, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o oidn::DeviceRef::~DeviceRef() in Renderer.cpp.o _oidnReleaseFilter, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o oidn::FilterRef::~FilterRef() in Renderer.cpp.o _oidnSetFilter1b, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o _oidnSetSharedFilterImage, referenced from: GLSLPT::Renderer::Update(float) in Renderer.cpp.o GLSLPT::Renderer::Update(float) in Renderer.cpp.o clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [PathTracer] Error 1 make[1]: *** [CMakeFiles/PathTracer.dir/all] Error 2 make: *** [all] Error 2

How can I deal with it? Thanks.

aceiii commented 9 months ago

Im on an x86 mac, running MacOS 13.6.4 and I'm getting the same issue as the original poster. Thinking it was somehow not picking the OIDN from homebrew, I manually cloned and compiled it but that lead to even more errors.

Wondering if anyone else has made any progress on this?

tfiner commented 5 months ago

I was able to build on an M2 with OIDN:

  1. installed oidn via homebrew
  2. deleted thirdparty/oidn
  3. changed CMakeLists.txt:
    
    set(OIDN_LIBDIR /opt/homebrew/lib)
    include_directories(/opt/homebrew/include)

deleted all the backslash junk starting with foreach(f ${SRCS}) ... endforeach() This isn't needed, and I think it contributed to lldb trouble loading the symbols

Commented out this, it isn't needed, and it looked like it was wiping out the debug flag -g

SET(LINK_OPTIONS " ")