Jump to content
  • Advertisement
Sign in to follow this  
Revelations

g++ Lesson 1(Linker errors?)

This topic is 4727 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, so I've been playing around with NeHe's lesson 1 using g++ under Windows(MingW). I'm fairly new to c++, and completely new to Windows GUI, so I assume this could be part of the problem. I've tried compiling with -mwindows, -lopengl32, -lglu32, and various combinations of these. I've tried including
 
#pragma comment(lib,"opengl32.lib")
#pragma comment(lib,"glu32.lib")
as well, with no luck. Anyways, on to the error messages!
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x31):main.cpp: undefined re
ference to `glViewport@16'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x40):main.cpp: undefined re
ference to `glMatrixMode@4'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x48):main.cpp: undefined re
ference to `glLoadIdentity@0'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x76):main.cpp: undefined re
ference to `gluPerspective@32'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x85):main.cpp: undefined re
ference to `glMatrixMode@4'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x8d):main.cpp: undefined re
ference to `glLoadIdentity@0'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0xa2):main.cpp: undefined re
ference to `glShadeModel@4'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0xcd):main.cpp: undefined re
ference to `glClearColor@16'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0xda):main.cpp: undefined re
ference to `glClearDepth@8'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0xe9):main.cpp: undefined re
ference to `glEnable@4'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0xf8):main.cpp: undefined re
ference to `glDepthFunc@4'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x10f):main.cpp: undefined r
eference to `glHint@8'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x12c):main.cpp: undefined r
eference to `glClear@4'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x134):main.cpp: undefined r
eference to `glLoadIdentity@0'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x192):main.cpp: undefined r
eference to `wglMakeCurrent@8'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x1cd):main.cpp: undefined r
eference to `wglDeleteContext@4'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x7cd):main.cpp: undefined r
eference to `wglCreateContext@4'
C:\DOCUME~1\JAMESG~1\LOCALS~1\Temp/ccYDaaaa.o(.text+0x82f):main.cpp: undefined r
eference to `wglMakeCurrent@8'

This is using the command line: g++ -lopengl32 -lglu32 main.cpp -o main.exe -mwindows Any and all help is greatly appreciated(when are we going to get GDNet forum search back? I can't be the first with this problem, and the Google GDNet search only gave me the ideas outlined above.) Edit: Because I suck at source tags.

Share this post


Link to post
Share on other sites
Advertisement
try:
g++ main.cpp -lopengl32 -lglu32 -lgdi32 -mwindows -o main.exe

some versions (?) of gcc has some issues with what order stuff is linked. hope this solves your problem...

Share this post


Link to post
Share on other sites
Using your advice I fooled around more with the order of my command line argument and... it works! Thanks, feel stupid for not thinking that one up myself.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!