Issue linking with freeglut.lib Converting existing program ver. 3.2 -> 4.1

Been working with SDK/Toolkit 3.2 and MS Express 2008 for a while. Got some stuff working great, especially one using OpenGL to display some processed imagery. Had a glitch when I run it on newer laptops with 4200M chipsets. Wondering if it required the newest SDK/Toolkit versions, so I decided to take the dive and loaded SDK/Toolkit 4.1 along with MS Express 2010 on my home laptop, away from the work environment. Copied .cpp, .cu and .h files over into new template 2010 solution, and found that some things have changed regarding the Open GL (no glut.h for example, freeglut.h, and need to include rendercheckGL.h seperately now). Got the items to compile, but I get linker errors saying it can’t resolve the GL functions. I’ve got freeglut.lib included in the additional dependencies, just like the bilateral filter demo program, and that seems to compile without a hitch.

Here’s the command coming from MS linker from my ‘translated’ program (using the CUDA template project):

/OUT:“…/…/bin/win32/Release//VideoProcessor. exe” /NOLOGO /LIBPATH:“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\lib\Win32” /LIBPATH:“C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1/C/common/lib/Win32” /LIBPATH:“C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1/shared/lib/Win32” “cudart.lib” “freeglut.lib” “glew32.lib” “cutil32.lib” “shrUtils32.lib” “kernel32.lib” “user32.lib” “gdi32.lib” “winspool.lib” “comdlg32.lib” “advapi32.lib” “shell32.lib” “ole32.lib” “oleaut32.lib” “uuid.lib” “odbc32.lib” “odbccp32.lib” “C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1\C\common\lib\Win32\cutil32.lib” “C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1\shared\lib\Win32\shrUtils32.lib” /MANIFEST /ManifestFile:“Win32/Release/VideoProcessor.exe.intermediate. manifest” /ALLOWISOLATION /MANIFESTUAC:“level=‘asInvoker’ uiAccess=‘false’” /PDB:“C:\Users\Matt\Documents\Visual Studio 2010\bin\win32\Release\VideoProcessor.pdb” /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /PGD:“C:\Users\Matt\Documents\Visual Studio 2010\bin\win32\Release\VideoProcessor.pgd” /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

Here’s the matching one for the bilateralFilter program (which compiles OK):

/OUT:“…/…/bin/win32/Release//bilateralFilter. exe” /NOLOGO /LIBPATH:“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\lib\Win32” /LIBPATH:“…/…/common/lib/Win32” /LIBPATH:“…/…/…/shared/lib/Win32” “cudart.lib” “freeglut.lib” “glew32.lib” “cutil32.lib” “shrUtils32.lib” “kernel32.lib” “user32.lib” “gdi32.lib” “winspool.lib” “comdlg32.lib” “advapi32.lib” “shell32.lib” “ole32.lib” “oleaut32.lib” “uuid.lib” “odbc32.lib” “odbccp32.lib” “C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1\C\common\lib\Win32\cutil32.lib” “C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1\shared\lib\Win32\shrUtils32.lib” /MANIFEST /ManifestFile:“Win32/Release/bilateralFilter.exe.intermediate. manifest” /ALLOWISOLATION /MANIFESTUAC:“level=‘asInvoker’ uiAccess=‘false’” /PDB:“C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1\C\bin\win32\Release\bilateralFilter. pdb” /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /PGD:“C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1\C\bin\win32\Release\bilateralFilter. pgd” /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

Here’s the end of the MS Express Log:

1>display.obj : error LNK2001: unresolved external symbol _glutPostRedisplay

1>display.obj : error LNK2001: unresolved external symbol _glutDisplayFunc

1>display.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0

1>main.obj : error LNK2001: unresolved external symbol _glutMainLoop

1>…/…/bin/win32/Release//VideoProcessor. exe : fatal error LNK1120: 33 unresolved externals

The freeglut.lib file is located in C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.1\C\common\lib\Win32 (notice this path included in the library highlighted in orange above). Any ideas as to why this isn’t resolving?

Another question: Anyone tried to use #define’s to switch the __mul24() operators to ‘*’ for compute >=2.0? Could it be done like this?

#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 200

	#define IMUL(a, b) (a)*(b)

#else

	#define IMUL(a, b) __mul24(a,b)

#endif

This one:

1>display.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0

means that opengl32.lib is not passed in the list of libraries to link with (which I don’t see in your logs)

This one:

1>display.obj : error LNK2001: unresolved external symbol _glutPostRedisplay

means that your object files are referencing a statically compiled freeglut library, but I’m 99% sure your freeglut is a dll, thus the symbols referenced should look like __imp__glutPost…@X . In order to fix that you need to figure out why __declspec(dllimport) is not attached to all functions in freeglut headers.

I guess you can if you remember that your IMUL can be 24bits on some platforms. I’d explicitly state it in the names, and for debug purposes would manually force it to 24 bits on >=20 arch just to catch errors.

Sergey.

Sergeyn, thanks for the advice. Doesn’t freeglut.lib replace the need for opengl32.lib? I don’t see it in the bilateralFilter project that came with the 4.1 SDK, and that compiles and works. I have a freeglut.lib, as can be seen in the directory screen shot below from the LIBPATH highlighted above, and there’s the .dll for it in the executable folder (see attached screen shots,…how can I just paste them in the post?)

Ended up copying the Bilateral Solution and Project files in the 4.1 SDK to another directory, renaming them, and then adding the relevant source/header files, and it compiled fine. Still don’t understand why it couldn’t resolve the GL functions to freeglut.lib.

Going to attempt to do the #ifdef with the IMUL macros and profile that to see if it makes any (discernable) difference for Compute >= 2.0