-
Notifications
You must be signed in to change notification settings - Fork 183
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
CSharp: Linux works - windows broken #285
Comments
ok, I guess this is as good time as any to wrap c sharp. I added the cmake script by basically copying the python version and editing it. it builds the project and compile a dll, but there are some warnings that are in fact error. could be potential error, because the can result to an incorrect function call, so they all have to be resolve by adding explicit renaming or disable warning. here is one tip. dlls are good for debugging but, in many cases if these are wrapper for different languages, it is nice that the entire thing is just one lib and one dll. at least for me, I like it better that way. |
yes but let us make official, if you sync, I added few fixed to the python script, mainly those warnings, plus I added the solver plugins. I also added the start of the c sharp script, so whatever modification you'd make, you can add it and submit a pull request. |
ok, I now added the proper renaming for operator overload method in some of the math classes. ndVector x(1); them: ndVector y = x + x is a valid operation in cpp, but if you try that in the python wrapper or c shaper, you will get an undefined function error. y = x.Add(x) and should works, because the operator+ is converted to member function Add. all the functions are defined in the Newton.i swig script. if you sync, it should just work, or be very closed to a wrapper with the full functionality or the engine. |
As usual, you go beyond any reasonable expectation of assistance, and solve problems I didn't know about before they manifested. Thank you. It is worth noting you can enable the I had not realized that setting Anyway, I'll give it a test on windows again probably tomorrow. Hopefully the linker issues are resolved with the changes to the newton.i file. It's worth noting the issues with ndFloat32 (and related) types that are typedeffed in |
oh yes you are correct, somehow python automatically replaces operator with the name, it is c sharp that does not do that.
ah yes that's another problem. yes, I was never able to add ndTypes.h to the swig script, because that file includes too instead, I did almost the same thing to did. but the minimal define are in header file the problem was that the still had the legacy prefix d instead of nd. one last think is that I added ndVector.h instead of ndVectorSimd.h using ndVectorSimd.h is generate as
but when using ndVector.h, it is generated as
it does not seem much, but SWIGTYPE_p_ndVector is a managed object, which goes through lot of memory and data conversion while ndVector is a native type. that was generted by the .cxx glue code. however, those saving are so minor, that I think is better to just use the define type and not the inlined low level version and that will be more aligned with the target language. anyway, try sync before you try again. |
I'm a little confused about the practical difference between using Anyway, this just compiles out-of-the-box on Linux now. There are still a couple rough edges though. CMake sets the final library name based on the project name, so the output is Anyway, I'll try on windows here shortly and see if the symbol issue is resolved. Might try a clean dev environment if not, just to make sure the issue isn't local to the windows vm. |
Can confirm it works on windows too. |
Ok, so we now know it work, so that the base line.
I do not know what difference it makes in python, using inline
ndVectorSimd.h
in c chart its been few years since I use it. But in c sharp there are ways
to get a native pointer to an object, so it seems that the swig compiler
capitalize on that when it can resolve an inline function.
So all those functions that pass vector around, are collapsed when they are
inlined, you see that the .cs files take the genetic cshapt type. But when
using the inline is does some funny casting in the .cxx function.
I do not worry about that, newton is a very lightweight library, and there
is very little communication from the app to the sdk.
So the time in .cxx is negligible.
I rather like it better when not using tge inlines.
I belive that python does something simular. But I can't testify to that
since I know very little about it.
On the library name.
You can make a pull request, and them it can be added.
The one thing about cmake search for installed dependencies, is that in
window not every one install app in the default folders, so many time many
c make script fail to find the dependency, that why I used the environment
variable.
If you make the pull request, I can check it out and if it works, them
that's I merge it.
…On Sun, Jul 10, 2022, 12:00 PM Logan Perkins ***@***.***> wrote:
Can confirm it works on windows too.
—
Reply to this email directly, view it on GitHub
<#285 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6EPJDPSW2HTRL6AZCFMIDVTMMULANCNFSM53C27Z3A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
So when my brother saw I had newton working with python via swig, he asked if it worked with CSharp. So I duplicated the
newtonPy
sub-project tonewtonSharp
, changed the swig options, removed the post-install steps, and told it to build. On linux, it "just worked". After manually compiling the .cs files (csc $(find . | grep cs$) -target:library -out:newton.dll
), it even successfully ran a simple world test with no further intervention.When he followed the same procedure on windows, both using msvc and using clang, it compiles, but then fails the linking step for the newtonSharp.dll with missing symbols. I'm including the traceback for the clang try, as it's easier to read than the msvc failure, but I can probably furnish that one too if you need it.
The odd thing is the python extension links fine. I know windows is odd about what symbols it exports vs what symbols it hides, but I don't know enough about windows development to begin to sort that out.
Any advice on how to proceed would be appreciated, and if it's not too much trouble, can you at least check if it works on your (presumably good) windows dev box? It would at least let me rule out a bad configuration in my windows VM.
Also a bunch of missing symbols related to
ndBigVector::...
The text was updated successfully, but these errors were encountered: