Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

DirectX Linking Newbie

terrywterryw Member Posts: 1
Hi, I have just started learning DirectX8 and have run into the following linker error : fatal error LNK1104: cannot open file 'libci.lib' It seems that I get this error whenever I include d3dx8.lib. I have checked that this file exists, and the strange thing is that the program has no difficulty linking to d3d8.lib. I have noticed that the same error occurs with many of the files in the SDK. I am using Visual C++ .NET if that is of any help. I am sure that this is probably something very trivial and hoped that somebody would be able to point me in the right direction. Here is the program code:

//////////////////////////////////////////////////////
// SurfaceApp
//////////////////////////////////////////////////////

#include
#include
#include
#include

// Function prototypes.
LRESULT WINAPI WndProc(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam);
void RegisterWindowClass(HINSTANCE hInstance);
void CreateAppWindow(HINSTANCE hInstance);
WPARAM StartMessageLoop();
HRESULT InitFullScreenDirect3D();
void Render();
void CleanUpDirect3D();

// Global variables.
HWND g_hWnd;
IDirect3D8* g_pDirect3D = NULL;
IDirect3DDevice8* g_pDirect3DDevice = NULL;
IDirect3DSurface8* g_pBitmapSurface = NULL;
HRESULT g_hResult = D3D_OK;
char g_szErrorMsg[256];

//////////////////////////////////////////////////////
// WinMain()
//////////////////////////////////////////////////////
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, INT)
{
RegisterWindowClass(hInstance);
CreateAppWindow(hInstance);
ShowWindow(g_hWnd, SW_SHOWDEFAULT);
UpdateWindow(g_hWnd);
HRESULT hResult = InitFullScreenDirect3D();
if (SUCCEEDED(hResult))
WPARAM result = StartMessageLoop();
CleanUpDirect3D();
CloseWindow(g_hWnd);
if (g_hResult != D3D_OK)
DXTRACE_ERR(g_szErrorMsg, g_hResult);
return 0;
}

//////////////////////////////////////////////////////
// WndProc()
//////////////////////////////////////////////////////
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
return 0;

case WM_DESTROY:
PostQuitMessage( 0 );
return 0;

case WM_PAINT:
ValidateRect(g_hWnd, NULL);
return 0;

case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostQuitMessage(WM_QUIT);
break;
}
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}

//////////////////////////////////////////////////////
// RegisterWindowClass()
//////////////////////////////////////////////////////
void RegisterWindowClass(HINSTANCE hInstance)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = (HCURSOR)LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "SurfaceApp";
wc.hIconSm = NULL;

RegisterClassEx(&wc);
}

//////////////////////////////////////////////////////
// CreateAppWindow()
//////////////////////////////////////////////////////
void CreateAppWindow(HINSTANCE hInstance)
{
g_hWnd = CreateWindowEx(
NULL,
"SurfaceApp",
"Direct3D Surface Application",
WS_OVERLAPPEDWINDOW,
100,
100,
648,
514,
GetDesktopWindow(),
NULL,
hInstance,
NULL);
}

//////////////////////////////////////////////////////
// StartMessageLoop()
//////////////////////////////////////////////////////
WPARAM StartMessageLoop()
{
MSG msg;
while(1)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// Use idle time here.
Render();
}
}
return msg.wParam;
}

//////////////////////////////////////////////////////
// InitFullScreenDirect3D()
//////////////////////////////////////////////////////
HRESULT InitFullScreenDirect3D()
{
g_pDirect3D = Direct3DCreate8(D3D_SDK_VERSION);
if (g_pDirect3D == NULL)
{
MessageBox(g_hWnd,
"Couldnt create DirectX object.",
"DirectX Error", MB_OK);
return E_FAIL;
}

HRESULT hResult = g_pDirect3D->CheckDeviceType(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, FALSE);
if (hResult != D3D_OK)
{
MessageBox(g_hWnd,
"Sorry. This program wont
run on your system.",
"DirectX Error", MB_OK);
return E_FAIL;
}
D3DPRESENT_PARAMETERS D3DPresentParams;
ZeroMemory(&D3DPresentParams, sizeof(D3DPRESENT_PARAMETERS));
D3DPresentParams.Windowed = FALSE;
D3DPresentParams.BackBufferCount = 1;
D3DPresentParams.BackBufferWidth = 640;
D3DPresentParams.BackBufferHeight = 480;
D3DPresentParams.BackBufferFormat = D3DFMT_X8R8G8B8;
D3DPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
D3DPresentParams.hDeviceWindow = g_hWnd;
hResult = g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, g_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&D3DPresentParams, &g_pDirect3DDevice);
if (FAILED(hResult))
{
MessageBox(g_hWnd,
"Failed to create Direct3D device.",
"DirectX Error", MB_OK);
return E_FAIL;
}
g_hResult = g_pDirect3DDevice->CreateImageSurface(640, 480,
D3DFMT_X8R8G8B8, &g_pBitmapSurface);
if (FAILED(g_hResult))
{
strcpy(g_szErrorMsg, "Error creating bitmap surface.");
PostQuitMessage(WM_QUIT);
}
g_hResult = D3DXLoadSurfaceFromFile(g_pBitmapSurface, NULL, NULL,
"image.bmp", NULL, D3DX_DEFAULT, 0, NULL);
if (FAILED(g_hResult))
{
strcpy(g_szErrorMsg, "Couldnt load bitmap file.");
PostQuitMessage(WM_QUIT);
}
return D3D_OK;
}

//////////////////////////////////////////////////////
// CleanUpDirect3D()
//////////////////////////////////////////////////////
void CleanUpDirect3D()
{
if (g_pBitmapSurface)
g_pBitmapSurface->Release();
if (g_pDirect3DDevice)
g_pDirect3DDevice->Release();
if (g_pDirect3D)
g_pDirect3D->Release();
}

//////////////////////////////////////////////////////
// Render()
//////////////////////////////////////////////////////
void Render()
{
IDirect3DSurface8* pBackBuffer = NULL;
g_hResult = g_pDirect3DDevice->GetBackBuffer(0,
D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
if (FAILED(g_hResult))
{
strcpy(g_szErrorMsg, "Error getting back buffer.");
PostQuitMessage(WM_QUIT);
}
g_hResult = g_pDirect3DDevice->CopyRects(g_pBitmapSurface,
NULL,0,pBackBuffer,NULL);
if (FAILED(g_hResult))
{
strcpy(g_szErrorMsg, "Error copying image buffer.");
PostQuitMessage(WM_QUIT);
}
g_pDirect3DDevice->Present(NULL, NULL, NULL, NULL);
if (pBackBuffer)
pBackBuffer->Release();
}

Kind regards,
Terry

Comments

  • HEPHEP Member Posts: 113
    This may be a conflict with a default library. Try adding "/NODEFAULT:LIBC" to the compiler options.
  • Q_DivisionQ_Division Member Posts: 1
    Hi

    This appears to be a common problem when using .NET 2003 the lib files are missing, its possible they re renamed in 2003 and dx does not know the new names, the simplest soultion is to copy libci.lib & libcid.lib (the debug ver), from a previous version such as 2002 or VC6.
Sign In or Register to comment.