Jump to content
  • Advertisement
Sign in to follow this  
PedroMachin

Linker Nightmares

This topic is 2490 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

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?

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
Hidden

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!

Share this post


Link to post

[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...

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!