OpenGL Compilation Killing Me - Nvidia

Hey,

I’m porting an app I’ve been working on for a project from Linux over to Windows (to see if the Nvidia drivers for OpenCL which are failing terribly on Ubuntu Linux work right in Windows).

I installed every Nvidia SDK I can think of - I can find include headers, I CAN’T find the libraries (.lib) for a path to add to the linker to link…

I need ONE function out of OpenGL (and it’s part of GLU), and that’s simply gluOrtho2D. I’m doing a 2 stage compilation link via command line. The compilation happens okay but the link obviously fails with:

main1.obj : error LNK2019: unresolved external symbol _gluOrtho2D referenced in function _init
output.exe : fatal error LNK1120: 1 unresolved externals

A pretty straight forward linker message, I don’t have the right OpenGL libs pointed to in the linker path. Right now my linker paths are:

C:\Users\UN\AppData\Local\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.2\OpenCL\common\lib\Win32
C:\Users\UN\AppData\Local\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.2\GLUT"
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib"

The second path (GLUT) is simply a dir I made in the already existing Nvidia dir to dump the GLUT libs (yeah, it’s hack-ish, I know).

Platform is Win7 x64 (though I’m not using 64 bit libs as far as I know), card is a GTX280. Just can’t find the location to link against the Nvidia OpenGL libs. Plenty of headers though…

Much help is appreciated, this is my first time running OpenGL, OpenCL, GLUT, or Glu on Windows, I typically use Linux or OS X.

TIA!

EDIT:
Yeah, and I realize the 3rd one is the pre-packaged with Windows OpenGL 1.1 lib, which is why it isn’t working (no GLU, I believe).

Also, forgot to mention, the compiler libraries I’m noting in the linker line are:

OpenCL.lib
OpenGL32.lib

(should probably just be OpenGL.lib but I can’t find it anywhere).

GLU is not part of OpenGL. It’s a supplementary library that sits on top of OpenGL, not a component. As such, you need to link to it specifically. On Windows, that would be GLU32.lib

However, I’m concerned about this line:

I need ONE function out of OpenGL (and it’s part of GLU)

How can you need one function from OpenGL, a function that relies on other OpenGL functions (gluOrtho2D almost certainly just calls glOrtho)? Even moreso when this function only modifies OpenGL state and therefore does nothing that is visible without either rendering something or querying OpenGL state, either of which requires other OpenGL functions.

[QUOTE=Alfonse Reinheart;1241573]GLU is not part of OpenGL. It’s a supplementary library that sits on top of OpenGL, not a component. As such, you need to link to it specifically. On Windows, that would be GLU32.lib

However, I’m concerned about this line:

How can you need one function from OpenGL, a function that relies on other OpenGL functions (gluOrtho2D almost certainly just calls glOrtho)? Even moreso when this function only modifies OpenGL state and therefore does nothing that is visible without either rendering something or querying OpenGL state, either of which requires other OpenGL functions.[/QUOTE]

I thought GLU was rolled into OpenGL after a certain version? Either way, I can’t find OpenGL nor GLU, I was under the impression that I’d get both using the proprietary nvidia drivers. Adding GLU32.lib didn’t do it, I’m guessing I’m still missing a path …

I mis-spoke about the quoted part, I’m using a OpenGL to draw vertices. As such, I’m using the following OpenGL functions. I meant I needed one more function, that the rest link in fine, the OpenGL functions I’m using are listed below, but apparently I’m not linking against the GLU lib correctly as that isn’t.

glClearColor();
glLoadIdentity();
gluOrtho2D();
glViewport();
glVertex2i(GL_POINTS)
glBegin()/glEnd()

The others do not have linker errors, but I’m guessing that’s because it’s using the out-dated OpenGL version that’s packaged with Windows that I’m linked to? I was under the impression that the Nvidia drivers will bring in the latest OpenGL libs which are supported by my gfx card.

Gahhh, I can’t even think straight none-the-less talk straight, tired.

Synopsis:
I’m rambling & tired. Point is: I need the GLU lib, I have a lib called “GlU32.lib” (the L isn’t capped) inside the Win SDK link location I have listed above, but that’s not doing it for me. I get the same error message.

I’ve tried both adding GlU32.lib and GLU32.lib as linker libs and while they don’t give me errors (they’re found), I still get the same linker error for missing gluOrtho2D which is above. I thought I should get a new lib with GLU in it from Nvidia?

Sorry about the lack of coherent thoughts…

glu32.dll is not coded by nVidia. It comes from Microsoft.
As for whether it is capitalized or not, it does not matter on the Windows platform. Windows is not like *nix.

As for glu32.lib, this should come with your IDE and not nVidia. If it does not come with your IDE, then you can get it from Mesa3D (www.mesa3d.org).
I think it is quite unusual for a IDE to not provide opengl32.lib and glu32.lib.
Are you using Visual C++ 2010 Express or something else?

I’m not using any IDE’s, notepad++ doesn’t come bundled with glu. It needs to compile on windows but need not be tied to that terribly unusable VS MS uses. I do have VS 2010 installed, though, so whatever libs the ide should include should still exist somewhere. I’ll look for the glu files when I get home, and check out the mesa site. What’s the diff between lib and DLL, just static vs dynamic linked libs such as .a vs .so? I’ll look for both, but I believe I need the .lib for static linking. Pretty new to windows dev here. I shouldn’t need an ide, though, I’m invoking cl via the cli. I do have vs2010 installed though so any libs it brought should exist, I linked against the win sdk dir as shown above.

Thanks.

Try and be patient, there tends to be an assumption on Windows that all builds happen in Visual Studio.
Getting compiler and linker paths can be tricky as a consequence of that.
I’d expect glu32.lib (just the export lib for glu32.dll) to be part of the Visual Studio install, worth using Cygwin find to track it down…

  • Nigel

[QUOTE=nigels;1241596]Try and be patient, there tends to be an assumption on Windows that all builds happen in Visual Studio.
Getting compiler and linker paths can be tricky as a consequence of that.
I’d expect glu32.lib (just the export lib for glu32.dll) to be part of the Visual Studio install, worth using Cygwin find to track it down…

  • Nigel[/QUOTE]

Okay, I’ll look now for a lib for it.

Yeah, not sure why VS is very popular. It’s terrible without visual assist at the very least, IMHO. I’d take slick edit, QT Creator (even for non-QT apps, it’s great), or even eclipse way before I use VS by choice :-. Hate getting stuff in SLN format :(.

EDIT:
So I just double checked, result is the same as I have in the synopsis 4 posts up (post #3). I have one file called “GLU32.lib” on my computer, it exists in the Win SDK link which I have the location specified as a link path as shown in post #1, and I specify GLU32.lib on the command line as a library to link against, ie.:

/LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib" GLU32.lib

Still same error :(. I’m guessing that that GLU lib came in with VS 2010. Though CL isn’t finding the gluOrtho2D function in there :(.

glu32.lib does exist in “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib” unless you’ve messed up the installation somehow. But for gluOrtho2D, there is actually no need whatsoever to use that function - you can just use glOrtho instead and get the same result.

Despite all of this, a standard installation of the MS development tools is perfectly capable of building OpenGL programs as-is and without any further config needed, so you need to look in your own setup for the cause of this problem.

Regarding not using the IDE, you’re missing out on the best debugging tools available to mankind at the moment, so that’s a very poor choice, but it’s your choice so I’ll drop it there.

[QUOTE=mhagain;1241599]glu32.lib does exist in “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib” unless you’ve messed up the installation somehow. But for gluOrtho2D, there is actually no need whatsoever to use that function - you can just use glOrtho instead and get the same result.

Despite all of this, a standard installation of the MS development tools is perfectly capable of building OpenGL programs as-is and without any further config needed, so you need to look in your own setup for the cause of this problem.

Regarding not using the IDE, you’re missing out on the best debugging tools available to mankind at the moment, so that’s a very poor choice, but it’s your choice so I’ll drop it there.[/QUOTE]

The GLU32.lib does exist inside the folder that you said, which is also the folder I’m specifying as a link path dir. I’m aware that MS comes with OpenGL version 1.1 (or some low version) pre-packaged. Though as far as I understand it, I should be getting the latest versions with my graphics card drivers, in this case, Nvidia drivers. I acquired GLUT from their website, the latest non-beta (3.6). I wanted to use the most up-to-date OpenGL versions as well.

Switching to glOrtho fixed things in that I was able to compile and my program works fine, but I’m still curious for future reference as to:
A) Where I can find the latest OpenGL/GLU libs, as I thought they were supposed to come in with the Nvidia SDK…and I can’t find them.
B) Why specifying the path to GLU32.lib and specifying it in the link path isn’t working


As for VS…yes, the debugger is nice, though IMO it ends there. The rest of the IDE is pretty crappy for what’s supposed to be the creme de la creme of IDEs, IMHO, and is easily overtaken by most complete IDE’s on the market (such as XCode or QT Creator). I’m writing a program on the GPU, Visual Studio does little (nothing) to help me there, nor can any other main IDE debugger. I rather write batch scripts or bash scripts because it makes things more portable. I don’t like relying on a specific IDE to determine the compilation of my code, I rather it just work. I have the sad memories of working at a company who binded all their projects to VS, which was fine…until VS was updated and all of a sudden solutions didn’t build right anymore and the software teams were in turmoil for a bit. It’s not my cup of tea, I would rather use scripted compilation and developers can then use whatever editor floats their boat without relying on the development process I used.

The best debugging tools” - for desktop applications, which is where VS’s debugger shines, I actually have to look towards GDB. GDB with a graphical front end (like what XCode uses for C/C++ debugging) is better than the VS C/C++ debugger, IMO.

But yeah, that’s all I’ll say on the subject of IDE’s as well, but point entail, the SW is being run on the GPU, this is just framework issues, so VS, nor any standard CPU application debugger can really help.

You might want to look at freeglut (http://freeglut.sourceforge.net/) in the future. It is more up to date than glut and supports various IDE’s. If you switch platforms a lot VS is a bit of a pain but if you are only on Windows there is not much point swimming against the stream.

As I said in my previous post, I downloaded the latest version of GLUT off of their website (the one you linked). It was OpenGL and GLU that I’m trying to get the latest versions for.

I do switch platforms quite frequently, so yeah, not all the time on Windows.

There are none. What you’ll get in the NV SDK are NV-specific libs, but unless you’re happy at the prospect of your program running on NV hardware only you’d be well-advised to avoid them. For general vendor-agnostic programming there are no official latest libs, so you need to use the extension-loading mechanism to access higher level functionality. The general advice you’ll get is that life is too short to do this by hand so you should use something like GLEW instead.

Hrm, not sure I’m following. Yeah, for extension handling I would use something like GLEW, but I’m just talking about the OpenGL and GLU libraries in and of themselves.

In any of the Nvidia SDK’s I got NO OpenGL or GLU libs, not NV-specific nor otherwise.

I’m not entirely sure why it’s so hard to find them…most Linux distributions have a relatively recent version of BOTH (OpenGL and GLU) in the repos…but for Windows, a MUCH more common system, I can’t find shit except the ancient (1.1?) version that comes with MS? And that’s all I can ever use unless I want to bind it to one card manu? Why isn’t it this way in Linux?

Kind of confused here…

This gets repeated so many times, that we explain it in the Wiki.
http://www.opengl.org/wiki/FAQ#How_Does_It_Work_On_Windows.3F

also
http://www.opengl.org/wiki/FAQ#Where_can_I_download.3F

also
http://www.opengl.org/wiki/Getting_started

The bottom line is, opengl32.lib has never been updated (the latest version is from 1995). It is for GL 1.1.
If you want to access higher versions, use a library such as GLEW. GLEW isn’t just for extensions. It is for getting function pointers for EVERYTHING beyond GL 1.1.

As for GLU, I already mentioned to get it from www.mesa3d.org.
They provide the latest version which is 1.3 (probably from 1995 as well).

Ok, so before this turns into a 10 pages discussion, just get yourself an extension loader and enjoy GL 4.2 or whatever it is that your video card supports.
As for GLU, it is old crap but if you insist, www.mesa3d.org and compile it yourself.
As for GLUT, once again, it is old crap. Use freeGLUT. http://freeglut.sourceforge.net

[QUOTE=V-man;1241623]This gets repeated so many times, that we explain it in the Wiki.
http://www.opengl.org/wiki/FAQ#How_Does_It_Work_On_Windows.3F

also
http://www.opengl.org/wiki/FAQ#Where_can_I_download.3F

also
http://www.opengl.org/wiki/Getting_started

The bottom line is, opengl32.lib has never been updated (the latest version is from 1995). It is for GL 1.1.
If you want to access higher versions, use a library such as GLEW. GLEW isn’t just for extensions. It is for getting function pointers for EVERYTHING beyond GL 1.1.

As for GLU, I already mentioned to get it from www.mesa3d.org.
They provide the latest version which is 1.3 (probably from 1995 as well).

Ok, so before this turns into a 10 pages discussion, just get yourself an extension loader and enjoy GL 4.2 or whatever it is that your video card supports.
As for GLU, it is old crap but if you insist, www.mesa3d.org and compile it yourself.
As for GLUT, once again, it is old crap. Use freeGLUT. http://freeglut.sourceforge.net[/QUOTE]

Ah, I didn’t know GLEW did more than just extension handling. So if I’m understanding this correctly, with the most up to date version of GLEW, and the regular Windows provided OpenGL 1.1, I’ll have full access to everything in OpenGL that my gfx card supports?

GLU is old crap? I’m not entirely sure what it does, but I know it has some primitives (spheres and such) as well as other functions that are ‘on top of’ OpenGL. I’ll look more into its functionality, I thought it was necessary. The version I downloaded I believe is freeGLUT (3.6).

That first FAQ link explained a lot, I know it’s a specification, not a lib, which is why I was trying to find the one produced by Nvidia. Though it seems the opengl32 that comes with Windows will take care of that. I’ll try out some version checking.

EDIT:
I’m pretty new to compiling OpenGL in general, none-the-less in Windows where everything is twice as hard.

GLU is old crap? I’m not entirely sure what it does, but I know it has some primitives (spheres and such) as well as other functions that are ‘on top of’ OpenGL. I’ll look more into its functionality, I thought it was necessary. The version I downloaded I believe is freeGLUT (3.6).

GLUT is not GLU; they have nothing to do with one another. Also, FreeGLUT’s highest version is 2.8, so if you’re using 3.6, you’re not using FreeGLUT; you’re using the old GLUT that you should never be using.

Yeah, I never said OpenGL and GLUT were the same. It’s GLU and OpenGL that I thought got packaged together at some point. I’ll have to look into more about GLU when I get a chance, because I really don’t get its ties with OpenGL, but moving that one function out of there.

Oh, nvm, I see where you got that from, thought the functions were gluSolidTorus… and gluSphere, etc. - haven’t used those functions in ages.

Yeah, I have to do more reading to GLU’s place in all this, I never really paid attention, just linked against it.

I’ll switch over to free glut, though, thanks.

GL is a low level library for sending commands to the GPU (basically). It is on the same level as Direct3D.

GLU is another library that adds a few functions such gluOrtho2D, gluSphere, gluTesselator. It makes use of GL, but is is ancient compared to GL 4.2 core.
For example, gluSphere makes calls to glBegin, glVertex, glNormal, glTexCoord, glEnd, which are considered deprecated in modern GL.
gluOrtho2D uses glOrtho, which is also deprecated.

GLU is on the same level as D3DX, the Direct3D Utility library. But at least D3DX has kept up with Direct3D.

There are other libraries, created by people at home, that makes GLU obsolete.

In your case, you are only using gluOrtho2D, possibly the most useless function in GLU.
All it does is call glOrtho and sets znear to -1.0 and zfar to 1.0. Obviously, you can do that yourself.

… and completely removed from the core profile (and GL 3.1 IIRC).

[QUOTE=V-man;1241660]GL is a low level library for sending commands to the GPU (basically). It is on the same level as Direct3D.

GLU is another library that adds a few functions such gluOrtho2D, gluSphere, gluTesselator. It makes use of GL, but is is ancient compared to GL 4.2 core.
For example, gluSphere makes calls to glBegin, glVertex, glNormal, glTexCoord, glEnd, which are considered deprecated in modern GL.
gluOrtho2D uses glOrtho, which is also deprecated.

GLU is on the same level as D3DX, the Direct3D Utility library. But at least D3DX has kept up with Direct3D.

There are other libraries, created by people at home, that makes GLU obsolete.[/quote]

Gotcha, I learned this stuff as ‘necessary’ - I didn’t realize it was just utility functions. Thanks for the clarification

[QUOTE=V-man;1241660]In your case, you are only using gluOrtho2D, possibly the most useless function in GLU.
All it does is call glOrtho and sets znear to -1.0 and zfar to 1.0. Obviously, you can do that yourself.[/QUOTE]

Yeah, that’s exactly what I changed to get it to work without GLU.

Don’t think it was 3.1. I’m using glVertex in my code and it’s OpenGL version 3.2 via glGetString. The reason I’m using such an old function is simply because I only need to set some colors here and there (manually). Also, I don’t know the newer OpenGL stuff, learned the old stuff, that’s all I know :(.