Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Using GLUT on XWindows

  1. #1
    Guest

    Using GLUT on XWindows

    When compiling a program using gcc with switches -lGL, -lGLw etc, an error message is displayed saying that libraries were not found ... Please Help

  2. #2
    Guest

    Re: Using GLUT on XWindows

    What the heck is libGLw ?? I compile w/
    -lGL -lGLU -lglut -L/path/to/GL/libraries -I/path/to/GL/headers
    and have no problems ... also if you are using Mesa for your OpenGL implementation you _might_ need to use:
    -lMesaGL -lMesaGLU -lglut
    or similar

  3. #3

    Re: Using GLUT on XWindows

    I have wrote a bash script to increase the development of openGL. The script helps people to compile and link Mesa 3D library.
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •