Problems with OpenGL(glut) in C++

This is a discussion on Problems with OpenGL(glut) in C++ within the Windows Programming forums, part of the Platform Specific Boards category; Okay, first of all...please don't bother posting if you're just going to say "www.google.com" or "search", because i have tried ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    17

    Problems with OpenGL(glut) in C++

    Okay, first of all...please don't bother posting if you're just going to say "www.google.com" or "search", because i have tried those and either way they don't help.
    Now to my problem...can someone explain a step by step tutorial that makes a program that uses glut in Open GL (such as glutinitwindow). Everything i have searched hasn't worked for me, so maybe it's that i am missing something. Having said that don't expect me to know ANYTHING about projects, linkers, etc... because i think i AM missing something. If you need to know what kind of errors I am getting they are usually either a "[build error]" or a "[linker error]".

    thx, i appreciate it

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    what is the error?

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    17
    ex-(except like 5 of these) [linker error] undefine reference to glut*********. The link was one that i had already looked at...

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    17
    if this helps I'm also using Dev C++ v 4.9.9.2. Also the program i wrote contains nothing except the necessary things (libraries)- that is no calls to the "errors" even.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    are you linking with GLUT?

  7. #7
    Registered User
    Join Date
    Nov 2007
    Posts
    17
    #include<GL/glut.h>

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Abood View Post
    #include<GL/glut.h>
    That's a header file. You need somethin like "-lglut" or such on your "link" command too. [I don't know what the right library name is, but it's along those lines].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Nov 2007
    Posts
    17
    yep did -lglut also...trust me i spent like 4 hours looking at sites (yes im frustrated).

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Well, undefined references mean that the linker can't find those functions. That in turn usually means that there's something wrong with the list of libraries that you are including. But if you think that all you are doing is exactly right, I guess it's time to look at everything very closely again.

    Perhaps also google or post the EXACT error messages. It may be something that someone else recognizes with that particular message.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Nov 2007
    Posts
    17
    [Linker error] undefined reference to '_glutInitWithExit'
    [Linker error] undefined reference to '_glutCreateWindowWithExit'
    [Linker error] undefined reference to '_glutCreateMenuWithExit'
    [Linker error] undefined reference to '_imp__glEnable'
    ld return 1 exit status
    [Build Error] ["2-Setting] Error 1
    The problem could be in the project as i am unsure as to if im doing THAT part right. I basically made a project with all the linkers included and made a file with the libraries + compile & run...

  12. #12
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    where did you put the libraries in your IDE?

  13. #13
    Registered User
    Join Date
    Nov 2007
    Posts
    17
    i put the libraries in the library folder where all the other .h files and then in a subfolder named GL

  14. #14
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    the h files go in the include folder, not in the library folder. like include/stdio.h and lib/libc.a

    libraries and header files are different things. header files just contain some information about the libraries.

    So in order to use a library, you need to do two thing: include the header file, and link wih the library.

    like this:
    Code:
    #include < mylib.h>
    
    int main()
    { blah blah return 0; }
    Code:
    gcc t.c -lmylib
    the -lmylib makes the compiler use the code from libmylib.a and use it with your program to make the program file.

    So you need to include the glut header file (I think you've done that) and then make sure your IDE has the glut library in the linker settings so that it will know what the heck the header file is talking about.

    Also, you don't have to manually put anything in the GL header file directory. How did you install GLUT and GL?

  15. #15
    Registered User
    Join Date
    Nov 2007
    Posts
    17
    yes sorry i was confused. Correction- the include folder. And about the linker settings, is that the same thing as project options->parameters->linker? Because if it is i have -lglut in there but maybe -lglut isnt even the library...

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 03:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  3. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 05:48 PM
  4. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 09:19 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21