Compiling for Linux

Enrico

16-05-2007 00:12:08

Hi,

I am currently trying to compile NxOgre 0.9, taken from SVN (revision 20). Ogre 1.4.1 is installed and working, as well as PhysX 2.6.2. I hope I have the settings copied correctly from your codeblocks project file (it was only NXOGRE_LINUX).


g++ -o source/NxOgreActor.o -c -O2 -pipe -DNXOGRE_LINUX -DLINUX -I/home/enrico/projekte/PhysX_2.6.2/novodex/SDKs/Cooking/include/ -I/home/enrico/projekte/PhysX_2.6.2/novodex/SDKs/Foundation/include/ -I/home/enrico/projekte/PhysX_2.6.2/novodex/SDKs/Framework/include/ -I/home/enrico/projekte/PhysX_2.6.2/novodex/SDKs/NxCharacter/include/ -I/home/enrico/projekte/PhysX_2.6.2/novodex/SDKs/NxExtensions/include/ -I/home/enrico/projekte/PhysX_2.6.2/novodex/SDKs/Physics/include/ -I/home/enrico/projekte/PhysX_2.6.2/novodex/SDKs/PhysXLoader/include/ -I/usr/local/include/OGRE/ -Iinclude source/NxOgreActor.cpp
In file included from source/NxOgreActor.cpp:20:
include/NxOgreStable.h:87:7: warning: no newline at end of file
In file included from include/NxOgreActor.h:23,
from source/NxOgreActor.cpp:21:
include/NxOgrePrerequisites.h:1: error: stray '\377' in program
include/NxOgrePrerequisites.h:1: error: stray '\376' in program
In file included from include/NxOgreActor.h:23,
from source/NxOgreActor.cpp:21:
include/NxOgrePrerequisites.h:1:4: warning: null character(s) ignored
include/NxOgrePrerequisites.h:1:6: warning: null character(s) ignored
include/NxOgrePrerequisites.h:2:1: warning: null character(s) ignored

This is the result of compiling the first file in source/. There are some strange errors with the characters. I tried to open the file in vim and Netbeans, but it looks correct so far. In vim there are the Windows Newline-characters '^M' visible. So I removed them from NxOgrePrerequisites.h but it did not change nothing.

I have no idea where these errors might come from :(

Best regards, Enrico

betajaen

16-05-2007 09:05:45

I believe you have it correct, those weird characters are odd. I'll run it through one of those advance notepad programs and convert it back into proper ASCII.

Did anything else surprising appear in the compile log?

Enrico

16-05-2007 09:32:47

I believe you have it correct, those weird characters are odd. I'll run it through one of those advance notepad programs and convert it back into proper ASCII.
Ok, thank you :)

Did anything else surprising appear in the compile log?
After five minutes of "warning: null character(s) ignored" and other errors and warnings I canceled the build :oops:
I still do not know where these errors and warnings should come from. I am working with source code created and edited by Visual Studio and compiled under Linux without problems :?:

betajaen

16-05-2007 10:08:42

GCC is really picky about silly things - the last line of a file must be blank for example.

Once I get some time, I'll have a stab at it, but anyone else is more than welcome to.

Enrico

16-05-2007 10:22:22

It is me again :D

I converted NxOgrePrequisites.h with:

col -bx < NxOgrePrequisites.h > NxOgrePrequisites.h

And now the compile starts and works until this error:

include/NxOgreCharacterController.h:79: error: ISO C++ forbids declaration of 'NxControllerManager' with no type
include/NxOgreCharacterController.h:79: error: expected ';' before '*' token
include/NxOgreCharacterController.h:81: error: expected `;' before 'virtual'
include/NxOgreCharacterController.h:103: error: ISO C++ forbids declaration of 'NxControllerManager' with no type
include/NxOgreCharacterController.h:103: error: expected ';' before '*' token
source/NxOgreCharacter.cpp: In constructor 'NxOgre::Character::Character(const NxOgre::NxString&, NxOgre::Scene*, NxOgre::CharacterController*, NxOgre::Pose, NxOgre::CharacterParams)':
source/NxOgreCharacter.cpp:62: error: 'class NxOgre::CharacterController' has no member named 'mControllerManager'
source/NxOgreCharacter.cpp:76: error: 'class NxOgre::CharacterController' has no member named 'mControllerManager'

:(

betajaen

16-05-2007 10:26:09

Figures. Silly Linux.

Enrico

16-05-2007 10:30:54

Where is "NxControllerManager" defined? I grep'ed through PhysX SDK 2.6.2 (2.7.0 is not available for Linux) and NxOgre for this, but the only places found are the places with the error messages :(

betajaen

16-05-2007 10:51:31

Argh. I just remember Ageia rewrote the character system in 2.7.0 including introducing the NxControllerManager class.

I suppose I'd have to write the Character for 2.6.2 as well.

Enrico

16-05-2007 10:55:24

Argh. I just remember Ageia rewrote the character system in 2.7.0 including introducing the NxControllerManager class.

I suppose I'd have to write the Character for 2.6.2 as well.

Ok :|

I will try to deactivate the character system, dont need that for now :)

betajaen

16-05-2007 11:02:26

If you just surround #if 0 and #endif, around the character code it should be good to go.

Enrico

16-05-2007 11:05:41

If you just surround #if 0 and #endif, around the character code it should be good to go.
Yeah, this works :)
But there are at least 5 more errors I already fixed and I am still not finished with fixing :(

btmorex

17-05-2007 23:08:05

GCC is really picky about silly things - the last line of a file must be blank for example.

Once I get some time, I'll have a stab at it, but anyone else is more than welcome to.


I opened the file in a hex editor. The first character is decimal 255 followed by decimal 254... after that there is a null (decimal 0) character between every ascii character. Sort of looks like it's in some 2-byte encoding format (some kind of unicode maybe?).

On a different note, do either of you know how I can get access to the Linux version of PhysX? I have an account but the only downloads available are the windows versions, which I'm not particularly interested in.

betajaen

17-05-2007 23:15:59

I can't either, Ageia has been busy! I'm hoping it means some new lovely things will happen soon.

btmorex

17-05-2007 23:22:06

I put in a request in their support section, hopefully they'll give me access. Otherwise, I guess I'll have to use a different physics package (but PhysX looks the best :cry: ).

elementarladung

18-05-2007 06:09:36

Hi,
go into the download section of sdk 2.6.2

There will be a linux version of it.

Greets

btmorex

18-05-2007 07:54:46

Hi,
go into the download section of sdk 2.6.2

There will be a linux version of it.

Greets


I only have 2.6.4 (only see a windows version) and 2.7.something (again only windows) in my list.

elementarladung

18-05-2007 08:20:40

hi,

yes you're right. It's not available anymore.

Enrico

18-05-2007 08:40:39

Just a small update: I got NxOgre compiling and linking. I modified one of Ogre's demos, unfortunately it crashs :( I will need to investigate here some more...

Toby

19-05-2007 11:06:11

Ho, I am very interesting. I tried to compile on Linux 4 months ago. And I love my Linux distribution with Beryl desktop manager.

If it works fine I will try again. Post change to do for it. Thx.

vinvin

19-05-2007 17:09:29

I compiled a few files correctly, but when trying NxOgreError.cpp it fails:

include/NxOgreWorld.h:44: error: ISO C++ forbids declaration of 'CharacterController' with no type
include/NxOgreWorld.h:44: error: expected ';' before '*' token


I tried to #include <CharacterController.h> from PhysX, but it has too many required headers and I don't know them...
What can I do to make it compile ?
Thanks

betajaen

19-05-2007 18:16:16

Are you using the latest SVN? I've disabled the character controller for Linux in it.

vinvin

20-05-2007 01:07:51

Yes, it is version 23.
But I don't see anything which would prevent this line to be in the header with linux. The only #ifdef is the entire .h thing to prevent include loops.

BTW, I'm using my own makefile with -DNX32 -DNX_LINUX -DNXOGRE_LINUX -DLINUX . What else should be added ?

Thanks :)

vinvin

20-05-2007 20:11:40

Well, I tried a few things and there are a few fixes:

  1. * include/NxOgreWorld.h: put #ifdef WIN32 around uses of CharacterController (lines 44 and 63)
    * include/NxOgreJointSet1.h:24: #include NxOgreJoint.h
    * include/NxOgreShapeWheel.h:90: friend class WheelShape;
    * source/NxOgrePhysXDriver.cpp:206: missing semicolon at the end of the line.
    * include/NxOgreRaycaster.h:40: friend class Scene;
    * source/NxOgreUserAllocator.cpp:86: missing semiconlon at the end of the line.
    [/list:u]
    Useful warnings:

    1. * source/NxOgreCooking.cpp:405: warning: deleting 'void*' is undefined
      [/list:u]
      And still errors:

      1. * source/NxOgreRemoteDebuggerConnection.cpp does not compile because NxFoundation is not defined (it is in debug macros). PhysX headers really suck, they often don't include what's needed...
        * source/NxOgreShapeWheel.cpp:223: error: 'class NxWheelContactData' has no member named 'contactPosition'
        [/list:u]
        All other files compile correctly. Do you have a solution for contactPosition ? The remote debugger is not mandatory I guess.

vinvin

22-05-2007 14:49:47

Maybe one could try to compile NxOgre under windows with PhysX 2.6.2.
When it compiles correctly, we could use the same version for windows and linux and we would be sure it works fine with 2.6.2 (we are using NxOgre for a portable game). And It would be easier to maintain for us (no feature disabling).
But maybe Ageia has planned to release 2.7.0 for linux ?

vinvin

01-06-2007 21:24:39

Still not compiling with version 24. Please commit what I told above and take a look at contactPosition :(
The following diff is the same thing than my previous post but in a diff format.
Thanks


Index: source/NxOgreUserAllocator.cpp
===================================================================
--- source/NxOgreUserAllocator.cpp (revision 24)
+++ source/NxOgreUserAllocator.cpp (working copy)
@@ -81,7 +81,7 @@
#if defined(WIN32) || defined(_XBOX)
LeaveCriticalSection(&m_Mutex);
#elif defined(__APPLE__) || defined(LINUX)
- pthread_mutex_unlock(&m_Mutex)
+ pthread_mutex_unlock(&m_Mutex);
#endif
}

Index: source/NxOgrePhysXDriver.cpp
===================================================================
--- source/NxOgrePhysXDriver.cpp (revision 24)
+++ source/NxOgrePhysXDriver.cpp (working copy)
@@ -207,7 +207,7 @@
<< " Most recent versions are at http://get.nxogre.org/" << std::endl;
#else
s << "Unable to start the PhysX SDK!" << std::endl << std::endl << "Please refer to the developer or publisher's website or support line for information relating to the errors detailed."
- << std::endl << std::endl << " -> Error Code: PhysX SDK is unavailable. Please install the PhysX System Software." << std::endl
+ << std::endl << std::endl << " -> Error Code: PhysX SDK is unavailable. Please install the PhysX System Software." << std::endl;
#endif

s << std::endl << std::endl << std::endl << "Version information:" << std::endl
Index: include/NxOgreJointSet2.h
===================================================================
--- include/NxOgreJointSet2.h (revision 24)
+++ include/NxOgreJointSet2.h (working copy)
@@ -21,7 +21,7 @@
#define __NXOGRE_JOINTSET2_H__

#include "NxOgrePrerequisites.h"
-#include "NXOgreJoint.h"
+#include "NxOgreJoint.h"

namespace NxOgre {

Index: include/NxOgreWorld.h
===================================================================
--- include/NxOgreWorld.h (revision 24)
+++ include/NxOgreWorld.h (working copy)
@@ -41,7 +41,9 @@

Ogre::Root* getRoot() {return mRoot;}
PhysXDriver* getPhysXDriver() {return mDriver;}
+#ifdef WIN32
CharacterController* getCharacterController() {return mCharacterController;}
+#endif
NxPhysicsSDK* getSDK();

void simulate(float time);
@@ -60,7 +62,9 @@

Ogre::Root *mRoot;
PhysXDriver* mDriver;
+#ifdef WIN32
CharacterController* mCharacterController;
+#endif

private:

Index: include/NxOgreRaycaster.h
===================================================================
--- include/NxOgreRaycaster.h (revision 24)
+++ include/NxOgreRaycaster.h (working copy)
@@ -37,7 +37,7 @@

class NxExport RayCaster : public NxUserRaycastReport {

- friend Scene;
+ friend class Scene;

public:

Index: include/NxOgrePrerequisites.h
===================================================================
--- include/NxOgrePrerequisites.h (revision 24)
+++ include/NxOgrePrerequisites.h (working copy)
@@ -142,7 +142,7 @@

////////////////////////////////////////////////////////

-#ifdef NX_USE_FLUID_API
+#if (NX_USE_FLUID_API == 1)
typedef Container<NxString, Fluid*> Fluids;
typedef Container<NxString, FluidDrain*> FluidDrains;
typedef Container<NxString, FluidEmitter*> FluidEmitters;
Index: include/NxOgreStable.h
===================================================================
--- include/NxOgreStable.h (revision 24)
+++ include/NxOgreStable.h (working copy)
@@ -81,10 +81,10 @@

#include <Nx.h>
#include <NxPhysics.h>
-#include <ControllerManager.h>

#ifdef NX_WIN32
#include <OgreMemoryMacros.h>
+#include <ControllerManager.h>
#endif

//////////////////////////////////////////////////////////////
Index: include/NxOgreShapeWheel.h
===================================================================
--- include/NxOgreShapeWheel.h (revision 24)
+++ include/NxOgreShapeWheel.h (working copy)
@@ -87,7 +87,7 @@

class NxExport Wheel : public Shape {

- friend WheelShape;
+ friend class WheelShape;

public:


betajaen

03-06-2007 16:13:32

Thank you.

I've implemented your patch, with a little bit of creativity. Fixed your Wheel ContactPosition bug (I took out the line), I'm guessing it's not defined in 2.6.2

I'm still stuck on the missing NxFoundation define, any chance you can elaborate on it?

vinvin

03-06-2007 17:19:13

Great :)

About NxFoundation, I was more going to not include it in the library and not use the remote debugger than fix it !
Here are the full errors:

source/NxOgreRemoteDebuggerConnection.cpp: In destructor 'NxOgre::RemoteDebuggerConnection::~RemoteDebuggerConnection()':
source/NxOgreRemoteDebuggerConnection.cpp:52: error: 'class NxRemoteDebugger' has no member named 'disconnect'
source/NxOgreRemoteDebuggerConnection.cpp: In member function 'void NxOgre::RemoteDebuggerConnection::simulate(NxReal)':
source/NxOgreRemoteDebuggerConnection.cpp:72: error: 'NxFoundation' has not been declared
source/NxOgreRemoteDebuggerConnection.cpp:73: error: 'NxFoundation' has not been declared
source/NxOgreRemoteDebuggerConnection.cpp: In member function 'void NxOgre::RemoteDebuggerConnection::addCamera(Ogre::Camera*)':
source/NxOgreRemoteDebuggerConnection.cpp:96: error: 'NxFoundation' has not been declared
source/NxOgreRemoteDebuggerConnection.cpp:101: error: 'NxFoundation' has not been declared
source/NxOgreRemoteDebuggerConnection.cpp:102: error: 'NxFoundation' has not been declared


Actually DBG macros expand to NxFoundation::FoundationSDK::getInstance().getRemoteDebugger()->writeParameter(...)
I don't have NxFoundation or FoundationSDK or even getInstance() defined anywhere in PhysX headers ! I don't understand how it can compile under windows...
Are these lines mandatory ? Is there another way to write them ?

betajaen

03-06-2007 23:54:08

Perhaps the RemoteDebugger isn't a feature in the Linux version.

vinvin

04-06-2007 00:22:01

yes perhaps. The weird thing is that the macros are defined for all architectures. I will continue to ignore this feature then - together with clothes and fluids.

I'm impatiently waiting for your contactPosition fix :) After that, I will be able to test what I am porting under linux !

betajaen

04-06-2007 00:26:42

You can just remove the line as it's not needed. The line after that replaces it with the contents from somewhere else.

I blame Luis for it - He wrote it. ;)

vinvin

04-06-2007 00:43:31

Great :D
Thanks betajaen !

vinvin

05-06-2007 00:42:57

I have been able to compile properly NxOgre without clothes, fluids and remote debugger, and same thing for the game I'm porting. The compilation stage is ok.
Now when I run it, I get this bad error on createBody:

Error: free unknown memory!!
*** glibc detected *** /home/vinvin/ADC/adoc: free(): invalid pointer: 0x596097d0 ***

The backtrace is:

#0 0xb7fbd410 in ?? ()
#1 0xbfbc353c in ?? ()
#2 0x00000006 in ?? ()
#3 0xb71a65b1 in abort () from /lib/i686/cmov/libc.so.6
#4 0xb71db08b in __fsetlocking () from /lib/i686/cmov/libc.so.6
#5 0xb71e2eed in mallopt () from /lib/i686/cmov/libc.so.6
#6 0xb71e6530 in free () from /lib/i686/cmov/libc.so.6
#7 0xb777490b in NxOgre::UserAllocator::free (this=0x2c10e498, memory=0x596097d8)
at source/NxOgreUserAllocator.cpp:474
#8 0xb77757f2 in MemoryWriteBuffer::storeBuffer (this=0xbfbc4014, buffer=0xbfbc3df4, size=4)
at source/NxOgreUserStream.cpp:214
#9 0xb77752ad in MemoryWriteBuffer::storeFloat (this=0xbfbc4014, f=2.53052998)
at source/NxOgreUserStream.cpp:187
#10 0xb742d487 in writeFloatBuffer () from /usr/local/lib/libPhysXCooking.so
#11 0xb7417a2f in TriangleMeshBuilder::save () from /usr/local/lib/libPhysXCooking.so
#12 0xb7403977 in NxCookTriangleMesh () from /usr/local/lib/libPhysXCooking.so
#13 0xb774b2a2 in NxOgre::NxGenerateTriangleMeshFromOgreMesh (meshName=@0x5968a828, scene=0x4f518d78,
scale=@0xbfbc411c) at source/NxOgreCooking.cpp:316
#14 0xb776c3b3 in NxOgre::MeshShape::_bindToActorDescription (this=0x5968a770, actor=0x5968a830,
shapes=@0xbfbc4234) at source/NxOgreShapeDescriptionMesh.cpp:60
#15 0xb7743a41 in NxOgre::Actor::_createActor (this=0x5968a830, shape=0x5968a770, pose=@0xbfbc450c,
params=@0xbfbc4294) at source/NxOgreActor.cpp:108
#16 0xb7744023 in Actor (this=0x5968a830, name=@0xbfbc4310, scene=0x4f518ca0, shape=0x5968a770,
pose=@0xbfbc450c, params=@0xbfbc42f4) at source/NxOgreActor.cpp:74
#17 0xb7749957 in Body (this=0x5968a830, identifier=@0xbfbc4528, scene=0x4f518ca0,
firstShapeDescription=0x5968a770, pose=@0xbfbc450c, params=@0xbfbc437c) at source/NxOgreBody.cpp:34
#18 0xb77605e4 in NxOgre::Scene::createBody (this=0x4f518ca0, identifier=@0xbfbc4528,
firstShapeDescription=0x5968a770, pose=@0xbfbc450c, params=@0xbfbc44f0) at source/NxOgreScene.cpp:164
#19 the game files...

Are you sure that the UserAllocator works properly ? I can check variables in any stack level printed above if you need some debug information.
Please check the execution path to see what/where is the problem, I don't know your code, it would take me days to understand it all.
Thanks !

betajaen

05-06-2007 09:27:12

Yep. It has worked before, and it's the UserAllocator written by Ageia.

vinvin

05-06-2007 10:00:01

So it seems that the problem in is NxOgre.

betajaen

05-06-2007 10:35:58

No, what I mean is; I've used NxOgre (0.9) in Linux with the UserAllocator, perhaps somehow it's different between the 2.6.x version and the 2.7.x version we have here. But I doubt it.

vinvin

05-06-2007 10:58:08

How could you use 2.7.x in linux ?
I am using NxOgre svn 0.9 and PhysX 2.6.2, and it crashes.

betajaen

05-06-2007 11:02:52

I wasn't, it was 2.6.x

I just had a thought, are you compiling it in Release or Debug mode? If it's release try it in Debug - I have a thought.

vinvin

05-06-2007 11:18:33

What is the difference ? If it is just about enabling debugging symbols it is already done, since there is a human readable backtrace. Are there debug macros I should define in NxOgre ? I can't test it before tomorrow night anyway :(

betajaen

05-06-2007 11:39:52

With Debugging anything to do with cooking is done to disk. If I remember correctly you can't cook to memory in Linux. Debug mode is the safer because everything is streamed and handled in files.

Worth a shot anyway.

daedar

05-06-2007 11:55:00

Maybe we can try to generate .nxs files under Windows and load them under Linux so that we can bypass the cooking process, no?

Btw, can a file cooked with 2.7 be loaded with 2.6? :?

betajaen

05-06-2007 11:56:31

Two monkeys! Your in this together, ain't ya?

You can certainly try, but I'm sure it'll cook on Linux in Debug mode.

daedar

05-06-2007 12:04:01

hehe yep we're 5 monkeys (students) working on ADoC :wink:

So we'll try both (debug and nxs).

vinvin

06-06-2007 23:50:45

Enabling NX_DEBUG does not change the fact that it crashes on a double free or corruption when loading a mesh. It however creates a file.mesh.nxs.
There is quite nothing in the log file, except versions numbers.
What can I do now ?

It still crashes in createBody, but when deleting the UserStream now. It sound to me like a memory corruption, and anything which is after it goes into bad memory space. Stack trace follows:

#5 0xb71f1eed in mallopt () from /lib/i686/cmov/libc.so.6
#6 0xb71f5530 in free () from /lib/i686/cmov/libc.so.6
#7 0xb71e0f64 in fclose () from /lib/i686/cmov/libc.so.6
#8 0xb7789bd1 in ~UserStream (this=0xbfafdf4c) at source/NxOgreUserStream.cpp:43
#9 0xb775af5d in NxOgre::NxGenerateTriangleMeshFromOgreMesh (meshName=@0x59680c10, scene=0x4f4b3600, scale=@0xbfafe04c)
at source/NxOgreCooking.cpp:356
#10 0xb777eef7 in NxOgre::MeshShape::_bindToActorDescription (this=0x59680b58, actor=0x59680c30, shapes=@0xbfafe164)
at source/NxOgreShapeDescriptionMesh.cpp:60
#11 0xb7752f91 in NxOgre::Actor::_createActor (this=0x59680c30, shape=0x59680b58, pose=@0xbfafe43c, params=@0xbfafe1c4)
at source/NxOgreActor.cpp:108
#12 0xb7753573 in Actor (this=0x59680c30, name=@0xbfafe240, scene=0x4f4b3528, shape=0x59680b58, pose=@0xbfafe43c,
params=@0xbfafe224) at source/NxOgreActor.cpp:74
#13 0xb775931f in Body (this=0x59680c30, identifier=@0xbfafe458, scene=0x4f4b3528, firstShapeDescription=0x59680b58,
pose=@0xbfafe43c, params=@0xbfafe2ac) at source/NxOgreBody.cpp:34
#14 0xb7771820 in NxOgre::Scene::createBody (this=0x4f4b3528, identifier=@0xbfafe458, firstShapeDescription=0x59680b58,
pose=@0xbfafe43c, params=@0xbfafe420) at source/NxOgreScene.cpp:164

Thanks :)

vinvin

28-06-2007 22:38:28

I have the same error with svn version 27. Now we are sure that it is not the cooking which crashes, since files are loaded directly from the nxs generated on windows.

Does anybody has ever make NxOgre work on linux ?
I'm quite thinking it has never, and it probably won't if you don't debug it, since you're the only one who knows the code :/

betajaen

28-06-2007 22:52:28

Yes, I have, and I believe I had it working with MeshShapes. This of course was months ago. Perhaps it's crashing because your using a 2.7.x saved shape on a 2.6.x PhysX.

I hear PhysX 2.7.2 for Linux is arriving at the end of June though.

vinvin

28-06-2007 23:36:42

That would be great !
Easier to maintain NxOgre at least !

That was crashing at the exact same line when I generated the nxs with 2.6.2 last time with svn 24. I don't think this is related with cooked files version.