PDA

View Full Version : Working with OpenGL in linux



Facade
06-05-2000, 08:53 PM
I am some what confused with OpenGL and linux. First of all, why is there no OpenGL for linux. There is the SI from sgi and a software renderer from MESA (I think it is software because of how slow it goes) I have not seen a real implementation of OpenGL but I saw a post some where that nVida is going to release there OpenGL icd soon. Anyways off to my real question
I have voodoo3. I want to develop OpenGL app's. That means I have to (like to) get the XF86 4.0 . This is what I did to try to install it
1.Download all necessary RPMS
tdfx_dri-4.0.00-1.i386.rpm
tdfx_drm-1.0-1.src.rpm
Glide_V3-DRI-3.10-6.i386.rpm
2.Became root.
3.Create a backup of my XF86Config file
cp /etc/X11/XF86Config /etc/X11/XF86Config.backup
4.Install Glide 3x.
rpm -Uvh Glide_V3-DRI-3.10-6.i386.rpm
5.Install the DRI enabled X Server
rpm -Uvh tdfx_dri-4.0.00-1.i386.rpm
6.Build the new device driver.
rpm --rebuild tdfx_drm-1.0-1.src.rpm
7.Install the new device driver. I can not get to work, using this command
rpm -Uvh /usr/src/redhat/RPMS/i386/tdfx_drm-1.0-1.i386.rpm
i get this error
modprobe: Can't locate module tdfx.o
execution of script failed

every thing else compiles, installs fine. Except that command

Any one see what I am doing wrong. Give me advice or anything, please do.
thanks
David

compr0@hotmail.com

jmeinhorn
06-06-2000, 04:24 AM
The first thing your going to want to do is if you actually want to do development is you need to install the development module as well. If you just look at the instructions again you will see it farther down. The next thing you need to do is get a couple of extra files from this page. http://dri.sourceforge.net/resources/resources.html

The rpms he gave you are work fine except they leave one broken link(libGLU.so) and don't worry about the tdfx.o error it trivial. So what you do now is get the XF86Config.voodoo3 from the linux I gave you and replace your regular X config with it(you will need to rename it to XF86Config). Next you will want to get the libGLU.so.1.2 and libglut.so.3.7 and replace the existing ones. Also get the header files and replace the corresponding ones as well. Make sure you download the gears demo as well. If you installed everything correctly you should get about 75fps otherwise you will get about 60. You might need to remove the old symbolic links from libGLU.so.1.2 and libglut.so.3.7 and relink them to the new libriaries you just installed. Just give me an email if ya have more questions.

Facade
06-06-2000, 03:25 PM
I got X to work, but I got some problems
When I run in 1600x1200 i have a gray bar at the left of my screen that does not take up much space, but I would like it to not be there. I think it has something to do with my refresh rate which is running at 65hz. Before I installed the new Xserver I could get 1600x1200 32bit at 75 hz. I know that 32 bit's is not possible but I would like to run at least 1600x1200 16bbp@70hz.
and when i run the gears demo it says permission denied. while I am in root and on a regular account
I also downloaded the source and tryed to compile doing this
gcc gears.c -I/usr/X11R6/include -L/usr/local/lib -L/usr/X11R6/lib -lglut -lGLU -lGL -o program
and got these errors
/tmp/ccduDuo3.o: In function `gear':
/tmp/ccduDuo3.o(.text+0x103): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x12b): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x17a): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1a2): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1fd): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x225): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x287): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x2c2): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x393): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x3be): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x416): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x447): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x4b1): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x4f4): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x55c): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x59d): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x661): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x68f): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x6e6): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x714): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x78a): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x7cb): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x822): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x850): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x944): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x985): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x9f1): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xa34): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xa8e): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xabf): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xb16): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xb44): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xbf2): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xc20): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xc77): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xca5): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xcde): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xd06): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xd36): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xd5e): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xd8d): undefined reference to `sqrt'
/tmp/ccduDuo3.o(.text+0xdfc): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xe2d): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xe87): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xeb8): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xee7): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xf04): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xf66): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xfa9): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1015): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1058): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x10a1): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x10de): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x111e): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x115b): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x11d8): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1219): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1283): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x12c4): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x12f3): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1310): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1360): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1389): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x13db): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1404): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1499): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x14b8): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1509): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1537): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x158c): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x15ba): undefined reference to `cos'
/usr/X11R6/lib/libglut.so: undefined reference to `XGetExtensionVersion'
/usr/X11R6/lib/libglut.so: undefined reference to `XFreeDeviceList'
/usr/X11R6/lib/libglut.so: undefined reference to `XQueryDeviceState'
/usr/X11R6/lib/libglut.so: undefined reference to `XListInputDevices'
/usr/X11R6/lib/libglut.so: undefined reference to `XFreeDeviceState'
/usr/X11R6/lib/libglut.so: undefined reference to `XOpenDevice'
/usr/X11R6/lib/libglut.so: undefined reference to `XmuLookupStandardColormap'
/usr/X11R6/lib/libglut.so: undefined reference to `XSelectExtensionEvent'
collect2: ld returned 1 exit status

if you see a problem please respond, or get in touch with me
David

compr0@hotmail.com

jmeinhorn
06-07-2000, 05:25 AM
When I installed the additional libriaries I put them in the /usr/X11R6/include and /usr/X11R6/lib respectively instead of /usr/local/ then you should be able to use this command line to compile your gears demo.
gcc gears.c -I/usr/X11R6/include -L/usr/X11R6/lib -lglut -lGLU -lGL -o gears.
The error you are getting looks like a linking problem so you probably trying to link against the wrong libraries. In order to run the demo you downloaded you might need to change the permissions on the file to make it executable. Try "chmod +x gears" and give it another whirl. The gray bar that comes on the left side of your screen is a bug that was in the code and there really isn't much you can do about that until they release the next version of X which should be around the 15th. You could try to get the lastest stuff from cvs and compile it yourself, but that isn't a minor undertaking.

06-25-2000, 09:36 PM
assuming your Include and Library directory's are correct? try this...

gcc -I/usr/X11R6/include -L/usr/local/lib -L/usr/X11R6/lib -o gears gears.c -lGLU -lGL -lglut -lXmu -lXi -lXext -lX11 -lm

the undefind math fucntions (sin, cos, sqrt etc. etc. etc.) from the link come from -lm and glut needs all the X11 librarys to be linked correctly ie. -lXmu -lXi -lXext -lX11

hope this helps
luke
-------


Originally posted by Facade:
I got X to work, but I got some problems
When I run in 1600x1200 i have a gray bar at the left of my screen that does not take up much space, but I would like it to not be there. I think it has something to do with my refresh rate which is running at 65hz. Before I installed the new Xserver I could get 1600x1200 32bit at 75 hz. I know that 32 bit's is not possible but I would like to run at least 1600x1200 16bbp@70hz.
and when i run the gears demo it says permission denied. while I am in root and on a regular account
I also downloaded the source and tryed to compile doing this
gcc gears.c -I/usr/X11R6/include -L/usr/local/lib -L/usr/X11R6/lib -lglut -lGLU -lGL -o program
and got these errors
/tmp/ccduDuo3.o: In function `gear':
/tmp/ccduDuo3.o(.text+0x103): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x12b): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x17a): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1a2): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1fd): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x225): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x287): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x2c2): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x393): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x3be): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x416): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x447): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x4b1): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x4f4): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x55c): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x59d): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x661): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x68f): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x6e6): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x714): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x78a): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x7cb): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x822): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x850): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x944): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x985): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x9f1): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xa34): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xa8e): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xabf): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xb16): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xb44): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xbf2): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xc20): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xc77): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xca5): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xcde): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xd06): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xd36): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xd5e): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xd8d): undefined reference to `sqrt'
/tmp/ccduDuo3.o(.text+0xdfc): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xe2d): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xe87): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xeb8): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xee7): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xf04): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0xf66): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0xfa9): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1015): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1058): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x10a1): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x10de): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x111e): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x115b): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x11d8): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1219): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1283): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x12c4): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x12f3): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1310): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1360): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1389): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x13db): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1404): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1499): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x14b8): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x1509): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x1537): undefined reference to `cos'
/tmp/ccduDuo3.o(.text+0x158c): undefined reference to `sin'
/tmp/ccduDuo3.o(.text+0x15ba): undefined reference to `cos'
/usr/X11R6/lib/libglut.so: undefined reference to `XGetExtensionVersion'
/usr/X11R6/lib/libglut.so: undefined reference to `XFreeDeviceList'
/usr/X11R6/lib/libglut.so: undefined reference to `XQueryDeviceState'
/usr/X11R6/lib/libglut.so: undefined reference to `XListInputDevices'
/usr/X11R6/lib/libglut.so: undefined reference to `XFreeDeviceState'
/usr/X11R6/lib/libglut.so: undefined reference to `XOpenDevice'
/usr/X11R6/lib/libglut.so: undefined reference to `XmuLookupStandardColormap'
/usr/X11R6/lib/libglut.so: undefined reference to `XSelectExtensionEvent'
collect2: ld returned 1 exit status

if you see a problem please respond, or get in touch with me
David

compr0@hotmail.com

hilbert
12-07-2001, 11:37 PM
I have wrote a bash script to increase the development of openGL. save the text to a file cc.sh and change it to executable by chmod a+x cc.sh Then type ./cc.sh --help to see how to use it to include OpenGL library properly. It supports OpenGL 3.5, 4.0.
If you are interested in 3D Math visualization , visit my projects : http://sourceforge.net/projects/mathdev/

#!/bin/bash
# The shell script was created to compile the c++ source file *.cpp, *.c, *.cxx
# , and debug using the GNU debuggin tools such as gdb and gprof
if [ -z "$1" ];
then
echo -e "Missing argument 1\nusage: $0 [ filename without .cpp ] [ OPTIONS ]
Type $0 --help for command line options"
exit
fi

# message of --help
helpMsg="usage: $0 [ filename without .cpp ] [ OPTIONS ]\n
The bash script accepts the following options :\n
\t -lFilename\n
\t\t include the library while linking.\n
\t\t This -l option is different from the -l in gcc compiler.\n
\t\t It does not search standard system directories but only\n
\t\t the full filename specified explicitly. For example,\n
\t\t cc.sh -lmy.o includes my.o while linking. -lmy does not\n
\t\t search the file libmy.a\n
\t -p\n
\t\t include the PLIB library, http://plib.sourceforge.net/\n
\n
\t --Mesa4Dir=DIR\n
\t\t change the default directory of Mesa 3D 4.0 from\n
\t\t /usr/local/Mesa-4.0 to DIR\n
\n
\t -m4\n
\t\t compile and link using the gcc options for Mesa 3D 4.0\n
\n
\t --Mesa35Dir=DIR\n
\t\t change the default directory of Mesa 3D 3.5 from\n
\t\t /usr/local/Mesa35 to DIR\n
\n
\t -m35\n
\t\t compile and link using the gcc options for Mesa 3D 3.5\n
\n
\t -glui\n
\t\t include the GLUI library, http://www.cs.unc.edu/~rademach/glui/\n
\n
\t -d\n
\t\t add debugging options for gcc compiler"

compile=
# command to compile
cc="c++"
# compile options
cflags="-W -Wall"
link=
# command to link
ccld="$cc"
# libraries to include
libs=
# link options
ldflags="-W -Wall"

# start the specific options
# debugging options
db="-a -g -pg"

# directories of Mesa 3D library
Mesa4Dir="/usr/local/Mesa-4.0"
Mesa35Dir="/usr/local/Mesa35"

# loop through all the arguments to determine the directory of Library
for arg in $@ ;
do
case $arg in
# print help message and quit
--help)
echo -e $helpMsg
exit
;;
# find the directory of Mesa 3D 4.0
--Mesa4Dir=*)
Mesa4Dir="`echo $arg | sed -e 's/--Mesa4Dir=//'`"
;;
# find the directory of Mesa 3D 3.5
--Mesa35Dir=*)
Mesa35Dir="`echo $arg | sed -e 's/--Mesa35Dir=//'`"
;;
esac
done

# options for Mesa 3D 4.0
# options to compile source code using Mesa 3D 4.0
cflagsM4="-DHAVE_CONFIG_H -I. -I$Mesa4Dir -I$Mesa4Dir/include -DNDEBUG -g -Wall -fomit-frame-pointer -ffast-math -fstrict-aliasing -malign-loops=2 -malign-jumps=2 -malign-functions=2 -D_REENTRANT -DPTHREADS -c"
# options to link Mesa 3D 4.0 library
ldflagsM4="-g -Wall -fomit-frame-pointer -ffast-math -fstrict-aliasing -malign-loops=2 -malign-jumps=2 -malign-functions=2 -D_REENTRANT -DPTHREADS"
# options to include Mesa 3D 4.0 library
libsM4="$Mesa4Dir/src-glut/libglut.la $Mesa4Dir/si-glu/libGLU.la $Mesa4Dir/src/libGL.la -lm"

# command to link Mesa 3D library
ldM="/bin/sh $Mesa4Dir/libtool --mode=link c++"

# options for GLUI
GLuiDir="/usr/local/Mesa-4.0/src-glui/lib/"
# options to include the GLUI library
libsGLUI="-L$GLuiDir -lglui"

# options to include PLIB library
libsPLIB="-lglut -lGLU -lGL -L/usr/X11/lib -lX11 -lXext -lXmu -lm -lplibssg -lplibsl -lplibpu -lplibfnt -lplibsg -lplibul -lplibnet"

# options for Mesa 3D 3.5
# options to compile source code using Mesa 3D 3.5
cflagsM35="-DHAVE_CONFIG_H -I. -I$Mesa35Dir -I$Mesa35Dir/include -DNDEBUG -I$Mesa35Dir/util -I$Mesa35Dir/src/X86 -g -Wall -ffast-math -fexpensive-optimizations -fstrict-aliasing -malign-loops=2 -malign-jumps=2 -malign-functions=2 -D_REENTRANT -DPTHREADS -c"
# options to link Mesa 3D 3.5 library
ldflagsM35="-g -Wall -ffast-math -fstrict-aliasing -malign-loops=2 -malign-jumps=2 -malign-functions=2 -D_REENTRANT -DPTHREADS"
libsM35="$Mesa35Dir/si-glu/.libs/libGLU.so -L$Mesa35Dir/src $Mesa35Dir/src/.libs/libGL.so -L/usr/X11R6/lib $Mesa35Dir/src-glut/.libs/libglut.so -L$Mesa35Dir/si-glu $Mesa35Dir/src/.libs/libGL.so $Mesa35Dir/src/OSmesa/.libs/libMesaOS.so -lSM -lICE -lXmu -lXext -lXi -lX11 -lpthread -lm -Wl,--rpath -Wl,$Mesa35Dir/si-glu/.libs -Wl,--rpath -Wl,$Mesa35Dir/src/.libs -Wl,--rpath -Wl,$Mesa35Dir/src-glut/.libs -Wl,--rpath -Wl,$Mesa35Dir/src/OSmesa/.libs"

# loop through all the arguments
for arg in $@ ;
do
case $arg in
# case of debugging option
-d)
cflags="$cflags $db"
ldflags="$ldflags $db"
;;
# case for Mesa 3D 4.0
-m4)
cflags="$cflags $cflagsM4"
ldflags="$ldflags $ldflagsM4"
libs="$libs $libsM4"
ccld="$ldM"
;;
# case for inclusion of PLIB
-p)
libs="$libs $libsPLIB"
;;
# case for inclusion of GLUI library
-glui)
libs="$libs $libsGLUI"
;;
# case for Mesa 3D 3.5
-m35)
cflags="$cflags $cflagsM35"
ldflags="$ldflags $ldflagsM35"
libs="$libs $libsM35"
ccld="$ldM"
;;
# case for inclusion of addition library files
-l*)
libs="$libs `echo $arg | sed -e 's/-l//'`"
;;
esac
done

# check if the $1.o exists to prevent it from being overwritten
if [ -f $1.o ];
then
echo -e "Attempted to overwrite $1.o\nScript exits"
exit
fi

# start to compile
compile="$cc $cflags -c"
link="$ccld $ldflags $libs"
if [ -f $1.cpp ];
then
$compile $1.cpp
# case of the .c file
elif [ -f $1.c ];
then
$compile $1.c
# case of the .cxx file
elif [ -f $1.cxx ];
then
$compile $1.cxx
else
echo -e "$1.c, $1.cpp, or $1.cxx file not found"
fi

# start to link
if [ -f $1.o ];
then
$link -o $1 $1.o
# move or remove the object file after linking
if [ -d ./.libs ]
then
mv --force $1.o ./.libs/
else
rm --force $1.o
fi
fi