PhysX & MinGW

sebarnolds

03-11-2006 14:05:47

Hi.

We are currently investigating Ogre 3D rendering with physics support at my work. We decided to use Newton as we couldn't afford the commercial license of PhysX. Anyway the recent license modification changed a lot for us (especially since PhysX has a 3D Studio Max plugin).

The problem is that we are developping a cross-platform application (Windows and Linux) and we are using MinGW under Windows.

Has anymody managed to use PhysX with MinGW ? I tried but, as it contains C++, it is not that easy to use. I reimp'ed the import libraries and successfuly build my application. However after having called NxCreatePhysicsSDK, I cannot use the returned object (getInternalVersion and getNbPPUs return incorrect values and it crash as soon as I call release). MinGW and Visual C++ have never been friends when it comes to using DLL from the other one. Anybody has a solution / idea ?

Thanks,
Seb

betajaen

04-11-2006 18:24:58

I've been avoiding this thread in hope someone would answer.

As I don't have an answer, I have a question. Could you use MinGW on Linux and Visual Studio on Windows.

Wasn't C++ designed in portability in mind? And if you do have conflicts between platforms, thats what #defines are for.

Game_Ender

05-11-2006 07:19:09

C++ the language was designed with portability in mind, but that comes at a price. Its also mean that the code is protable, not necesarily the executables.

Just like C has no firm data type sizes, and many things are left up to the implementer, in C++ there is no standard application binary interface (ABI). Which means Microsoft is free to define how C++ names are mangled, what the calling convention is, how exceptions are handled, etc. This makes C++ libraries compiled with VS incompatible with C++ libraries complied with MinGW. Even different versions of GCC have this same problem. C on the other hand does have a standard ABI, so as long its in the proper executable format in theory you should have no problems.

sebarnolds

06-11-2006 08:46:18

Hi.

Thank you for your answers.

Some more informations here. In fact, binaries compiled by Visual C++ and MinGW are not compatible... not always. There is a way to use both. A (very good) article about this can be found here: http://aegisknight.org/cppinterface.html.

In short, I need, in a Visual C++ DLL, a creation/destruction function in C format (e.g. extern C CLASS_POINTER* initialize()). Then I need the POINTER_CLASS class to be fully pure virtual (e.g. all the functions must be pure virtual ones). If you look at the PhysX headers, you can see that all of these are available (the main NxPhysicsSDK class is a pure virtual class and we get a pointer to it by calling NxCreatePhysicsSDK). I successfuly linked to PhysX DLL (no name mangling issues) but there IS a problem at runtime.

Here is my code :

pPhysX = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION);
if (!pPhysX) {
ALTER_TRACE("error initializing PhysX SDK: wrong SDK DLL version?");
} else {
NxU32 v1, v2, v3, v4;
v1 = pPhysX->getInternalVersion(v2, v3, v4);

ALTER_TRACE("Version: " << v2 << "." << v3 << "." << v4 << "(" << v1 << ")");
ALTER_TRACE("PPUs found: " << pPhysX->getNbPPUs());
}


ALTER_TRACE is just a macro to dump some stuff to stdout. It prints me weird values for getInternalVersion and getNbPPUs (in fact, if I had that amount of PPUs, I would be rich :-) ). And, as soon as I call release on the interface, it generates a fatal error. I assume something is wrong but I can't find what...

So, I guess noone here uses PhysX with MinGW under Windows... :-(

As for using Visual C++ under Windows and gcc under Linux, that would require us to convert our (complex) Makefiles to Visual Studio format and to adapt a lot of things to Visual C++ (assembler code...). This is not an alternative as long as we keep the Linux version.

Anyway, if anybody has an idea, don't hesitate.

Seb

Toby

22-11-2006 11:49:09

Then I tried to compile physX with mingw but i did not managed. I use last OgreSDK 1.2.4 with code block and mingw. I install NxOgre0.5 preview3 and lastest DirectX SDK august2006.

I obtain some error like this:

C:/PhysX/SDKs/Foundation/include/NxSimpleTypes.h:19: error: `__int64' does not name a type
C:/PhysX/SDKs/Foundation/include/NxSimpleTypes.h:24: error: `__int64' does not name a type
C:/PhysX/SDKs/Foundation/include/NxSimpleTypes.h:95: error: `size_t' was not declared in this scope
........


Then I don t know if it is possible.

sebarnolds

22-11-2006 12:03:33

Hi.

I didn't have any problem to compile my application. It seems your problem is different than mine.

I might add that the problem (mine) seems to be related to calling conventions used by Ageia for their SDK which is not compatible with MinGW (vtables are ordered differently).

A collegue of mine successfuly used a tiny part of the SDK by modifying headers (rename destructor, add an argument to all functions and some other tricky modifications... he thought of that by analyzing generated asm by calling conventions). However it is not very practical and we dropped the idea for the moment. Maybe we'll try later (when the Linux sdk is released maybe ?).

Seb

Tsh't

30-05-2008 06:24:39

Old thread but... Doesn't work better now. Tried myself with 2.8.1, even the slightiest example gives me a segmentation fault when accessing to the SDK pointer (with windows libs) :( Maybe the linux SDK, yes...