Link to home
Start Free TrialLog in
Avatar of xersoft
xersoft

asked on

fatal error LNK1120: 1 unresolved externals

This should be an easy question.

I'm using C++6.0 and DirectX 7.0 with the SDK.

I'm trying to do this:
hRet = DirectDrawCreate(NULL, &pDD, NULL);

and then compile.
I get the following error:
--------------------Configuration: Project - Win32 Debug--------------------
Linking...
ProjectView.obj : error LNK2001: unresolved external symbol _DirectDrawCreate@12
Debug/Project.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Project.exe - 2 error(s), 0 warning(s)

What do I do about this? I have found a question with a similer problem and it said that I press alt-f7 and enter some information. I do not however, have this information.

Thanks for the help!
ASKER CERTIFIED SOLUTION
Avatar of fl0yd
fl0yd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xersoft
xersoft

ASKER

That did change the error message somewhat. Heres what I got now.

--------------------Configuration: Project - Win32 Debug--------------------
Compiling...
ProjectView.cpp
Linking...
ProjectView.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw4
Debug/Project.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Creating browse info file...

Project.exe - 2 error(s), 0 warning(s)

anyideas on this one? And what exactly am I doing in the project settings? Is there away to just make C++ find the stuff it needs when it needs it so I don't have to do this for each project?
Avatar of xersoft

ASKER

hmmmm looks like the bad line was
hRet = pDD->QueryInterface(IID_IDirectDraw4, (LPVOID *) & lpDD);

and I don't know what it does, I commented it out and it seems to compile fine. I guess you did answer the question that I asked, Thanks for the help.
The line of code
hRet = pDD->QueryInterface(IID_IDirectDraw4, (LPVOID *) & lpDD);
asks your currently retrieved direct draw interface pointer (pDD) whether it also exposes an IDirectDraw4-interface. If so, it is created and a pointer to it is stored in lpDD. In that case hRet is greater than 0, otherwise it is below 0 - you can use
if( SUCCEEDED( hRet ) ) ... or
if( FAILED( hRet ) ) ...
to check for success/failure. I'm not at my machine right now, so I don't have access to DX7-documentation. As far as I know the refiid for direct draw in dx7 is IID_IDirectDraw7 so you shouldn't try to query for v4, unless there is a reason to do so.
The reason for the linker error is that my last post was partially wrong: replace 'guids.lib' by 'dxguid.lib' and you should be fine. Sorry about that...