Newton in C++

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Newton in C++

Postby lperkins2 » Mon Aug 13, 2018 2:26 am

So, I'm having a hard time understanding how the source and compiled libraries are laid out for use in C++. The C-compatible header is sdk/dgNewton/Newton.h, and using that while linking against libNewton.so works, but only gives opaque objects and no convenient interface for object-oriented programs.

The C++ top level header appears to be sdk/dNewton/dNewton.h, but that references symbols (_ZN12dNewtonAllocnwEm) which are not defined in libNewton.so (or the lib*.a static libraries). What am I missing? It looks like I can compile dNewton/dNewtonAlloc.cpp and similar files, and everything will work. Am I just missing a c++ shared library? Or does the c++ shared library not exist and I just have to compile those files myself inside my project?
lperkins2
 
Posts: 39
Joined: Fri Jul 03, 2015 4:16 am

Re: Newton in C++

Postby Slick » Mon Aug 13, 2018 4:56 am

I don't know if I have exactly the same challenge but I struggle sometimes deciding what libraries to include to link against. I have been working on my project and am getting lots of link errors.

For example in a C++ project to you link to both dNewton.lib and newton.lib?
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Newton in C++

Postby MeltingPlastic » Mon Aug 13, 2018 12:58 pm

I link against both dNewton and newton as well as an other libs your need like dCustomJoints
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Newton in C++

Postby lperkins2 » Mon Aug 13, 2018 1:03 pm

So, my choices are
libNewton.so
libdMath.a
libdContainers.a
libdAnimation.a
libimgui.a
libNewton.a
libdCustomJoints.a
libdScene.a

Looks like dNewton doesn't get built on linux. I can build and link against the contents of the dNewton folder, and things seem more or less happy, but looking at the contents of dNewton, it looks like a thin wrapper around Newton.cpp.

For example, dNewtonBody::GetMatrix just proxies the call to NewtonBodyGetMatrix. Hm... digging into Newton.cpp, it creates a NewtonWorld (which looks to really just be an opaque type).
Code: Select all
typedef struct NewtonWorld{} NewtonWorld;

But the NewtonCreate() function really gives back Newton::Newton (from NewtonClass.cpp), which extends dgWorld. Looks like if you want to actually use c++ without the C api, NewtonClass.h is the starting point.



Hm... looks like you can't actually include NewtonClass.h in an external project and get it to compile properly. Looks like the answer is the C api is the only api.
Last edited by lperkins2 on Mon Aug 13, 2018 1:16 pm, edited 1 time in total.
lperkins2
 
Posts: 39
Joined: Fri Jul 03, 2015 4:16 am

Re: Newton in C++

Postby Slick » Mon Aug 13, 2018 1:14 pm

I think dNewton is a small wrapper. In theory you could use Newton without it.

I am still working on understanding it all. For now I am using dNewton along with other libraries.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Newton in C++

Postby Julio Jerez » Mon Aug 13, 2018 2:08 pm

lperkins2 wrote:So, my choices are
libNewton.so
libdMath.a
libdContainers.a
libdAnimation.a
libimgui.a
libNewton.a
libdCustomJoints.a
libdScene.a

Ok let us start symple. How did you make those libraries, did you use the make file, the cmake scripts or something else?
I recently re wrote the cmake script to general complete projects that are suppose to work out of the box.
The problem is that I only have window systems, and I could not get the cross build to generate projects in windows.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton in C++

Postby Slick » Mon Aug 13, 2018 3:22 pm

Julio the CMake is working well. One thing I changed in mine was to use MDd and not MTd for debug. I am used to creating apps as multi thread DLL. I don't know if that is not the norm but for me to avoid linking errors I did that.

I almost have my app updated so I don't even know if it is working with the latest yet.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Newton in C++

Postby lperkins2 » Mon Aug 13, 2018 9:57 pm

The sequence was
Code: Select all
cd $NGD
mkdir build
cd build
cmake ..
make
su -c 'make install'


This was with the Jan 2018 stable release. So if by recently you mean after the stable release, that would do it. I'll rebuild with the latest github snapshot and see what happens.
lperkins2
 
Posts: 39
Joined: Fri Jul 03, 2015 4:16 am

Re: Newton in C++

Postby lperkins2 » Tue Aug 14, 2018 1:45 am

Nope, no dice. CMake chokes with
Code: Select all
CMake Error at sdk/dScene/CMakeLists.txt:25 (install):
  install TARGETS given no LIBRARY DESTINATION for shared library target
  "dScene".

and a bunch of similar errors. I'll step back git commits to see if there's a version that compiles.


Doesn't look promising, going back 10 days gets me a working cmake, but the compilation chokes in dTimeTracker.h with the expansion of DTIMETRACKER_API
lperkins2
 
Posts: 39
Joined: Fri Jul 03, 2015 4:16 am

Re: Newton in C++

Postby Julio Jerez » Tue Aug 14, 2018 11:23 am

I do not think it will work, I rewrote all the cmake scripts, but I only tests on visual studio.

I was hoping someone could take a look and add the extra stiff for making a POSIT make file.

I tried to generate one, but for that it can only be done in two way:
1-use a native system which I do not have
2-use cross compiling.

When I try using cross build system it will not work unless I specify a "buidsytem" which I know nothing about.

I am reading the cmake 3:12 doc about making a cross compiler for linux.

If you are silly to test it, I can start doing it tonight and should ready in a day or two.

The hand made makefile is one that I wrote, but requires too much maintenance, it is better to have Cmake generate one and get rid of all of the hand made build, including the visual studio ones.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton in C++

Postby lperkins2 » Tue Aug 14, 2018 12:30 pm

I can test the new cmake scripts. If it would help, I can get you access to a linux VM I use for scratch work. Long term, getting a VM set up on your local machine is probably the most reliable way, assuming your computer can handle it. If you're on windows 10, there's now something called 'Windows Subsystem for Linux', which runs usermode linux under windows.
lperkins2
 
Posts: 39
Joined: Fri Jul 03, 2015 4:16 am

Re: Newton in C++

Postby Julio Jerez » Tue Aug 14, 2018 1:28 pm

ah cool, let me get as much as I can on the cmake fiorst then I see if I can install some of those
linux virtual machines, my system soul be above to handle it yes,
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton in C++

Postby lperkins2 » Sun Sep 02, 2018 11:59 am

Any progress on getting CMake working on linux? I still get
Code: Select all
CMake Error at sdk/dProfiler/dTimeTracker/CMakeLists.txt:32 (install):
  install TARGETS given no LIBRARY DESTINATION for shared library target
  "dTimeTracker".

and a bunch of similar errors, when running cmake against the latest github commit.
lperkins2
 
Posts: 39
Joined: Fri Jul 03, 2015 4:16 am

Re: Newton in C++

Postby Julio Jerez » Sun Sep 02, 2018 4:38 pm

well there was another person inferring to do it, but it seems he shy away.
I just got a new 512 gb drive and I am cloning my c drive.
I read that Windows 10 now allows for an installation of unbuntoo linux as a virtual machine.

If I can get that set up, I see if I can do it this weekend.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton in C++

Postby lperkins2 » Mon Sep 03, 2018 1:56 pm

Linux Subsystem for windows, it's actually more like usermode linux than a true linux VM, which means it is much less resource hungry. For these purposes, it should work just fine.
lperkins2
 
Posts: 39
Joined: Fri Jul 03, 2015 4:16 am

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 14 guests

cron