PDA

View Full Version : using texture linking problem in vc++2005 express


abousoft
01-01-2007, 09:49 AM
Hey all

I'm new to opengl and I'm trying to do a small texture example but when I tried nehe's example it didn't work so I got another example that compiled but failed to link , I'm using vc++ express 2005 and I added all the libraries(glut.lib ,glut32.lib , glaux.lib) to the 'C:\Program Files\Microsoft Visual Studio 8\VC\lib' so I need to know what have I missed , this is the code


#include "stdafx.h"

#include <windows.h> // Header File For Windows
#include <math.h> // Math Library Header File
#include <stdio.h> // Header File For Standard Input/Output
#include <glut.h>
#include <glaux.h>

AUX_RGBImageRec* LoadBMP(char *Filename) // Loads A Bitmap Image
{

FILE *File=NULL; // File Handle

if (!Filename) // Make Sure A Filename Was Given
{
return NULL; // If Not Return NULL
}

File=fopen(Filename,"r"); // Check To See If The File Exists

if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}
return NULL; // If Load Failed Return NULL

}


and here is the linking error:

Linking...
Texture.obj : error LNK2019: unresolved external symbol _auxDIBImageLoadW@4 referenced in function "struct _AUX_RGBImageRec * __cdecl LoadBMP(char *)" (?LoadBMP@@YAPAU_AUX_RGBImageRec@@PAD@Z)
C:\Documents and Settings\Abousafy\My Documents\Visual Studio 2005\Projects\Texture\Debug\Texture.exe : fatal error LNK1120: 1 unresolved externals

any ideas are welcomed cuz I really need to use textures in a project

Reedbeta
01-01-2007, 12:14 PM
Hey abousoft, when you post code please enclose it in [ code ] [ /code ] tags so it'll be formatted nicely. I've added them for you in the message above.

As for the linker error, it's indicating that it can't find the function auxDIBImageLoad. This sounds like the same problem as before, have you actually added the libraries to the project? Putting them in the lib directory isn't enough.

abousoft
01-01-2007, 01:13 PM
hey reedbeta , sorry I didn't know about that code tag
anyways before your reply I have tried to do the same thing as I have done with the openal code but once I added the GLAUX.lib to the project linker and then I compile I found that it generates more linking errors as shown below so any other ideas???:

glaux.lib(tkimage.obj) : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function _RawImageGetData@8
glaux.lib(tkdib.obj) : error LNK2001: unresolved external symbol __imp__MessageBoxA@16
glaux.lib(tk.obj) : error LNK2001: unresolved external symbol __imp__MessageBoxA@16
glaux.lib(tkimage.obj) : error LNK2019: unresolved external symbol __imp__GetFocus@0 referenced in function _RawImageGetData@8
glaux.lib(tkdib.obj) : error LNK2001: unresolved external symbol __imp__GetFocus@0
glaux.lib(tk.obj) : error LNK2001: unresolved external symbol __imp__GetFocus@0
glaux.lib(tkimage.obj) : error LNK2019: unresolved external symbol __imp__wsprintfA referenced in function _RawImageOpenAW@8
glaux.lib(tkdib.obj) : error LNK2001: unresolved external symbol __imp__wsprintfA
glaux.lib(tkdib.obj) : error LNK2019: unresolved external symbol __imp__DeleteObject@4 referenced in function _tkDIBImageLoadAW@8
glaux.lib(tk.obj) : error LNK2001: unresolved external symbol __imp__DeleteObject@4
glaux.lib(tkdib.obj) : error LNK2019: unresolved external symbol __imp__DeleteDC@4 referenced in function _tkDIBImageLoadAW@8
glaux.lib(tkdib.obj) : error LNK2019: unresolved external symbol __imp__GdiFlush@0 referenced in function _tkDIBImageLoadAW@8
glaux.lib(tkdib.obj) : error LNK2019: unresolved external symbol __imp__SetDIBits@28 referenced in function _tkDIBImageLoadAW@8
glaux.lib(tkdib.obj) : error LNK2019: unresolved external symbol __imp__SelectObject@8 referenced in function _tkDIBImageLoadAW@8
glaux.lib(tkdib.obj) : error LNK2019: unresolved external symbol __imp__CreateDIBSection@24 referenced in function _tkDIBImageLoadAW@8
glaux.lib(tkdib.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleDC@4 referenced in function _tkDIBImageLoadAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__DispatchMessageA@4 referenced in function _tkExec@0
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetMessageA@16 referenced in function _tkExec@0
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function _tkExec@0
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function _tkExec@0
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetClientRect@8 referenced in function _tkExec@0
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetSystemMetrics@4 referenced in function _tkInitPosition@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__SwapBuffers@4 referenced in function _tkSwapBuffers@0
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetCursorPos@4 referenced in function _tkGetMouseLoc@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__PostMessageA@16 referenced in function _ReleaseStaticEntries@4
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__SetSystemPaletteUse@8 referenced in function _ReleaseStaticEntries@4
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__SetSysColors@12 referenced in function _ReleaseStaticEntries@4
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetPaletteEntries@16 referenced in function _UpdateStaticMapping@4
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetStockObject@4 referenced in function _UpdateStaticMapping@4
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RealizePalette@4 referenced in function _FlushPalette@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__SelectPalette@12 referenced in function _FlushPalette@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__CreatePalette@4 referenced in function _FlushPalette@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__ChoosePixelFormat@8 referenced in function _FindBestPixelFormat@12
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__DescribePixelFormat@16 referenced in function _FindExactPixelFormat@12
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__InvalidateRect@12 referenced in function _ForceRedraw@4
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetPixelFormat@4 referenced in function _PixelFormatDescriptorFromDc@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__DestroyWindow@4 referenced in function _DestroyThisWindow@4
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetSysColor@4 referenced in function _GrabStaticEntries@4
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__UnrealizeObject@4 referenced in function _RealizePaletteNow@12
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__ReleaseDC@8 referenced in function _CleanUp@0
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__SetPixelFormat@12 referenced in function _FindPixelFormat@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__SetPaletteEntries@16 referenced in function _tkSetOneColor@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__DefWindowProcA@16 referenced in function _tkWndProc@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__SetCapture@4 referenced in function _tkWndProc@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__ReleaseCapture@0 referenced in function _tkWndProc@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetKeyState@4 referenced in function _tkWndProc@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__EndPaint@8 referenced in function _tkWndProc@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__BeginPaint@8 referenced in function _tkWndProc@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__PostQuitMessage@4 referenced in function _tkWndProc@16
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__ShowWindow@8 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetDC@4 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__GetWindowRect@8 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__CreateWindowExW@48 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__AdjustWindowRect@12 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegisterClassA@4 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegisterClassW@4 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__LoadCursorA@8 referenced in function _tkInitWindowAW@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__LoadIconA@8 referenced in function _tkInitWindowAW@8
C:\Documents and Settings\Abousafy\My Documents\Visual Studio 2005\Projects\Texture\Debug\Texture.exe : fatal error LNK1120: 56 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Abousafy\My Documents\Visual Studio 2005\Projects\Texture\Texture\Debug\BuildLog.htm"
Texture - 63 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Reedbeta
01-01-2007, 01:22 PM
Those are all Windows functions. It looks like you're not linking in the Windows libraries. Note that if you're using glaux.lib you should also link in glu32.lib and opengl32.lib, the main OpenGL and GLU libraries. As for the Windows libraries, they ought to be linked in automatically; I don't know why they aren't being in this case - something must be messed up in the project settings. Make sure you haven't checked "ignore default libraries" or anything like that, and if all else fails, create a brand new project and add all your source files and the OpenGL libraries to it.

abousoft
01-01-2007, 01:39 PM
hey reed I have tried to make a new project and link all the libraries again but nothing was changed , any other ideas ?

Reedbeta
01-01-2007, 01:43 PM
Well, try adding kernel32.lib, user32.lib, and gdi32.lib to the linker inputs...I think those three contain the majority of the Windows API, but there may be more libraries needed, I'm not sure.

abousoft
01-01-2007, 01:51 PM
hey reed I have added the 3 libraries and the linking errors where minimizes to 4 only and here they are:


TextureTrial1.cpp
Linking...
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20 referenced in function _GetRegistrySysColors@8
C:\Documents and Settings\Abousafy\My Documents\Visual Studio 2005\Projects\TextureTrial1\Debug\TextureTrial1.ex e : fatal error LNK1120: 3 unresolved externals
Build log was saved at "file://c:\Documents and Settings\Abousafy\My Documents\Visual Studio 2005\Projects\TextureTrial1\TextureTrial1\Debug\Bu ildLog.htm"
TextureTrial1 - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

so any ideas what other libraries are needed??

Kenneth Gorking
01-01-2007, 02:04 PM
This is a simple question that you can figure out for yourself, by looking it up at msdn...

abousoft
01-01-2007, 02:29 PM
hey reed
I linked advapi.lib and it finally it worked
thanks for the help