-
-
Notifications
You must be signed in to change notification settings - Fork 402
Fix windows dll path #1384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix windows dll path #1384
Conversation
Reviewer's Guide by SourceryThis PR implements a fix for Windows DLL loading by adding a new initialization mechanism that adds OpenCascade DLL directories to the Windows DLL search path. The changes also include a major update to the installation documentation with comprehensive guides for both Linux and Windows platforms. Sequence diagram for Windows DLL initializationsequenceDiagram
actor User
participant Application
participant OS
participant OpenCascade
User->>Application: Start Application
Application->>OS: Check platform
alt Windows
OS->>Application: Platform is Windows
Application->>OS: Check OCCT_ESSENTIALS_PATH
alt OCCT_ESSENTIALS_PATH set
OS->>Application: OCCT_ESSENTIALS_PATH is set
Application->>OpenCascade: Initialize OCCT libraries
loop For each DLL in OCCT_ESSENTIALS_PATH
OpenCascade->>OS: Add DLL directory to search path
end
else OCCT_ESSENTIALS_PATH not set
OS->>Application: OCCT_ESSENTIALS_PATH not set
Application->>User: Raise AssertionError
end
else Not Windows
OS->>Application: Platform is not Windows
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tpaviot - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
There is one mistake after Ln.33.
A "break" is needed to prevent further processing the same directory.
The idea is calling "add_dll_directory" upon a directory once only if there is any DLL in it.
Bill-XU
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great THANKS ! It becomes more friendly to windows users.:-D
I have some suggestions.
-
Regarding "System Requirements (Windows)" or "Installing Required Software (Windows)"
rapidjson is also necessary for building RWGltf.
Usegit clone https://github.com/Tencent/rapidjson.git -
Regarding "Building pythonOCC (Windows) 3. Configure with CMake"
If using CMake GUI, it is necessary not forgetting add two environment variables in GUI.
OCCT_INCLUDE_DIR=C:\OpenCASCADE-7.8.1\inc
OCCT_LIBRARY_DIR=C:\OpenCASCADE-7.8.1\win64\vc14\lib -
There is no explanation on how to configure rapidjson for RWGltf.
Here is what I am doing.- Run VisualStudio 2022 Community as administrator
- Open PYTHONOCC.sln generated by CMake
- Open properties window of project RWGltf
- Choose C/C++ on the left
- Edit "Additional Include Directories"
- Add include directory of rapidjson.
Note: the include directory of rapidjson is the "include" itself under rapidjson root, and in it there is only one subfolder and its name is "rapidjson". In case you cloned rapidjson to C:\rapidjson, the include directory shall be "C:\rapidjson\include". - If you continue building within VisualStudio, change target to Release, and build the whole solution then the project INSTALL.
Unfortunately, I only use VisualStudio 2022 Community, so don't know how to make the same changes when using cmake --build.
-
Regarding the value of "OCCT_ESSENTIALS_PATH", I suggest using the root directory of OpenCascade and its 3rd party libraries. (Maybe changing the name to "OCCT_ESSENTIALS_ROOT" is better?)
In my case, I created a folder named "OpenCASCADE-7.8.1" under "C:\Program Files (x86)". And I extracted all 3rd party libraries in it, also created a folder named "opencascade-7.8.1" for holding compiled OCCT. So I set the value to "C:\Program Files (x86)\OpenCASCADE-7.8.1".
This folder structure is also recommended by OCCT in this instruction https://dev.opencascade.org/doc/overview/html/index.html#intro_install_windows
(If the value was "%CASROOT%\win64\vc14\bin", the 3rd party libraries, like TCL/TK DLLs, would not be loaded when the folder structure was as the same as OCCT recommended)
|
@Bill-XU thank you for your comments. For anything related to documentation on building occt/pythonocc for windows, you can open a new issue/pr. |
|
I have a suggestion to include setup of |
|
@Andrej730 You mean the |
Yeah, I think, this is what most users would expect if build succeeded and Python package is installed - Python package to work without setting up additional environment variable manually. |
|
ok that makes sense I will add this feature |
| set the ```OCCT_ESSENTIALS_ROOT``` environment variable | ||
| ```batch | ||
| setx OCCT_ESSENTIALS_PATH "%CASROOT%\win64\vc14\bin" | ||
| setx OCCT_ESSENTIALS_ROOT "%CASROOT%\win64\vc14\bin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "OCCT_ESSENTIALS_ROOT" must be the root of OpenCASCADE in which there are not only opencascade itself, but also its 3rd party libraries. Otherwise, many packages (AIS etc.) would throw DLL not found error.
The recommended folder structure is described in OCCT's documentation here https://dev.opencascade.org/doc/overview/html/index.html#intro_install_windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I'm sorry @Bill-XU I don't get the point between the _ROOT, _PATHS, "root of opencascade" etc. this is specific windows stuff. You can let the OCCT_ESSENTIALS_ROOT env var point wherever needed. If you need a different behavior please submit a patch. |
@tpaviot |
|
@Andrej730 I tweaked CmakeList.txt so it becomes possible to define OCCT_ESSTNEIALS_ROOT at build time and hard code the related path to config.py. It can however still be defined at run time. Can you please test and report any issue? @Bill-XU I think the INSTALL.md is now more accurate, can you please review. |
|
BTW @Andrej730 I remember you discussed a pythonocc issue, related to shape serialization and version upgrade, but I can't find it anymore, can you please point me to the right place? |
@tpaviot I believe this is the one - #1350 (comment) |

This PR is a follow up for #1347
@farleyrunkel @Andrej730 @Bill-XU can you please review this PR I cannot test the fix.
Summary by Sourcery
Fix the DLL path issue on Windows by adding a function to initialize OCCT libraries using the OCCT_ESSENTIALS_PATH environment variable. Update the INSTALL.md to provide a detailed build guide for Linux and Windows, including prerequisites, system requirements, and troubleshooting.
Bug Fixes:
Documentation: