Context: I work in a project that produces a python library. This library has several dependencies and we build most of the dependencies from source.
Everything is done in docker images with Ubuntu 22.
In order to deal with all the dependencies the team created (long ago) a repository based on brew. The idea is: one formula per dependency to be built (and packaged).
The problem: We need to add Open3D as a dependency to the project, so we need to build and package it. But when running make one dependey of Open3D called embree seems to be missing.
To run the build we "simply" use: brew install --build-from-source my-open3d
And a formula:
require "formula"
class MyOpen3d < Formula
homepage 'http://www.open3d.org/'
url "http://mirror.OUR_MIRROR/open3d-0.15.1.zip"
sha256 "1664ad0539d7175215b02aea6ee09eec154ce7f9865abd4fdbc5369fce4ec511" # Same file from github
def install
cmake_args = %W[
-DBUILD_GUI=OFF
-DCMAKE_INSTALL_PREFIX=#{prefix}
-DBUILD_SHARED_LIBS=ON
]
system "mkdir", "builds"
Dir.chdir('builds/') do
system "cmake", "..", *cmake_args
system "make", "-j#{ENV.make_jobs}", "install"
end
end
end
When running this, I see most of the build is done, but it stops at this error:
[ 88%] Building CXX object cpp/pybind/CMakeFiles/pybind.dir/core/tensor_accessor.cpp.o
cd /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/cpp/pybind && /usr/bin/ccache /cache/brew/Library/Homebrew/shims/linux/super/g++ -DBUILD_ISPC_MODULE -DFMT_HEADER_ONLY=0 -DFMT_STRING_ALIAS=1 -DFMT_USE_WINDOWS_H=0 -DOPEN3D_CUDA_COMPILER_ID=\"\" -DOPEN3D_CUDA_COMPILER_VERSION=\"\" -DOPEN3D_CXX_COMPILER_ID=\"GNU\" -DOPEN3D_CXX_COMPILER_VERSION=\"11.4.0\" -DOPEN3D_CXX_STANDARD=\"14\" -DUNIX -DUSE_BLAS -DWITH_IPPICV -DZMQ_STATIC -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=1 -D__TBB_LIB_NAME=tbb_static -Dpybind_EXPORTS -I/cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp/pybind/.. -I/cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/_deps/ext_pybind11-src/include -isystem /usr/include/python3.10 -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/3rdparty/glew/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/3rdparty/glfw/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/fmt/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/eigen/src/ext_eigen -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/parallelstl/src/ext_parallelstl/include -O3 -DNDEBUG -fPIC -fvisibility=hidden -fstack-protector-strong -Wformat -Wformat-security -Wall -Wextra -Werror -Wno-unused-parameter -fdiagnostics-color=always -Wno-unknown-pragmas -flto -fno-fat-lto-objects -std=c++14 -MD -MT cpp/pybind/CMakeFiles/pybind.dir/core/tensor_accessor.cpp.o -MF CMakeFiles/pybind.dir/core/tensor_accessor.cpp.o.d -o CMakeFiles/pybind.dir/core/tensor_accessor.cpp.o -c /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp/pybind/core/tensor_accessor.cpp
[ 88%] Building CXX object cpp/pybind/CMakeFiles/pybind.dir/core/tensor_converter.cpp.o
cd /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/cpp/pybind && /usr/bin/ccache /cache/brew/Library/Homebrew/shims/linux/super/g++ -DBUILD_ISPC_MODULE -DFMT_HEADER_ONLY=0 -DFMT_STRING_ALIAS=1 -DFMT_USE_WINDOWS_H=0 -DOPEN3D_CUDA_COMPILER_ID=\"\" -DOPEN3D_CUDA_COMPILER_VERSION=\"\" -DOPEN3D_CXX_COMPILER_ID=\"GNU\" -DOPEN3D_CXX_COMPILER_VERSION=\"11.4.0\" -DOPEN3D_CXX_STANDARD=\"14\" -DUNIX -DUSE_BLAS -DWITH_IPPICV -DZMQ_STATIC -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=1 -D__TBB_LIB_NAME=tbb_static -Dpybind_EXPORTS -I/cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp/pybind/.. -I/cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/_deps/ext_pybind11-src/include -isystem /usr/include/python3.10 -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/3rdparty/glew/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/3rdparty/glfw/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/fmt/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/eigen/src/ext_eigen -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/parallelstl/src/ext_parallelstl/include -O3 -DNDEBUG -fPIC -fvisibility=hidden -fstack-protector-strong -Wformat -Wformat-security -Wall -Wextra -Werror -Wno-unused-parameter -fdiagnostics-color=always -Wno-unknown-pragmas -flto -fno-fat-lto-objects -std=c++14 -MD -MT cpp/pybind/CMakeFiles/pybind.dir/core/tensor_converter.cpp.o -MF CMakeFiles/pybind.dir/core/tensor_converter.cpp.o.d -o CMakeFiles/pybind.dir/core/tensor_converter.cpp.o -c /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp/pybind/core/tensor_converter.cpp
[ 88%] Building CXX object cpp/pybind/CMakeFiles/pybind.dir/core/tensor_function.cpp.o
cd /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/cpp/pybind && /usr/bin/ccache /cache/brew/Library/Homebrew/shims/linux/super/g++ -DBUILD_ISPC_MODULE -DFMT_HEADER_ONLY=0 -DFMT_STRING_ALIAS=1 -DFMT_USE_WINDOWS_H=0 -DOPEN3D_CUDA_COMPILER_ID=\"\" -DOPEN3D_CUDA_COMPILER_VERSION=\"\" -DOPEN3D_CXX_COMPILER_ID=\"GNU\" -DOPEN3D_CXX_COMPILER_VERSION=\"11.4.0\" -DOPEN3D_CXX_STANDARD=\"14\" -DUNIX -DUSE_BLAS -DWITH_IPPICV -DZMQ_STATIC -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=1 -D__TBB_LIB_NAME=tbb_static -Dpybind_EXPORTS -I/cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp/pybind/.. -I/cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/_deps/ext_pybind11-src/include -isystem /usr/include/python3.10 -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/3rdparty/glew/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/3rdparty/glfw/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/fmt/include -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/eigen/src/ext_eigen -isystem /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/parallelstl/src/ext_parallelstl/include -O3 -DNDEBUG -fPIC -fvisibility=hidden -fstack-protector-strong -Wformat -Wformat-security -Wall -Wextra -Werror -Wno-unused-parameter -fdiagnostics-color=always -Wno-unknown-pragmas -flto -fno-fat-lto-objects -std=c++14 -MD -MT cpp/pybind/CMakeFiles/pybind.dir/core/tensor_function.cpp.o -MF CMakeFiles/pybind.dir/core/tensor_function.cpp.o.d -o CMakeFiles/pybind.dir/core/tensor_function.cpp.o -c /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/cpp/pybind/core/tensor_function.cpp
[ 88%] Linking CXX executable ../../bin/MergeMesh
cd /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/cpp/tools && /usr/bin/cmake -E cmake_link_script CMakeFiles/MergeMesh.dir/link.txt --verbose=1
/cache/brew/Library/Homebrew/shims/linux/super/g++ -O3 -DNDEBUG -Wl,-z,noexecstack -Wl,-z,relro,-z,now -pie -Wl,--strip-debug CMakeFiles/MergeMesh.dir/MergeMesh.cpp.o -o ../../bin/MergeMesh -Wl,-rpath,/cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/lib/Release ../../lib/Release/libOpen3D.so -lstdc++fs
/usr/bin/ld: ../../lib/Release/libOpen3D.so: undefined reference to `embree::avx2::BVH8Triangle4iMBIntersector4HybridPluecker()'
/usr/bin/ld: ../../lib/Release/libOpen3D.so: undefined reference to `embree::avx2::BVH8Triangle4vMBIntersector8HybridPluecker()'
/usr/bin/ld: ../../lib/Release/libOpen3D.so: undefined reference to `embree::avx2::BVH8Triangle4iIntersector1Moeller()'...
And like 1000 more lines with
../../lib/Release/libOpen3D.so: undefined reference to `embree::avx2::SOME_FUNCTION
Fun facts (not really fun):
- It actually works if I set
DBUILD_SHARED_LIBS=OFF(I guess the problem comes from this) - If I run
cmakeandmakedirectly (nobrew) this compilations flags build properly. - When I check the logs I see that the lib
embreewas built:
...
-- Installing: /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/embree/lib/cmake/embree-3.13.0/embree_avx2-targets.cmake
-- Installing: /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/embree/lib/cmake/embree-3.13.0/embree_avx2-targets-release.cmake
-- Installing: /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/embree/lib/libembree3.a
-- Installing: /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/embree/lib/cmake/embree-3.13.0/embree-targets.cmake
-- Installing: /cache/brew.temp/ltu-open3d-20251001-205119-6fsqd9/Open3D-0.15.1/builds/embree/lib/cmake/embree-3.13.0/embree-targets-release.cmake
...
[ 41%] Completed 'ext_embree'
The Question: what might change when building with brew? Am I missing something?
libOpen3D.sodepends from. But none of those libraries contains the symbolembree::avx2::SOME_FUNCTION. Note, that the filelibOpen3D.sohas been created successfully, so at the time of creation the symbol was defined by one of its dependency. So it smells like there are two embree libraries on your system: one which defines the symbolembree::avx2::SOME_FUNCTION, and the one which doesn't define it.embreelibrary, which is built according to the logs. Does that library actually defines the symbolembree::avx2::BVH8Triangle4iMBIntersector4HybridPluecker()?