So, I'm having another problem this time...

I'm on Windows 7 x 64, working with VC++ 2008 Express

I've been working on this DX10 tutorial up to this point where I tried to build my project and got this :

error LNK2019: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 referenced in function "void __cdecl initD3D(struct HWND__ *)" (?initD3D@@YAXPAUHWND__@@@Z)

I don't really know what's going on. I've added the .lib and header files under Project->Linker Dependencies and Project and Solutions->VC++ Directories (where I added library files for x64 and header files) but still nothing.

Please shed your light onto this. I'm so frustrated!

In the same folder as the compiler there is a program named dumpbin.exe. ( use a command prompt do run that file. You might also first have to run vcvars32.bat to set paths) It will list all the public symbols in a library. Run it against the library to see if it contains initD3D function and if it does was it's name mangled the same way your compiler mangled it.

I'm sorry but I'm not quite sure about what to do now?
Run it against which library?

Also initD3D is a user defined function, it's not supposed to be in any of the libraries <d3d10.lib> or <d3dx10.lib> if that's what you mean?

I tried dumpbin.exe d3d10.lib in the command and I get a huge list of ... things?

>>Also initD3D is a user defined functio
I assumed that was in a library. But if not then look at our own code for that function. google found this tutorial that contains that function

>>I tried dumpbin.exe d3d10.lib in the command and I get a huge list of ... things?

Surprise! redirect output to a file, load it with Notepad, and search for what you want.

>>Also initD3D is a user defined functio
I assumed that was in a library. But if not then look at our own code for that function. google found this tutorial that contains that function

>>I tried dumpbin.exe d3d10.lib in the command and I get a huge list of ... things?

Surprise! redirect output to a file, load it with Notepad, and search for what you want.

The tutorial is slightly different than the one I used.

my initD3D is void, his is bool and works for DX8, while I'm working on DX10.

So the initD3D function could not be found in any of the two libraries, d3d10.lib or d3dx10.lib... As I thought, but what does that mean?

I think you have not included the library file name in following path

In Visual Studio.
project properties -> Linker->Input->AdditionalDependencies .

>>but what does that mean?

Search the tutorial that you are using for that function. Must be there somewhere. If not then you are using the wrong tutorial.

I think you have not included the library file name in following path

In Visual Studio.
project properties -> Linker->Input->AdditionalDependencies .

I've included both libraries, d3d10.lib and d3dx10.lib. I wish that was the actual problem though. :sad:

I think you forgot to include the Library file ( .lib) name under following path

ProjectProperties - >Linker-> Input ->Additional Dependencies

This is the function given by the tutorial... and this is exactly what it looks like in my project as well...

// this function initializes and prepares Direct3D for use
void initD3D(HWND hWnd)
{
    DXGI_SWAP_CHAIN_DESC scd;    // create a struct to hold various swap chain information

    ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));    // clear out the struct for use

    scd.BufferCount = 1;    // create two buffers, one for the front, one for the back
    scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;    // use 32-bit color
    scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;    // tell how the chain is to be used
    scd.OutputWindow = hWnd;    // set the window to be used by Direct3D
    scd.SampleDesc.Count = 1;    // set the level of multi-sampling
    scd.SampleDesc.Quality = 0;    // set the quality of multi-sampling
    scd.Windowed = TRUE;    // set to windowed or full-screen mode

    // create a device class and swap chain class using the information in the scd struct
    D3D10CreateDeviceAndSwapChain(NULL,
                                  D3D10_DRIVER_TYPE_HARDWARE,
                                  NULL,
                                  0,
                                  D3D10_SDK_VERSION,
                                  &scd,
                                  &swapchain,
                                  &device);

    // get the address of the back buffer and use it to create the render target
    ID3D10Texture2D* pBackBuffer;
    swapchain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer);
    device->CreateRenderTargetView(pBackBuffer, NULL, &rtv);
    pBackBuffer->Release();

    // set the render target as the back buffer
    device->OMSetRenderTargets(1, &rtv, NULL);

    D3D10_VIEWPORT viewport;    // create a struct to hold the viewport data

    ZeroMemory(&viewport, sizeof(D3D10_VIEWPORT));    // clear out the struct for use

    viewport.TopLeftX = 0;    // set the left to 0
    viewport.TopLeftY = 0;    // set the top to 0
    viewport.Width = 800;    // set the width to the window's width
    viewport.Height = 600;    // set the height to the window's height

    device->RSSetViewports(1, &viewport);    // set the viewport
}

Oh so it's D3D10CreateDeviceAndSwapChain() that can not be foud, not initD3D() -- my mistake. But the same suggestions still apply. According to this microsoft link that function is in D3D10.dll (scroll down to the bottom of the page and it will tell you what library it's in.)

Okay so I'm stuck again! :-D

How am I supposed to add a .dll to my project?
This is weird because the header file specified is already in the include path for my DX 10 SDK... I don't get it

I've added the .lib and header files under Project->Linker Dependencies and Project and Solutions->VC++ Directories (where I added library files for x64 and header files) but still nothing.

As far as I know Visual Studio 2008 Express Edition does not support 64-bit programs. However, by installing the correct Windows SDK you'll get the 64-bit tools enabiling you to compile/link from the command line. And possibly with extra tweaking you even can get the tools to integrate with the IDE.

Anyhow, you might want to ask these kind of questions on a Microsoft's dedicated Visual C++ Express Edition forum.

Note though that you may end up doing a whole lot of installing/uninstalling and reading of the various Readme files to get the things working.

As far as I know Visual Studio 2008 Express Edition does not support 64-bit programs. However, by installing the correct Windows SDK you'll get the 64-bit tools enabiling you to compile/link from the command line.

But my my application is a Win32 application, it shouldn't matter, no?

But my my application is a Win32 application, it shouldn't matter, no?

By reading your first post I got the impression that you are having 64-bit libraries etc and trying to get them working with VC Express, that would not work. Perhaps I understood it all wrong?

By reading your first post I got the impression that you are having 64-bit libraries etc and trying to get them working with VC Express, that would not work. Perhaps I understood it all wrong?

Actually yes, I'm confused myself.

After reading your post about the 64-bit program I realized that my program is actually 32bit.

I went back and changed again the libraries from x64 to x86, which for some reason didn't work at first!
It now goes through compiling but crashes at runtime...but I believe this thread is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.