-
Notifications
You must be signed in to change notification settings - Fork 25
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
Windows build support #7
Conversation
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 adding this! I can't immediately verify it on a windows machine myself, so I might wait until I try it out on a machine at work.
Side-note: I'd appreciate if you base your commits on my main
branch so the commits
tab in github only shows the new work you've done for this PR. Thanks!
crates/opencascade-sys/build.rs
Outdated
@@ -36,6 +37,8 @@ fn main() { | |||
cxx_build::bridge("src/lib.rs") | |||
.cpp(true) | |||
.flag_if_supported("-std=c++11") | |||
.define("_USE_MATH_DEFINES", "TRUE") | |||
.include(format!("{}", dst.join("inc").display())) |
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.
Is CMake generating this directory only for windows targets?
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.
Seems to be. The structure is different in subtle ways.
One option is to add conditionals to enable/disable these different paths. I opted not to do that yet. Once a pattern emerges it might be a good idea.
Im not sure what OCCT does for macos
or webassembly
.
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 tried for macos. It uses the lib
directory.
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.
Ah sorry, I should mention that I develop mainly on MacOS so that target should be well tested.
I'm currently not planning to target web assembly, though I may have plans in the future to have a model viewer that accepts web assembly blobs which generate instructions for generating an opencascade model.
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.
Fair enough. I am primarily on Linux myself so that covers those two. I will probably need webassembly at some point but I am in no rush for it.
I'm working on a project similar to OpenSCAD. Last year I did the webassembly port of OpenSCAD and judging from the community reaction, I will probably need it for this project as well.
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.
Haha I wanted fillets and chamfers as well. Got those in first thing.
I made an adapter for my cars cup holder so I can fit my favorite mug in it. So I can say its usable. However there is lots to do before its ready for real use. However I did get a little 3D editor in it so it really feels like working with OpenSCAD at this point.
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 wouldnt have gotten so far if this crate didnt exist. I really appreciate the work you did here.
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.
Feel free to leave issues and suggestions for things if you want. Especially syntax for the language since that needs lots of inspiration.
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.
Really cool to get a usable, real-world object as a result of some Rust hacking :)
I did get a little 3D editor in it so it really feels like working with OpenSCAD at this point.
MacOS has a native STL viewer that I've been using as a crutch, otherwise I probably would have gotten frustrated and made a viewer as well.
I wouldnt have gotten so far if this crate didnt exist. I really appreciate the work you did here.
Thank the opencascade devs! And dtolnay for the cxx
crate :) I'm just gluing things together here, though I did suffer through the initial work of getting build.rs
working properly, I'll take credit for that haha
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'll clone it and give it a spin!
Im trying. Maintaining a fork is not something I am used to. Especially where I need a main branch to work on my changes as well with potentially multiple of the PRs merged. Ill do my best to keep it simple in the future. |
@DSchroer let me know if you need any help with git operations. My basic workflow for forks is to have two remotes. As an example, here's my local git repo for
You can add remotes with
You can then fetch branches with To checkout my latest
You can then create a new branch based on
When done with your work, push to your remote and make a PR:
When you want to update
|
Thanks! Ill use that for future PRs. I appreciate the detailed response. |
Just a note. You can test this on linux if you do the following:
Just make sure that you have |
Still waiting to test this on a windows machine, sorry! Work is busy this week until Thursday, I'll try to test it then. |
On the msvc toolchain, after adding the correct linker path, I get this output:
I'll investigate this more later but I have to leave this machine for now. |
Make the build work on windows msvc targets
Hey. I built your changes against my project and it worked just fine. So I merged them. Now I run into a weird error with the examples though. My project gives no errors but the examples give me:
Ive got no idea where those are coming from at this point. Any ideas? I probably wont have time to look deep for a few weeks right now. However we can let this sit on ice until then. Can you build the examples with MSVC? |
Hi @DSchroer sorry to get back to you so late on this! I am able to build and run the bottle example on the MSVC toolchain. I'll try reproducing your error with |
@DSchroer actually I haven't used mingw in forever on windows, do you have a list of steps I can follow to reproduce the issue you're seeing, on a windows machine specifically? That'll probably be faster than me struggling with windows for hours 😅 |
@bschwind I have some time to look into it now. For repro steps on linux (I am corss compiling):
|
Got it fixed. We need to set the |
crates/opencascade-sys/build.rs
Outdated
cxx_build::bridge("src/lib.rs") | ||
.cpp(true) | ||
.flag_if_supported("-std=c++11") | ||
.include(format!("{}", dst.join("include").join("opencascade").display())) | ||
.define("_USE_MATH_DEFINES", "TRUE") | ||
.define("OCC_CONVERT_SIGNALS", occ_convert_define) |
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.
From this page
On Windows with MSVC compiler, exceptions can be thrown directly from signal handler, this OCC_CONVERT_SIGNALS is not needed. Note however that this requires that compiler option /EHa is used.
Not sure if we need /EHa
here or not. I built this on the default MSVC toolchain you get with a windows Rust installation and I get two linking errors:
unresolved external symbol "public: void __cdec1 Standard_ErrorHandler::Callback::RegisterCallback(void)"
unresolved external symbol "public: void __cdec1 Standard_ErrorHandler::Callback::UnregisterCallback(void)"
Currently still working this out.
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.
Ive limited the flag to only *-windows-gnu
builds. It should fix the error for you now.
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.
@DSchroer I think if it's not *-windows-gnu
you don't want to define OCC_CONVERT_SIGNALS
at all. On MSVC, if you set occ_convert_define
to None
, you're still defining OCC_CONVERT_SIGNALS
and I still get the issue I mentioned above.
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.
Oh shoot. I assumed based on the interface .define("thing", None)
would disable it. Ill look into it soon.
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.
Ive done another pass. This time its only ever set for windows-gnu
. Hopefully this works.
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.
LGTM!
Tested and working on the MSVC toolchain, sorry for all the back-and-forth on this but glad we finally got it working!
Awesome! Want to merge the PR? |
Haha yep, got distracted right after I commented that, sorry! Thanks for the PR and patience :) |
Add the necessary build parameters in order to cross compile for windows.
Test with
x86_64-pc-windows-gnu
.