C++ Standards, Extensions, and Interop


linking error visual studio 2010 when trying to use Direct x 10


Goodday,
I'm trying to make a starting 3D program but i get these errors:
Error 1 error LNK2019: unresolved external symbol __imp__DispatchMessageW#4 referenced in function _wWinMain#16 C:\Users\Sander\Documents\eigen werk\project\test\test\winmain.obj test
Error 2 error LNK2019: unresolved external symbol __imp__TranslateMessage#4 referenced in function _wWinMain#16 C:\Users\Sander\Documents\eigen werk\project\test\test\winmain.obj test
And more like these.
the code that i use is this:
// directX 10 include anders werkt onderstaand niet
#include <d3d10.h>
//nog is nakijken
//rechtermuisklik op u project naam ->property's ->configuration properties->vc ++ directories
//include directorie invullen
//library directorie invullen
//linker->input: additional dependencies, D3D10.lib
#include <d3dx10.h>
// Include the Windows header file, needed for all Windows applications
#include <windows.h>
#include <tchar.h>
// Direct3D global vars
ID3D10Device* pD3DDevice = NULL;
IDXGISwapChain* pSwapChain = NULL;
ID3D10RenderTargetView* pRenderTargetView = NULL;
HINSTANCE hInst; // global handle to hold the application instance
HWND wndHandle; // global variable to hold the window handle
int width = 640;
int height = 480;
// forward declarations
//render fucntion
void Render()
{
if (pD3DDevice != NULL)
{
// clear the target buffer
pD3DDevice->ClearRenderTargetView(pRenderTargetView, D3DXCOLOR
(0.0f, 0.0f, 0.0f, 0.0f));
// All drawing will go here.
// display the next item in the swap chain
pSwapChain->Present(0, 0);
}
}
//Function om de shutdowndirect3D te doen
void ShutdownDirect3D()
{
// release the rendertarget
if (pRenderTargetView)
{
pRenderTargetView->Release();
}
// release the swapchain
if (pSwapChain)
{
pSwapChain->Release();
}
// release the D3D Device
if (pD3DDevice)
{
pD3DDevice->Release();
}
}
bool InitDirect3D(HWND hWnd, int width, int height)
{
// Create the clear the DXGI_SWAP_CHAIN_DESC structure
DXGI_SWAP_CHAIN_DESC swapChainDesc;
ZeroMemory(&swapChainDesc, sizeof(swapChainDesc));
// Fill in the needed values
swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Width = width;
swapChainDesc.BufferDesc.Height = height;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.OutputWindow = hWnd;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Windowed = TRUE;
// Create the D3D device and the swap chain
HRESULT hr = D3D10CreateDeviceAndSwapChain(NULL,
D3D10_DRIVER_TYPE_REFERENCE,
NULL,
0,
D3D10_SDK_VERSION,
&swapChainDesc,
&pSwapChain,
&pD3DDevice);
// Error checking. Make sure the device was created
if (hr != S_OK)
{
return false;
}
// Get the back buffer from the swapchain
ID3D10Texture2D *pBackBuffer;
hr = pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)
&pBackBuffer);
if (hr != S_OK)
{
return false;
}
// create the render target view
hr = pD3DDevice->CreateRenderTargetView(pBackBuffer, NULL,
&pRenderTargetView);
// release the back buffer
pBackBuffer->Release();
// Make sure the render target view was created successfully
if (hr != S_OK)
{
return false;
}
// set the render target
pD3DDevice->OMSetRenderTargets(1, &pRenderTargetView, NULL);
// create and set the viewport
D3D10_VIEWPORT viewPort;
viewPort.Width = width;
viewPort.Height = height;
viewPort.MinDepth = 0.0f;
viewPort.MaxDepth = 1.0f;
viewPort.TopLeftX = 0;
viewPort.TopLeftY = 0;
pD3DDevice->RSSetViewports(1, &viewPort);
return true;
}
bool InitWindow( HINSTANCE hInstance, int width, int height );
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
// This is winmain, the main entry point for Windows applications
int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow )
{
// Initialize the window
if ( !InitWindow( hInstance, width, height ) )
{
return false;
}
// called after creating the window
if ( !InitDirect3D( wndHandle, width, height) )
{
return 0;
}
// main message loop:
MSG msg = {0};
while (WM_QUIT != msg.message)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == TRUE)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Additional game logic can be called from here
}
Render();
return (int) msg.wParam;
}
/*******************************************************************
* InitWindow
* Inits and creates and main app window
* Inputs - application instance - HINSTANCE
Window width - int
Window height - int
* Outputs - true if successful, false if failed - bool
*******************************************************************/
bool InitWindow(HINSTANCE hInstance, int width, int height)
{
WNDCLASSEX wcex;
// Fill in the WNDCLASSEX structure. This describes how the window
// will look to the system
wcex.cbSize = sizeof(WNDCLASSEX); // the size of the structure
wcex.style = CS_HREDRAW | CS_VREDRAW; // the class style
wcex.lpfnWndProc = (WNDPROC)WndProc; // the window procedure callback
wcex.cbClsExtra = 0; // extra bytes to allocate for this class
wcex.cbWndExtra = 0; // extra bytes to allocate for this instance
wcex.hInstance = hInstance; // handle to the application instance
wcex.hIcon = 0; // icon to associate with the application
wcex.hCursor = LoadCursor(NULL, IDC_ARROW); // the default cursor to use
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); // the background color
wcex.lpszMenuName = NULL; // the resource name for the menu
wcex.lpszClassName = TEXT("DirectXExample"); // the class name being created
wcex.hIconSm = 0; // the handle to the small icon
RegisterClassEx(&wcex);
// Resize the window
RECT rect = { 0, 0, width, height };
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
// create the window from the class above
wndHandle = CreateWindow(TEXT("DirectXExample"),
TEXT("DirectXExample"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
rect.right - rect.left,
rect.bottom - rect.top,
NULL,
NULL,
hInstance,
NULL);
if (!wndHandle)
{
return false;
}
// Display the window on the screen
ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}
/*******************************************************************
* WndProc
* The main window procedure for the application
* Inputs - application window handle - HWND
message sent to the window - UINT
wParam of the message being sent - WPARAM
lParam of the message being sent - LPARAM
* Outputs - LRESULT
*******************************************************************/
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// Check any available messages from the queue
switch (message)
{
// Allow the user to press the Escape key to end the application
case WM_KEYDOWN:
switch(wParam)
{
// Check if the user hit the Escape key
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
break;
// The user hit the close button, close the application
case WM_DESTROY:
PostQuitMessage(0);
break;
}
// Always return the message to the default window procedure for further processing
return DefWindowProc(hWnd, message, wParam, lParam);
}
I include the inlclude of sdk and included te lib of sdk. And in de linker-> input i inserted the D3D10.lib.
I have searched the internet, but nothing i found worked i would be so happy if you can help me thx.
sakke-maft wrote:
I'm trying to make a starting 3D program but i get these errors:
Error 1 error LNK2019: unresolved external symbol __imp__DispatchMessageW#4 referenced in function _wWinMain#16
Link with User32.lib
Igor Tandetnik
Buddy you are doing it wrong while using d3d10.h and d3dx10.h you have to add d3d10.lib as well as d3dx10.lib. Both Library files are required to according to your program. This should work when I started using Directx 10 I got the
same error too :D. But according to the errors it seems you are missing the Windows SDK library link. May be when you where adding the d3d10.lib you might have overwritten it on the previous Library dependencies. It happens some times its annoying too.
Mine library link dependencies looks like this:
kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);d3d10.lib;d3dx10.lib;
sakke-maft wrote:
I'm trying to make a starting 3D program but i get these errors:
Error 1 error LNK2019: unresolved external symbol __imp__DispatchMessageW#4 referenced in function _wWinMain#16
Link with User32.lib
Igor Tandetnik
Buddy you are doing it wrong while using d3d10.h and d3dx10.h you have to add d3d10.lib as well as d3dx10.lib. Both Library files are required to according to your program. This should work when I started using Directx 10 I got the
same error too :D. But according to the errors it seems you are missing the Windows SDK library link. May be when you where adding the d3d10.lib you might have overwritten it on the previous Library dependencies. It happens some times its annoying too.
Mine library link dependencies looks like this:
kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);d3d10.lib;d3dx10.lib;

Related Links

Using Direct2D how would i fill a font with a gradient or radial brush?
Beginner c++ question--Bitwise enumerations
int i = 2; Is this the Assingment Operator here ?
How do you define a template class's constructor outside the class
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
How to use another variable from another Form in VisualC++
Accessing a member through a pointer
How to copy one char* array into another one?
definition of dllimport static data member not allowed
LockFile problem
mspdbsrv.exe consuming over 1.4GB
Visual c++, how to find a file in certain folder and print its name?
abstract classes in cpp
Convert float to String
LNK1104 error - DEBUG vs. RELEASE
recvfrom on a udp socket does not receive in release build/mode

Categories

MSDN
Visual Studio Languages
Visual Studio Development
Windows and Windows ph...
Apps for Office and Sh...
DevLabs
HealthVault
JScript and Scripting
Machine Translation an...
Windows Server
Orchard
Bing Maps
Silverlight
Archived Forums C-D
Archived Forums E-H
Archived Forums SA-SM
Archived Forums Visual...
Kinect for Windows SDKs
Suggestions and Feedba...
Visual C++
Visual Studio Editor
MSBuild
Visual Studio Diagnost...
Submitting and Publish...
Application Compatibil...
Windows Desktop Develo...
Media Foundation Devel...
Windows Desktop Debugging
Windows Desktop Ribbon...
Developing Apps for Of...
SharePoint 2013 - Setu...
SharePoint 2010 - Gene...
SharePoint 2010 - Deve...
SharePoint 2010 - Setu...
Cloud Services (Web an...
Azure Networking (DNS,...
Azure Virtual Machines
Azure Automation
Azure Scripting and Co...
Azure Key Vault
Azure Batch
Azure Data Catalog
Azure IoT Hub
Azure Disk Encryption
Azure Data Lake Analyt...
Azure Time Series Insi...
Publishing Apps for th...
Team Foundation Server...
Team Foundation Server...
Visual FoxPro General
The Architect Role
WCF Data Services
ADO.NET Entity Framewo...
LINQ to SQL
Code Contracts
Microsoft Translator U...
Small Basic
SyncFx - SyncToy-File ...
Microsoft Robotics - C...
SQL Server Search
Standard 2009: Tools
Standard 7: Components...
Standard 7: Tools
Standard 7: Servicing ...
Windows Embedded 8.1 I...
SQL Server 2012 Spatia...
SQL Server 2012 Analys...
SQL Server 2012 Report...
SQL Server 2012 Databa...
Windows Live Writer: D...
CRM Development
WebsitePanel - Support
Developing for the Mob...
The Samsung Windows De...
Bing Maps General
SharePoint Server Prot...
Exchange Server Protocols
Microsoft Atlas APIs: ...
Microsoft Lync Persist...
Hosting and Streaming ...
Programming Silverligh...
MVVM / ViewModel Patte...
Accessing Web Services...
Expression Design
Retired SharePoint Col...
.NET Framework Network...
.NET Platform Architec...
.NET Remoting and Runt...
ASMX Web Services and ...
Building Development a...
Azure Startups
Building Windows Store...
Commerce Server 2002 a...
Core Coding Experience...
Developer Documentatio...
ISV Community Days
JScript for the .NET F...
Microsoft Security Dev...
Multimap API Developme...
Office Development wit...
Office Live Small Busi...
Performance Counters f...
Phoenix
Popfly General Discussion
Search Server: Develop...
Search Server: Federation
SyncFx - Feedback [Rea...
SyncFx - Technical Dis...
SQL Server 2014 Self-S...
SQL Server 2014 Analys...
SQL Server 2014 Master...
Team Foundation Server...
Visual Basic Interop a...
Visual Studio Team Sys...
Visual Studio Web Perf...
Visual Studio Online "...
Web Development in Vis...
Windows SideShow Devel...
Windows Workflow Found...
Working with Data and ...
XNA Game Studio Express
SQL Server 2016 Preview

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile