Sign in to follow this  
Fassbinderfan

D3DXGetImageInfoFromFile C++ 2008 Express edition

Recommended Posts

I wrote some DirectX in VC++ 6 int 1990's and am now trying to move to C++2008 CLR. Which may be the biggest mistake of my life. I'm trying to call the D3DXGetImageInfoFromFile function. My String^ has to be converted to a LPCSTR. I thought I did that but am still getting errors. Are there any examples of C++2008 init DirectX out there using that clr? LPDIRECT3D9 g_pDirect3D = NULL; HRESULT hResult; D3DXIMAGE_INFO imageInfo; g_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION); D3DPRESENT_PARAMETERS PresentParams; memset(&PresentParams, 0, sizeof(D3DPRESENT_PARAMETERS)); PresentParams.Windowed = TRUE; PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD; HWND hWnd = GetActiveWindow(); g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &PresentParams, &g_pDirect3D_Device); System::String^ filename2 = "c:\\mi.jpg"; const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(filename2)).ToPointer(); string os = chars; hResult = D3DXGetImageInfoFromFile(os.c_str() , &imageInfo); Test2.obj : error LNK2028: unresolved token (0A000016) "extern "C" long __stdcall D3DXGetImageInfoFromFileA(char const *,struct _D3DXIMAGE_INFO *)" (?D3DXGetImageInfoFromFileA@@$$J18YGJPBDPAU_D3DXIMAGE_INFO@@@Z) referenced in function "private: void __clrcall Test2::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@Test2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) Test2.obj : error LNK2019: unresolved external symbol "extern "C" long __stdcall D3DXGetImageInfoFromFileA(char const *,struct _D3DXIMAGE_INFO *)" (?D3DXGetImageInfoFromFileA@@$$J18YGJPBDPAU_D3DXIMAGE_INFO@@@Z) referenced in function "private: void __clrcall Test2::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@Test2@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)

Share this post


Link to post
Share on other sites
Quote:
Original post by Fassbinderfan


Test2.obj : error LNK2028: unresolved token (0A000016) "extern "C" long __stdcall D3DXGetImageInfoFromFileA(char const *,struct _D3DXIMAGE_INFO *)"


That linker error usually means that the linker couldn't find the function definition anywhere. Oft times, it means you didn't link the dll file or the linker couldn't find it. Sometimes it also means you linked the debug runtime and forgot to change to the debug runtime in the Direct X control console.

Check that D3DX9.dll or D3DX9d.dll are linked.

Share this post


Link to post
Share on other sites
Yeah, the functions that have D3DX in them (most functions with the capitol X in them actually) are from the extension library and need the d3dx9.lib linked in addition to the d3d9.lib file.

If that's all you have linked it would make sense to me that it won't compile. Try linking d3dx9.lib and see if that works. It should be in the same folder as d3d9.lib.

I would also consider using the debug runtime. It helps immensely when your program crashes. It almost takes you to the offending line most of the time.

Hope that helps.

Share this post


Link to post
Share on other sites

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