Sign in to follow this  

Linker Errors

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

Ok so I have two linker errors and I don't seem to understand what exactly they mean.
 
Can somebody shade some light on them:
 
LNK2019: unresolved external symbol "long __stdcall MainWindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?MainWindowProc@@YGJPAUHWND__@@IIJ@Z) referenced in function _WinMain@16
 
I solved the Procedure function: it was an incorrect reference to the window class' lpfnWndProc parameter
 
 
LNK2019: unresolved external symbol _D3D11CreateDeviceAndSwapChain@48 referenced in function "protected: bool __thiscall DXBase::InitDirect3D(void)" (?InitDirect3D@DXBase@@IAE_NXZ)
 
 If code is needed replay and I will upload
Edited by George Anastasov

Share this post


Link to post
Share on other sites

The first error appears (guessing) because you create** a window referencing MainWindowProc as the window procedure but that function doesn't appear (with that signature, anyway) in your code anywhere.
 
The second error appears to result from not linking in d3d11.lib, or your library path is incorrect***. Take a look at the docs for "D3D11CreateDeviceAndSwapChain." At the bottom of the page is listed "Requirements." Under that is a table listing the header you must "#include" and the library you must link.
 
**EDIT: actually, it's likely in the WNDCLASS(EX) struct in your RegisterClass(Ex) call.
 
If you have MainWindowProc in the WNDCLASS, somewhere you must have a function:
 
LRESULT CALLBACK MainWindowProc(HWND, UINT, WPARAM, LPARAM) { ... }
 
with those parameters.
 
***EDIT2: if your library path is incorrect and you have linked d3d11.lib, you'll get a "library not found" type error instead. Sorry about that.

Edited by Buckeye

Share this post


Link to post
Share on other sites

The first error appears (guessing) because you create** a window referencing MainWindowProc as the window procedure but that function doesn't appear (with that signature, anyway) in your code anywhere.
 
The second error appears to result from not linking in d3d11.lib, or your library path is incorrect***. Take a look at the docs for "D3D11CreateDeviceAndSwapChain." At the bottom of the page is listed "Requirements." Under that is a table listing the header you must "#include" and the library you must link.
 
**EDIT: actually, it's likely in the WNDCLASS(EX) struct in your RegisterClass(Ex) call.
 
If you have MainWindowProc in the WNDCLASS, somewhere you must have a function:
 
LRESULT CALLBACK MainWindowProc(HWND, UINT, WPARAM, LPARAM) { ... }
 
with those parameters.
 
***EDIT2: if your library path is incorrect and you have linked d3d11.lib, you'll get a "library not found" type error instead. Sorry about that.

 

Thank you for the quick replay. The problem was coming from the fact that I haven't included the d3d11.lib in the Linker->Input->Additional Dependecies

One quick question: I've seen many people use the '#pragma comment(lib,"<name of library>")'. what is this and why is this needed?

Share this post


Link to post
Share on other sites

#pragma comment(lib...

 

is an alternate way to specify linker options in MSVS. I use that, for instance, in my folder of "reusable" code snippets to remind me what library needs to be linked.

 

Discussed here.

 

EDIT: Thanks for posting the reason/solution for the problem.

Edited by Buckeye

Share this post


Link to post
Share on other sites

This topic is 1183 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this