Building Plot3D for OpenSolaris with Sun Studio 12
If you have access to Nasa OpenSource software, you probably have seen their Plot3D package which is available for download and is a very, very nice CFD package that has been around for a very long time. Here are my notes for getting Plot3D ported and running on OpenSolaris using Sun Studio 12 compilers.
Getting started
OpenSolaris 2008.11
plot3d4.1f
Studio 12 compilers
GNU utilities
You need to get Plot3D from Nasa, which is only available through their downloading mechanisms.
For OpenSolaris, use the package manager and the opensolaris.org repository to download the Studio 12 compilers for C/C++ and GNU utilities, the repository is great and as a developer on OpenSolaris, you should get use to this tool to manage your environment, it is a fantastic addition, I use it heavily.
Building Plot3D
# tar xvf plot3d4.1f.tar
The basic configuration script generation is older so it will not generate a correct Makefile needed for the compile, therefore, run configure and generate the needed file, or edit Makefile.in to pull in what you would like and create a good general Makefile. I found the editing of the Makefile best for me.
# configure
Then edit the Makefile with good paths to Fortran and C, or make sure your have your PATH set correctly. If you set the PATH, then everything goes smoothly, if you choose to edit the Makefile, you need to make sure you pick up all the Makefiles in the source tree.
Edit your LDFLAGS to point to your correct GLUT library, you can look at my building of freeglut, or building of glut 3.7.1, I have tested Plot3D with both implementation successfully. For this build, using freeglut installed in /usr/local/lib
LDFLAGS = -L/usr/local/freeglut/lib -lglut -L/usr/X11/lib -lGLU -lGL -lXmu -lXi -lX11 -lXext -L/usr/lib -lm -lpthread
# gmake
Everything will compile. But, when you go to run the examples, you will find that you will get a core dump and plot3d will fail. So, lets fix it here before running the examples in the next section.
Fixing the core error
# cd src
# vi oglc.c
Edit this file by making the following change:
remove: char *wname ;
insert: char wname[80] ;
remove: wname = “PLOT3D” ;
What is happening ?
Per the manual:
The sprintf() function places output, followed by the null byte (\0), in consecutive bytes starting at s; it is the user's responsibility to ensure that enough storage is available.
The pointer does not allow enough room, designating wname[80] is probably overkill – but, shouldn't have to worry about it being filled, that would be a lot of open windows on your screen !
# gmake
Now we are ready to go.
Installing Plot3D and running an example
The Makefile can be modified to install where you want, by default, even if you set –prefix=<some directory> , the path is not set correctly, I found it easier to run the examples from the directory where I built Plot3D.
Making sure we pick up the freeglut libraries:
# export LD_LIBRARY_PATH=/usr/local/freeglut/lib
# cd demo/wbt
# ../../bin/plot3d
Once in plot3d, and because we are in the wbt directory, use the plot3d command to read a file.
@wbt
This will start up Plot3D, running a nice visual that you can spin and rotate. You can move through the other demos the same way, each coming up and by which you can spin, rotate, zoom in-out, etc.
You can now do some final cleanup by moving the plot3d file and the help file as well (if you want to get help while at the plot3d command line)
