GLSL-PathTracer icon indicating copy to clipboard operation
GLSL-PathTracer copied to clipboard

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

Open liumu96 opened this issue 2 years ago • 9 comments

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?

liumu96 avatar Jun 25 '23 01:06 liumu96

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)

knightcrawler25 avatar Jun 25 '23 06:06 knightcrawler25

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.

liumu96 avatar Jun 25 '23 12:06 liumu96

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.

knightcrawler25 avatar Jun 25 '23 13:06 knightcrawler25

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

liumu96 avatar Jun 26 '23 01:06 liumu96

Do you have SDL2 installed?

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

knightcrawler25 avatar Jun 26 '23 02:06 knightcrawler25

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

liumu96 avatar Jun 26 '23 02:06 liumu96

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.

flaricy avatar Jan 18 '24 12:01 flaricy

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?

aceiii avatar Feb 28 '24 07:02 aceiii

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 " ") 

tfiner avatar Jun 16 '24 21:06 tfiner