bschwind / opencascade-rs

Rust bindings to the OpenCascade CAD Kernel
GNU Lesser General Public License v2.1
90 stars 17 forks source link

compile error #27

Open ltg1710 opened 1 year ago

ltg1710 commented 1 year ago

thank for your open project

when i compile it (cargo build) in the envirment

cmake 3.23.0 rustc 1.67 windows 10 (home) visual studio 2022 community

The console give me some error message as fellow

cargo build
   Compiling opencascade-sys v0.1.0 (D:\opensource\OpenCascade\opencascade-rs\crates\opencascade-sys)
error: failed to run custom build command for `opencascade-sys v0.1.0 (D:\opensource\OpenCascade\opencascade-rs\crates\opencascade-sys)`

Caused by:
  process didn't exit successfully: `D:\opensource\OpenCascade\opencascade-rs\target\debug\build\opencascade-sys-8db3cae7a8db6976\build-script-build` (exit code: 101)
  --- stderr
  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKernel/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKernel/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKShHealing/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKShHealing/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKService/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKService/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKV3d/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKV3d/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKOpenGl/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKOpenGl/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  thread 'main' panicked at '
  command did not execute successfully, got: exit code: 1

  build script failed, must exit now', C:\Users\usename\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.50\src\lib.rs:1098:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Can somebody give me some advices? If you need some more information, please leave a message

ltg1710 commented 1 year ago

when add cmake_policy(SET CMP0054 OLD) in OCCT\CMakeLists.txt. the result like this

cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
cmake_policy(SET CMP0054 OLD)

set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/adm/cmake")
......

compile error is

   Compiling opencascade-sys v0.1.0 (D:\opensource\OpenCascade\opencascade-rs\crates\opencascade-sys)
error: failed to run custom build command for `opencascade-sys v0.1.0 (D:\opensource\OpenCascade\opencascade-rs\crates\opencascade-sys)`

Caused by:
  process didn't exit successfully: `D:\opensource\OpenCascade\opencascade-rs\target\debug\build\opencascade-sys-8db3cae7a8db6976\build-script-build` (exit code: 101)
  --- stderr
  CMake Deprecation Warning at CMakeLists.txt:3 (cmake_policy):
    The OLD behavior for policy CMP0054 will be removed from a future version
    of CMake.

    The cmake-policies(7) manual explains that the OLD behaviors of all
    policies are deprecated and that a policy should be set to OLD only under
    specific short-term circumstances.  Projects should be ported to the NEW
    behavior and not rely on setting a policy to OLD.

  thread 'main' panicked at '
  command did not execute successfully, got: exit code: 1

  build script failed, must exit now', C:\Users\usename\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.50\src\lib.rs:1098:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
bschwind commented 1 year ago

Hmmm, unfortunately the error logs don't give a lot of info. Seems to be an error with cmake running.

I would go into the crates/opencascade-sys/OCCT directory, and try to build with cmake directly:

cd crates/opencascade-sys/OCCT
mkdir build
cd build
cmake ..
make

These are just rough commands to build something with cmake, you might need to configure a bit more. Give that a try and see if it runs into any obvious errors.

Also, did you clone with git clone --recursive? If not, you'll need to pull in the OCCT directory because it is a submodule.

If you didn't use --recursive, you can pull it in with git submodule update --init --recursive from the root directory of the project.

ltg1710 commented 1 year ago

it is a compile flag question, can be fixed by adding a compile flag /zi when build type is debug | relwithdebinfo. so this issue only occurs in visual studio on Windows systems. The issue have created in cmake crate repo.

but I don't know how to fix this problem.

I find this point by these step:

  1. find file OCCT.sln in folder opencascade-rs\target\debug\build\opencascade-sys-4548eac1d834d3b2\out\build
  2. open it by visual studio 2022
  3. compile this solution by vs2022
  4. will compile error, you can find error message cannot find tkernel.pdb
  5. check tkernel property, 1685602996503
  6. change it to zi
  7. all is ok
bschwind commented 1 year ago

@ltg1710 does the same issue occur in release mode? (cargo build --release)

I remember getting the compilation working for windows awhile ago, but I haven't checked on more recent commits.

For example could you try an older commit from this PR?

ltg1710 commented 1 year ago

I try use cargo build --release in main branche. error message is

cargo build --release
   Compiling opencascade-sys v0.1.0 (D:\opensource\OpenCascade\opencascade-rs\crates\opencascade-sys)
error: failed to run custom build command for `opencascade-sys v0.1.0 (D:\opensource\OpenCascade\opencascade-rs\crates\opencascade-sys)`

Caused by:
  process didn't exit successfully: `D:\opensource\OpenCascade\opencascade-rs\target\release\build\opencascade-sys-00933064e5fcae31\build-script-build` (exit code: 1)

  --- stderr
  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKernel/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKernel/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKShHealing/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKShHealing/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKService/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKService/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:319 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlLibs" will no longer be dereferenced when
    the policy is set to NEW.  Since the policy is not set the OLD behavior
    will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKV3d/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at adm/cmake/occt_toolkit.cmake:322 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "CSF_OpenGlesLibs" will no longer be dereferenced
    when the policy is set to NEW.  Since the policy is not set the OLD
    behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:14 (include)
    src/TKV3d/CMakeLists.txt:3 (OCCT_INCLUDE_CMAKE_FILE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CXX include path:
    D:\opensource\OpenCascade\opencascade-rs\target\release\build\opencascade-sys-d3bbbd1534d62252\out\cxxbridge\include
    D:\opensource\OpenCascade\opencascade-rs\target\release\build\opencascade-sys-d3bbbd1534d62252\out\cxxbridge\crate

  error occurred: Command "D:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC\\Tools\\MSVC\\14.33.31517\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-O2" "-Brepro" "-I" "D:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\cxxbridge\\include" "-I" "D:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\cxxbridge\\crate" "-I" "D:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\include" "-I" "include" "-W4" "-D_USE_MATH_DEFINES=TRUE" "-FoD:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\afa425caffa7f4d0-lib.rs.o" "-c" "D:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\cxxbridge\\sources\\opencascade-sys\\src\\lib.rs.cc" with args "cl.exe" did not execute successfully (status code exit code: 2).

then run cmd "D:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC\\Tools\\MSVC\\14.33.31517\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-O2" "-Brepro" "-I" "D:\\open source\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\cxxbridge\\include" "-I" "D:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\cxxbridge\\crate" "-I" "D:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\include" "-I" "include" "-W4" "-D_USE_MATH_DEFINES=TRUE" "-FoD:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\afa425caffa7f4d0-lib.rs.o" "-c" "D:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\cxxbridge\\sources\\opencascade-sys\\src\\lib.rs.cc" directly, i can get error message in detail D:\\opensource\\OpenCascade\\opencascade-rs\\target\\release\\build\\opencascade-sys-d3bbbd1534d62252\\out\\cxxbridge\\include\rust/cxx.h(2): fatal error C1083: 无法 打开包括文件: “algorithm”: No such file or directory

cxx.h is a file of cxx crate. its content like this

#pragma once
#include <algorithm>
#include <array>
#include <cassert>
......

My understanding is that it did not find the basic std header file of c++. Should be a problem with including path parameters.

In total. it have been compile OCCT successfully(all header/lib files have intalled to correspond directory) but compile lib.rs.cc failed.

bschwind commented 1 year ago

@ltg1710 I don't have a windows machine handy at the moment so I'll be unable to test this for myself. Sorry it's not working for you but if you're able to find the root cause and adjust it in build.rs, I'll happily get ahold of a machine and test any PRs you submit.

yk0n9 commented 1 year ago

@ltg1710 I don't have a windows machine handy at the moment so I'll be unable to test this for myself. Sorry it's not working for you but if you're able to find the root cause and adjust it in build.rs, I'll happily get ahold of a machine and test any PRs you submit.

Build fails with rustc 1.70 and x86_64-windows-msvc with some full error messages Error:

lib.rs.cc
D:\workspace\opencascade-rs\target\release\build\opencascade-sys-f398181b01cf1afb\out\cxxbridge\sources\opencascade-sys\src\lib.rs.cc(1): fatal error C1083: cannot open include file : “opencascade-sys/include/wrapper.hxx”: No such file or directory
    exit code: 2

Then, I copied opencascade-sys/include as a whole to target/release/build/opencascade-sys-xxx/out/cxxbridge/include/opencascade-sys/ Error:

lib.rs.cc
   D:\workspace\opencascade-rs\target\release\build\opencascade-sys-f398181b01cf1afb\out\include\IMeshTools_ModelBuilder.hxx(52): warning C4530: C++ exception handler used without unwind semantics enabled. Please specify /EHsc
   D:\workspace\opencascade-rs\target\release\build\opencascade-sys-f398181b01cf1afb\out\cxxbridge\include\opencascade-sys/include/wrapper.hxx(79): error C2371: “Handle_Poly_Triangulation”: redefinition; different base types
   D:\workspace\opencascade-rs\target\release\build\opencascade-sys-f398181b01cf1afb\out\include\Poly_Triangulation.hxx(34): note: See the declaration of "Handle_Poly_Triangulation"
   D:\workspace\opencascade-rs\target\release\build\opencascade-sys-f398181b01cf1afb\out\cxxbridge\include\opencascade-sys/include/wrapper.hxx(243): error C2440: “<function-style-cast >': cannot convert from 'opencascade::handle<Poly_Triangulation> *' to 'std::unique_ptr<Handle_Poly_Triangulation,std::default_delete<Handle_Poly_Triangulation>>'
   D:\workspace\opencascade-rs\target\release\build\opencascade-sys-f398181b01cf1afb\out\cxxbridge\include\opencascade-sys/include/wrapper.hxx(243): note: No constructor can accept source type, or constructor overload resolution is ambiguous
   D:\workspace\opencascade-rs\target\release\build\opencascade-sys-f398181b01cf1afb\out\cxxbridge\sources\opencascade-sys\src\lib.rs.cc(1364): error C2440: "initialization": unable Conversion from "const T &(__cdecl *)(const opencascade::handle<T> &)" to "const Poly_Triangulation &(__cdecl *)(const Handle_Poly_Triangulation &)"
   D:\workspace\opencascade-rs\target\release\build\opencascade-sys-f398181b01cf1afb\out\cxxbridge\sources\opencascade-sys\src\lib.rs.cc(1364): note: in the range matching the target type There is no function with that name within
   exit code: 2

Because I don't understand c++, Probably there may be a problem with the path in the windows environment