Find the answer to your Linux question:
Results 1 to 5 of 5
Hello as with many, I'm new to Linux but old to programming. I've set the system up, installed mesa-6.3.2, followed setup instructions,used make install which has put the lib files ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2005
    Posts
    21

    help in compile with openGL


    Hello as with many, I'm new to Linux but old to programming. I've set the system up, installed mesa-6.3.2, followed setup instructions,used make install which has put the lib files (which have installed into /usr/local/lib and headers to /usr/local/include/GL (is this right)).

    I tried to compile using a simple make main in my projects directory. This contains a simple hello world programme. This works so I changed it to printf("hello world %d", GL_PROJECTION) and added #include <GL/gl.h>, this works so I know it's using the header file.
    Next I added a glMatrixMode(GL_PROJECTION); to test if the libary is being linked in. This produces

    g++ main.cc -o main
    /tmp/ccif6YAV.o(.text+0x25): In function 'main':
    main.cc:undefined reference to 'glMatrixmode'
    collect2: ld returned 1 exit status
    main:*** [main] Error1

    I've tried adding it to the path using
    export PATH=/usr/local/lib:/usr/local/include/GL:/usr/bin (for compiler)

    but get the same result, can anyone advise

  2. #2
    Linux Newbie
    Join Date
    Nov 2004
    Location
    New York
    Posts
    150
    The PATH variable is just for finding executables entered from a shell. You probably want something like CPATH or LIBRARY_PATH, or maybe LDFLAGS. Try passing the location of the library directory to gcc with -L/usr/local/lib, and the name of the library as -lGL.
    \"Nifty News Fifty: When news breaks, we give you the pieces.\" - Sluggy Freelance

  3. #3
    Just Joined!
    Join Date
    Sep 2005
    Posts
    21
    Thanks that worked

    g++ -o main main.cc -I/ysr/local/include -L/usr/local/lib -IGL


    Don't know why files aren't going into usr/lib

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Nov 2004
    Location
    New York
    Posts
    150
    Well that was lucky - I made a typo, I meant to type -L/usr/lib. Glad it worked for you though. You should add /usr/local/lib and /usr/local/include to your compiler's default search paths so you don't have to use the flags every time, but I'm not sure how to do that - my distro probably had it set like that automatically.
    \"Nifty News Fifty: When news breaks, we give you the pieces.\" - Sluggy Freelance

  6. #5
    Just Joined!
    Join Date
    Sep 2005
    Posts
    21
    problem for some reason my version of linux PATH doesn't point to usr/lib ect by default, but I've just found out you can add change paths by entering ect/profile and editing the default paths. Bit like edit paths in windows

Posting Permissions

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