打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Install PhysX on Ubuntu10.04

Installation

First thing to do is download PhysX package from this site:  http://developer.nvidia.com/object/physx_downloads.html
It looks like Nvidia doesn’t provide packages for linux any more (because of coming sdk 3, they say), but you can still find it

on Internet by googling for: PhysX_2.8.1_SDK_CoreLinux_deb.tar.gz or PhysX_2.8.1_SDK_CoreLinux_rpm.tar.gz

When you have package ready, go to download directory, unpack and install all packages.  64bit users will need to do it from command line to force installation.

64bit:

    sudo dpkg -i --force-architecture *.deb
Shared libraries are installed in version specific directory “/usr/lib/PhysX/v2.8.1/”, 
so we need to link them to “/usr/lib”.
sudo ln -s /usr/lib/PhysX/v2.8.1/libNxCharacter.so.1 /usr/lib/libNxCharacter.so.1
sudo ln -s /usr/lib/PhysX/v2.8.1/libNxCooking.so.1 /usr/lib/libNxCooking.so.1
sudo ln -s /usr/lib/PhysX/v2.8.1/libPhysXCore.so.1 /usr/lib/libPhysXCore.so.1

PhysX is now installed and we can try run some samples from Nvidia which are placed in
“/usr/sbin/PhysX_Samples_2.8.1_FC4/Bin/linux/”. Note that not all samples will work.
I don’t know why they didn’t pay attention to make sure everything works.
Source code for samples are not availableon Linux too. Sample that should work is for example SampleBoxes.
/usr/sbin/PhysX_Samples_2.8.1_FC4/Bin/linux/SampleBoxes

Compile own project

So, now we have working PhysX, let’s try to compile something with use of it. I will describe how to do it with Eclipse CDT.

You can get a gcc comand as well in the next paragraph (Although, for explanation of parameters read this section).

Before start, on 64bit machines ensure that you have 32bit gcc extensions installed:

64bit:

    sudo apt-get install g++-multilib lib32stdc++6
(否则会出现 cannot find ldl的错误)

Create a new C++ Empty Project and go to its properties. Go to “Settings” in “C/C++ Build” section.
We will configure g++ flags to compile project properly.
In “GCC C++ Compiler” in “Preprocessor” add these “Definied symbols”:
    LINUX, NX32, CORELIB, NX_DISABLE_FLUIDS

(Last one is needed to make physics simulation work. I think it’s some kind of bug in PhysX but I’m not sure why it happens.

I’ve found solution for it on some Italian or Spanish site so I could not understand what it was about.)

In “Directories”  enter these paths:

    /usr/include/PhysX/v2.8.1/SDKs/Physics/include

    /usr/include/PhysX/v2.8.1/LowLevel/API/include

    /usr/include/PhysX/v2.8.1/SDKs/Cooking/include

    /usr/include/PhysX/v2.8.1/SDKs/PhysXLoader/include

    /usr/include/PhysX/v2.8.1/SDKs/PhysXLoader/include

    /usr/include/PhysX/v2.8.1/LowLevel/hlcommon/include

    /usr/include/PhysX/v2.8.1/SDKs/Foundation/include

    /usr/include/PhysX/v2.8.1/SDKs/NxCharacter/include

64bit: In “Miscellaneous” add flag to “Other flags”: -m32.  This flag tells compiler to make 32 bit binary instead of 64.

Now go to “GCC C++ Linker” and in “Libraries” add libs:

    dl, pthread, PhysXLoader

    GLU, GL, glut

Second line of libraries listed above are for OpenGL and GLUT, you’ll need them if you’re going to compile source code that I will list below.

64bit: In “Library search path” should be:

/usr/lib32

64bit: Same as in compiler section add flag in “Miscellaneous”

64bit:

-m32

Ok, enviroment set up properly, let’s compile something and see how it works. Because there is no sample code from Nvidia to try

I’ve prepaired one taken from SDK for Windows and modified it a little for easier compilation under Linux. Here are source files: SampleBoxes.tar

And here is entire CTD project with proper configuration: SampleBoxesCDT.tar

Compile, run, enjoy.

Command line

You may also compile these sources from command line with:

g++ -DNX_DISABLE_FLUIDS -DCORELIB -DNX32 -DLINUX -I/usr/include/PhysX/v2.8.1/SDKs/Physics/include -I"" -I/usr/include/PhysX/v2.8.1/LowLevel/API/include -I/usr/include/PhysX/v2.8.1/SDKs/Cooking/include -I/usr/include/PhysX/v2.8.1/SDKs/PhysXLoader/include -I/usr/include/PhysX/v2.8.1/LowLevel/hlcommon/include -I/usr/include/PhysX/v2.8.1/SDKs/Foundation/include -I/usr/include/PhysX/v2.8.1/SDKs/NxCharacter/include -O3 -Wall -c -fmessage-length=0 -m32 -o"SampleBoxes.o" "./SampleBoxes.cpp"
g++ -L/usr/lib32 -m32 -o"physx_test"  ./SampleBoxes.o   -lPhysXLoader -lGLU -lGL -lglut -ldl -lpthread

Documentation

Last, very useful thing to do is install PhysX SDK Documentation viewer. The documentation files in PhysX packages for Linux are taken from Windows literally, so they are in Microsoft’s “.chm” extension

and cover installation and setup under Windows, but still it’s very useful. PhysX API is platform independ. In Ubuntu there is a nice “.chm” file viewer “gnochm”.

Documentation main file is “/usr/share/doc/libphysx-2.8.1/PhysXDocumentation.chm”

Maybe some day we will get drivers from Nvidia that run PhysX on GPU and better support for Linux. In near future there will be release of 3.0 PhysX SDK. It will support 64bit architectures nativel






本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
PostgreSQL技术之家: 从PostgreSQL中访问Oracle数据库的利器:Oracle
gcc -I -L -l区别
修改gcc默认搜索路径
ROS 中添加第三方依赖库
修改修改boot.img文件的工具,mkbootfs,mkbootimg,unpackbootimg
Win7 配置Android开发环境
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服