From f0a9b5794e7918893b00c2380cc59e8c2e8f7943 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:46:03 +0000 Subject: [PATCH 1/6] Initial plan From 2674af6e607c88b1da10713a1ba52b7aacb77a95 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:53:27 +0000 Subject: [PATCH 2/6] Force BUILD_SHARED_LIBS=ON for Python module builds - Modified CMakeLists.txt to automatically set BUILD_SHARED_LIBS=ON when BUILD_PYTHON_MODULE=ON - Updated Dockerfile.wheel to remove explicit BUILD_SHARED_LIBS=OFF - Updated Windows workflow to remove explicit BUILD_SHARED_LIBS=OFF for wheel builds - Updated ci_utils.sh to remove BUILD_SHARED_LIBS=OFF from pip package builds This ensures pybind module dynamically links to libOpen3D.so instead of statically embedding it Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com> --- .github/workflows/windows.yml | 1 - CMakeLists.txt | 6 ++++++ docker/Dockerfile.wheel | 2 +- util/ci_utils.sh | 3 +-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b68e8814dc2..ee0e23d9171 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -311,7 +311,6 @@ jobs: cmake -G "Visual Studio 17 2022" -A x64 ` -DCMAKE_INSTALL_PREFIX="C:\Program Files\Open3D" ` -DDEVELOPER_BUILD="$Env:DEVELOPER_BUILD" ` - -DBUILD_SHARED_LIBS=OFF ` -DSTATIC_WINDOWS_RUNTIME=ON ` -DBUILD_COMMON_ISPC_ISAS=ON ` -DBUILD_AZURE_KINECT=ON ` diff --git a/CMakeLists.txt b/CMakeLists.txt index 855c47e1dcb..513caf88822 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,6 +245,12 @@ if(BUILD_JUPYTER_EXTENSION AND NOT BUILD_PYTHON_MODULE) message(FATAL_ERROR "BUILD_JUPYTER_EXTENSION=ON requires BUILD_PYTHON_MODULE=ON") endif() +# Python bindings require shared libraries to separate pybind module from libOpen3D +if(BUILD_PYTHON_MODULE) + set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (required for Python module)" FORCE) + message(STATUS "BUILD_SHARED_LIBS set to ON (required for BUILD_PYTHON_MODULE)") +endif() + # Parse Open3D version number file(STRINGS "cpp/open3d/version.txt" OPEN3D_VERSION_READ) foreach(ver ${OPEN3D_VERSION_READ}) diff --git a/docker/Dockerfile.wheel b/docker/Dockerfile.wheel index 08a3ae5a583..e3c093f2f20 100644 --- a/docker/Dockerfile.wheel +++ b/docker/Dockerfile.wheel @@ -132,8 +132,8 @@ COPY . /root/Open3D WORKDIR /root/Open3D # Build python wheel +# Note: BUILD_SHARED_LIBS is automatically set to ON when BUILD_PYTHON_MODULE=ON RUN export NPROC=$(($(nproc)+2)) \ - && export BUILD_SHARED_LIBS=OFF \ && source /root/Open3D/util/ci_utils.sh \ && build_pip_package build_azure_kinect build_jupyter \ && if [ ${CI:-}a != a ]; then cd /root/Open3D/build/ && ls | grep -Ev '^lib$' | xargs rm -rf ; fi diff --git a/util/ci_utils.sh b/util/ci_utils.sh index dc5182f159b..aef44f0652a 100644 --- a/util/ci_utils.sh +++ b/util/ci_utils.sh @@ -175,8 +175,7 @@ build_pip_package() { echo Building with CPU only... mkdir -p build pushd build # PWD=Open3D/build - cmakeOptions=("-DBUILD_SHARED_LIBS=OFF" - "-DDEVELOPER_BUILD=$DEVELOPER_BUILD" + cmakeOptions=("-DDEVELOPER_BUILD=$DEVELOPER_BUILD" "-DBUILD_COMMON_ISPC_ISAS=ON" "-DBUILD_AZURE_KINECT=$BUILD_AZURE_KINECT" "-DBUILD_LIBREALSENSE=ON" From ffc6db70933ee9a7a4e2103346192d49805ffe38 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:56:14 +0000 Subject: [PATCH 3/6] Fix macOS OpenMP library packaging for shared builds - Removed the NOT BUILD_SHARED_LIBS condition from OpenMP library packaging - Now packages libomp for macOS regardless of build type since Python builds always use shared libs Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com> --- cpp/pybind/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cpp/pybind/CMakeLists.txt b/cpp/pybind/CMakeLists.txt index 982b0eccd8f..c7f4d1f6e16 100644 --- a/cpp/pybind/CMakeLists.txt +++ b/cpp/pybind/CMakeLists.txt @@ -106,10 +106,9 @@ set(PYTHON_EXTRA_LIBRARIES $) if (BUILD_GUI AND CMAKE_SYSTEM_NAME STREQUAL "Linux") list(APPEND PYTHON_EXTRA_LIBRARIES ${CPP_LIBRARY}.1 ${CPPABI_LIBRARY}) endif() -if (WITH_OPENMP AND APPLE AND NOT BUILD_SHARED_LIBS) +if (WITH_OPENMP AND APPLE) # Package libomp v11.1.0, if it is not installed. Later version cause crash on -# x86_64 if PyTorch is already imported. Case of shared libopen3d.dylib is not -# handled. +# x86_64 if PyTorch is already imported. # https://github.com/microsoft/LightGBM/issues/4229 list(APPEND PYTHON_EXTRA_LIBRARIES ${OpenMP_libomp_LIBRARY}) execute_process(COMMAND brew list --versions libomp From fccae3f23a5c5261aa5f4cc3d7dac682ed48ae75 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 23:58:22 +0000 Subject: [PATCH 4/6] Remove STATIC_WINDOWS_RUNTIME=ON from Windows wheel build - Removed explicit STATIC_WINDOWS_RUNTIME=ON from Windows wheel workflow - When BUILD_SHARED_LIBS=ON (now automatic for Python), STATIC_WINDOWS_RUNTIME defaults to OFF - Shared libraries should use DLL runtime (/MD) instead of static runtime (/MT) Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com> --- .github/workflows/windows.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ee0e23d9171..02333c9fe77 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -311,7 +311,6 @@ jobs: cmake -G "Visual Studio 17 2022" -A x64 ` -DCMAKE_INSTALL_PREFIX="C:\Program Files\Open3D" ` -DDEVELOPER_BUILD="$Env:DEVELOPER_BUILD" ` - -DSTATIC_WINDOWS_RUNTIME=ON ` -DBUILD_COMMON_ISPC_ISAS=ON ` -DBUILD_AZURE_KINECT=ON ` -DBUILD_LIBREALSENSE=ON ` From 1eef0300afe69293f195a6aca68886ac64860960 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 00:00:02 +0000 Subject: [PATCH 5/6] Improve BUILD_SHARED_LIBS message clarity - Added conditional message only when BUILD_SHARED_LIBS was OFF - Clarified why shared libraries are required for Python module Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com> --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 513caf88822..50f43b64939 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,8 +247,11 @@ endif() # Python bindings require shared libraries to separate pybind module from libOpen3D if(BUILD_PYTHON_MODULE) + if(NOT BUILD_SHARED_LIBS) + message(STATUS "BUILD_SHARED_LIBS was OFF, forcing to ON (required for BUILD_PYTHON_MODULE)") + message(STATUS "Python bindings require libOpen3D as a shared library to separate pybind module from libOpen3D") + endif() set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (required for Python module)" FORCE) - message(STATUS "BUILD_SHARED_LIBS set to ON (required for BUILD_PYTHON_MODULE)") endif() # Parse Open3D version number From fe53c5109fc6ff34b8e2c589b006a5db62097020 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 04:57:50 +0000 Subject: [PATCH 6/6] Change BUILD_SHARED_LIBS default to ON instead of forcing it - Reverted the CMakeLists.txt logic that forced BUILD_SHARED_LIBS=ON when BUILD_PYTHON_MODULE=ON - Changed the default value of BUILD_SHARED_LIBS from OFF to ON - This allows users to build Python bindings with static libOpen3D if desired - Updated Dockerfile.wheel comment to reflect the new approach - CI/Docker/build scripts still remove explicit BUILD_SHARED_LIBS=OFF to use the default Co-authored-by: ssheorey <41028320+ssheorey@users.noreply.github.com> --- CMakeLists.txt | 11 +---------- docker/Dockerfile.wheel | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50f43b64939..f7c53548853 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ endif() include(CMakeDependentOption) # Open3D build options -option(BUILD_SHARED_LIBS "Build shared libraries" OFF) +option(BUILD_SHARED_LIBS "Build shared libraries" ON ) option(BUILD_EXAMPLES "Build Open3D examples programs" ON ) option(BUILD_UNIT_TESTS "Build Open3D unit tests" OFF) option(BUILD_BENCHMARKS "Build the micro benchmarks" OFF) @@ -245,15 +245,6 @@ if(BUILD_JUPYTER_EXTENSION AND NOT BUILD_PYTHON_MODULE) message(FATAL_ERROR "BUILD_JUPYTER_EXTENSION=ON requires BUILD_PYTHON_MODULE=ON") endif() -# Python bindings require shared libraries to separate pybind module from libOpen3D -if(BUILD_PYTHON_MODULE) - if(NOT BUILD_SHARED_LIBS) - message(STATUS "BUILD_SHARED_LIBS was OFF, forcing to ON (required for BUILD_PYTHON_MODULE)") - message(STATUS "Python bindings require libOpen3D as a shared library to separate pybind module from libOpen3D") - endif() - set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries (required for Python module)" FORCE) -endif() - # Parse Open3D version number file(STRINGS "cpp/open3d/version.txt" OPEN3D_VERSION_READ) foreach(ver ${OPEN3D_VERSION_READ}) diff --git a/docker/Dockerfile.wheel b/docker/Dockerfile.wheel index e3c093f2f20..161054fd788 100644 --- a/docker/Dockerfile.wheel +++ b/docker/Dockerfile.wheel @@ -132,7 +132,7 @@ COPY . /root/Open3D WORKDIR /root/Open3D # Build python wheel -# Note: BUILD_SHARED_LIBS is automatically set to ON when BUILD_PYTHON_MODULE=ON +# Note: BUILD_SHARED_LIBS defaults to ON, which is required for Python wheels RUN export NPROC=$(($(nproc)+2)) \ && source /root/Open3D/util/ci_utils.sh \ && build_pip_package build_azure_kinect build_jupyter \