Linker Nightmares

Started by
11 comments, last by AverageMidget 12 years, 5 months ago
Hello there, this is my first post here in GameInstitute, please be kind to my ignorace :)

I am running on Visual C++ Express with the June 2010 release of DirectX.

My problem:
This declaration:
const DIDATAFORMAT& pointerDataFormatAlias = c_dfDIMouse;
Is causing the following Linker error:
1>eiInput.obj : error LNK2001: unresolved external symbol _c_dfDIMouse

I have included <dinput.h> in the file as well as added it to my header files and included it in my project.

I have added the following paths to the libraries under "Configuration Properties/VC++ Directories/Library Directories"
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86
C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Lib

I have added the following paths to the include directories under "Configuration Properties/VC++ Directories/Library Directories"
C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Include
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86

I have added the relevant library directories under "Linker/General":
C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;C:\Program Files %28x86%29\Microsoft SDKs\Windows\v7.0A\Lib;%(AdditionalLibraryDirectories)

I have added the relevant (as far as I know) libraries themselves under Linker/Input:
dinput8.lib;dxguid.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;ole32.lib;winmm.lib;psapi.lib;d3d9.lib;%(AdditionalDependencies)



Just in case, I'm missing something important, this is the whole Command Line under "Linker" showing all the included libraries:

/OUT:"C:\Users\Pedro\Documents\Visual Studio 2010\Projects\DirectInputScroll\Debug\DirectInputScroll.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64" /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86" /LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib" "dinput8.lib" "dxguid.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "ole32.lib" "winmm.lib" "psapi.lib" "d3d9.lib" "winspool.lib" "advapi32.lib" "shell32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Debug\DirectInputScroll.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Pedro\Documents\Visual Studio 2010\Projects\DirectInputScroll\Debug\DirectInputScroll.pdb" /SUBSYSTEM:WINDOWS /PGD:"C:\Users\Pedro\Documents\Visual Studio 2010\Projects\DirectInputScroll\Debug\DirectInputScroll.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

What the heck is going on?
Advertisement
Try linking to dinput.lib too. Just a suggestion I found after searching in google for 2 min ;)
Try linking to dinput.lib too. Just a suggestion I found after searching in google for 2 min ;)
You need to #define DIRECTINPUT_VERSION as 0x0700 or greater before your #include of dinput.h, otherwise this macro won't be available. Did you not get a "DIRECTINPUT_VERSION not defined" warning when you compiled?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


You need to #define DIRECTINPUT_VERSION as 0x0700 or greater before your #include of dinput.h, otherwise this macro won't be available. Did you not get a "DIRECTINPUT_VERSION not defined" warning when you compiled?


Thank You, now things are starting to make sense....

However, when I #define DIRECTINPUT_VERSION as 0x0700, I realized that my program is actually using structures under the #if(DIRECTINPUT_VERSION >= 0x0800), such as the IDirectInputDevice8 struct.
So, if I define version 0x0700, I get rid of the linker errors, but then I get a ton of compile errors.

It seems that I need to define #define DIRECTINPUT_VERSION as 0x0800 given all the version 8 structures (the version is defined automatically by dinput.h if there is no explicit version define, so I'm back to where I started). However, it seems that for some reason, "extern const DIDATAFORMAT c_dfDIMouse;" in the dinput.h file is not being linked to whichever external file it was defined!

[quote name='mhagain' timestamp='1318843765' post='4873389']
You need to #define DIRECTINPUT_VERSION as 0x0700 or greater before your #include of dinput.h, otherwise this macro won't be available. Did you not get a "DIRECTINPUT_VERSION not defined" warning when you compiled?


Thank You, now things are starting to make sense....

However, when I #define DIRECTINPUT_VERSION as 0x0700, I realized that my program is actually using structures under the #if(DIRECTINPUT_VERSION >= 0x0800), such as the IDirectInputDevice8 struct.
So, if I define version 0x0700, I get rid of the linker errors, but then I get a ton of compile errors.

It seems that I need to define #define DIRECTINPUT_VERSION as 0x0800 given all the version 8 structures (or not define it at all since the version is defined automatically by dinput.h if there is no explicit version define, which apparently was what was going on before).

Apparently, the problem is that "extern const DIDATAFORMAT c_dfDIMouse;" in the dinput.h file is not being linked to whichever external file it was defined! Like I showed in my original post in the linker command line, dxguid.lib is included in the linker.
[/quote]

I attached the whole project, just in case someone wants to take a gander...

Try linking to dinput.lib too. Just a suggestion I found after searching in google for 2 min ;)


Thanks King, but dinput.lib does not exist, only dinput8.lib. Thanks for the suggestion :)
Go to your projects property page and, in the Additional Library Directories list, move C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86 above C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64.

EDIT:
I should explain that a bit better. Your project is set to target 32bit but the linker is finding the 64bit libraries, since they're first in the list.

Go to your projects property page and, in the Additional Library Directories list, move C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86 above C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64.

EDIT:
I should explain that a bit better. Your project is set to target 32bit but the linker is finding the 64bit libraries, since they're first in the list.


Stupid Linker!
Thanks AverageMidget. You guys are awesome!
Stupid Linker!
Thanks AverageMidget. You guys are awesome!


You're welcome.

This topic is closed to new replies.

Advertisement