Compiling Tutorial program with Dev-c++

This is a discussion on Compiling Tutorial program with Dev-c++ within the C++ Programming forums, part of the General Programming Boards category; I am trying to compile the first lesson of the tutorials presented at http://nehe.gamedev.net/data/lessons....asp?lesson=02 When I try to compile it ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485

    Compiling Tutorial program with Dev-c++

    I am trying to compile the first lesson of the tutorials presented at http://nehe.gamedev.net/data/lessons....asp?lesson=02

    When I try to compile it I get a lot of feedback from the linker. How should i fix this?
    Here is the file downloaded from their page:
    http://nehe.gamedev.net/data/lessons/devc/lesson02.zip
    Thanks

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >When I try to compile it I get a lot of feedback from the linker.
    Elaborate, please. Most likely you're failing to include the requisite libraries.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485
    I get a lot of errors like this one:
    Code:
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x38):untitled1.cpp: undefined reference to `glViewport@16'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x45):untitled1.cpp: undefined reference to `glMatrixMode@4'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x4d):untitled1.cpp: undefined reference to `glLoadIdentity@0'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x84):untitled1.cpp: undefined reference to `gluPerspective@32'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x91):untitled1.cpp: undefined reference to `glMatrixMode@4'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x99):untitled1.cpp: undefined reference to `glLoadIdentity@0'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0xb7):untitled1.cpp: undefined reference to `glShadeModel@4'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0xd1):untitled1.cpp: undefined reference to `glClearColor@16'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0xe0):untitled1.cpp: undefined reference to `glClearDepth@8'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0xf0):untitled1.cpp: undefined reference to `glEnable@4'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x100):untitled1.cpp: undefined reference to `glDepthFunc@4'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x115):untitled1.cpp: undefined reference to `glHint@8'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x13b):untitled1.cpp: undefined reference to `glClear@4'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x143):untitled1.cpp: undefined reference to `glLoadIdentity@0'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x258):untitled1.cpp: undefined reference to `wglMakeCurrent@8'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x282):untitled1.cpp: undefined reference to `wglDeleteContext@4'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x854):untitled1.cpp: undefined reference to `ChoosePixelFormat@8'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x898):untitled1.cpp: undefined reference to `SetPixelFormat@12'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x8ce):untitled1.cpp: undefined reference to `wglCreateContext@4'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0x914):untitled1.cpp: undefined reference to `wglMakeCurrent@8'
    c:\documents and settings\ole kristian\mine dokumenter\c\untitled1.o(.text+0xc2f):untitled1.cpp: undefined reference to `SwapBuffers@4'
    The list goes on, but the names are allmost the same all the time. Sorry for asking this kind of questions, but I really need your help

  4. #4
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    I'm a Dev-Cpp user, and I think I had the same problems, although it would not be a bad thing to post some of the errors.

    Well, the simplest solution is downloading the DevCpp project & code, that project already has the right configuration.
    You'll also need glaux if the linker is missing it which can be downloaded from DevPaks.org or sourceforge.

  5. #5
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    But that project also contains some weird overhead. It's better to go to Project Options, Parameters, Linker and change it to:

    Code:
    -lglaux -lopengl32 -lglu32
    glaux is of course not necessary but if you use it is important that you link it first, before opengl32, before glu32.

    Hope this helpz

  6. #6
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485
    I added the 3 words, and not most of the linker errors are gone
    Code:
    c:\documents and settings\ole kristian\skrivebord\lesson01\lesson12.o(.text+0x854):lesson12.cpp: undefined reference to `ChoosePixelFormat@8'
    c:\documents and settings\ole kristian\skrivebord\lesson01\lesson12.o(.text+0x898):lesson12.cpp: undefined reference to `SetPixelFormat@12'
    c:\documents and settings\ole kristian\skrivebord\lesson01\lesson12.o(.text+0xc2f):lesson12.cpp: undefined reference to `SwapBuffers@4'
    thats what is left.

    Could you please elaborate abit on what the 3 word really are?

    thanks

  7. #7
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    Those functions aren't OpenGL functions, but I guess Windows functions. Are you sure you set the project type to GUI?

  8. #8
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    Checked it, and they're declarded in wingdi.h.

  9. #9
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485
    Now I have changed my project to GTK+, but this is returned:
    C:\DEV-C_~1\Bin\ld.exe: cannot open -lgtk-1.3: No such file or directory

  10. #10
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    go to Project options, General, Type: and select Win32 GUI. Should be enough.

    The word -lopengl32 tells the linker to include the import library for opengl: an import library helps to communicate with opengl32.dll

  11. #11
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    Are you actually using Dev, and not wxDev? I v never heard of a project type named GTK+...
    Anyways, this should be Win32 GUI as I described above.

  12. #12
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485
    It works not, thank you so much

  13. #13
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158

    Wink

    no problem!
    I'm gonna get some sleep now. Im afraid I need it

  14. #14
    Registered User pronecracker's Avatar
    Join Date
    Oct 2006
    Location
    netherlands
    Posts
    158
    Er... I'm afraid I didn't read your post well. I hope it is a typo and should be īt works now"?
    Otherwise, how can I help you fix the last errors?
    But not now. Maybe tomorrow

  15. #15
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485
    Argh, I know it is wrong and I accualy went back to edit it, but for some reason it did not work.

    It works now thanks to your help. Thank you very much

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

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Replies: 7
    Last Post: 03-05-2008, 01:56 PM
  3. Can somebody tell me why this program isn't compiling?
    By caduardo21 in forum Windows Programming
    Replies: 2
    Last Post: 01-25-2005, 07:40 AM
  4. Help compiling a program
    By jjj93421 in forum C++ Programming
    Replies: 1
    Last Post: 03-08-2004, 05:38 PM
  5. File I/O Tutorial Not Compiling
    By oobootsy1 in forum C++ Programming
    Replies: 10
    Last Post: 03-08-2004, 11:24 AM

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