Jump to content
  • Advertisement
Sign in to follow this  
RedRabbit

DirectX Link Error: libci.lib?

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

I just got to tutorial 3 on Andy Pike's site and all my code is entered...I've added the new d3dx8.lib and winmm.lib files to my command line in visual studio 2003...but I'm getting this error:
DXCube fatal error LNK1104: cannot open file 'libci.lib'


Here's the code....I know it's a lot and it probably has nothing to do with the code but still...here.
#include <d3dx8.h>

LPDIRECT3D8 g_pD3D = NULL;
LPDIRECT3DDEVICE8 g_pD3DDevice = NULL;
LPDIRECT3DVERTEXBUFFER8 g_pVertexBuffer = NULL;	//Buffer that holds vertices

const char g_sWndHandle[] = "DXCube";

struct CUSTOMVERTEX
{
	FLOAT x,y,z,rhw;	//Transformed position for the vertex
	DWORD color;		//Vertex Color
};

#define D3DFVF_CUSTOMVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE)
#define SafeRelease(pObject) if(pObject != NULL) { pObject->Release(); pObject = NULL;}


HRESULT InitializeD3D(HWND hWnd)
{
    //First of all, create the main D3D object. If it is created successfully we
    //should get a pointer to an IDirect3D8 interface.
    g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
	if(FAILED( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION)))
		return E_FAIL;

	//Get the current display mode
    D3DDISPLAYMODE d3ddm;
    if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))
       return E_FAIL;

    //Create a structure to hold the settings for our device
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory(&d3dpp, sizeof(d3dpp));

    //Fill the structure.
    //We want our program to be windowed, and set the back buffer to a format
    //that matches our current display mode
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC;
	d3dpp.BackBufferFormat = d3ddm.Format;

    //Create a Direct3D device.
    if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                   D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice)))
								   return E_FAIL;

	//Turn on Back Face Culling
	g_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);

	//Turn off lighting because our vertices have color
	g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

    return S_OK;
}

HRESULT InitializeVertexBuffer()
{
	VOID* pVertices;

	CUSTOMVERTEX cvVertices[] = 
	{
		//Store the cubes vertices each with x,y,z,rhw,and color values.
		//Make sure they are arranged in clockwise rotation because
		//counter-clockwise faces will be back face culled.
		//We will use three triangle strips: top, sides, bottom.

		//Top Face
        {-5.0f, 5.0f, -5.0f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 0 - Blue
        {-5.0f, 5.0f, 5.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 1 - Red
        {5.0f, 5.0f, -5.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 2 - Red
        {5.0f, 5.0f, 5.0f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 3 - Green

        //Face 1
        {-5.0f, -5.0f, -5.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 4 - Red
        {-5.0f, 5.0f, -5.0f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 5 - Blue
        {5.0f, -5.0f, -5.0f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 6 - Green
        {5.0f, 5.0f, -5.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 7 - Red

        //Face 2
        {5.0f, -5.0f, 5.0f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 8 - Blue
        {5.0f, 5.0f, 5.0f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 9 - Green
        
        //Face 3
        {-5.0f, -5.0f, 5.0f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 10 - Green
        {-5.0f, 5.0f, 5.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 11 - Red

        //Face 4
        {-5.0f, -5.0f, -5.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 12 - Red
        {-5.0f, 5.0f, -5.0f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 13 - Blue

        //Bottom Face
        {5.0f, -5.0f, -5.0f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 14 - Green
        {5.0f, -5.0f, 5.0f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 15 - Blue
        {-5.0f, -5.0f, -5.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 16 - Red
        {-5.0f, -5.0f, 5.0f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 17 - Green
	};

	//Create the buffer from our device (vid card)

	if(FAILED(g_pD3DDevice->CreateVertexBuffer(18 * sizeof(CUSTOMVERTEX),
		0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVertexBuffer)))
		return E_FAIL;

	//Get a pointer to the vertex buffer vertices then lock the vertex buffer
	if(FAILED(g_pVertexBuffer->Lock(0,sizeof(cvVertices), (BYTE**)&pVertices,0)))
		return E_FAIL;

	//Copy our vertices values into the vertex buffer
	memcpy(pVertices, cvVertices, sizeof(cvVertices));

	//Unlock the vertex buffer
	g_pVertexBuffer->Unlock();

	return S_OK;
}

void SetupRotation()
{
	//Here we will rotate our world around the x,y,z axes.
	D3DXMATRIX matWorld, matWorldX, matWorldY, matWorldZ;

	//Create the transformation matrices.
	D3DXMatrixRotationX(&matWorldX,timeGetTime()/400.0f);
	D3DXMatrixRotationY(&matWorldY,timeGetTime()/400.0f);
	D3DXMatrixRotationZ(&matWorldZ,timeGetTime()/400.0f);

	//Combine matrices by multiplication.
	D3DXMatrixMultiply(&matWorld, &matWorldX, &matWorldY);
	D3DXMatrixMultiply(&matWorld, &matWorld, &matWorldZ);

	//Apply the transformation.
	g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);
}

void SetupCamera()
{
	//Here we set the camera up with it's three settings that include position, look-at position
	//and "up direction" (which way in relation to the view angle is UP).
	//We have set:
	//Position: (0,0,-30)
	//Look-At:  (0,0,0)
	//Up Pos:   Y-Axis
	D3DXMATRIX matView;
	D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3(0,0,-30),
								 &D3DXVECTOR3(0,0,0),
								 &D3DXVECTOR3(0,1.0,0));
	g_pD3DDevice->SetTransform(D3DTS_VIEW, &matView);
}

void SetupPerspective()
{
	//Here we set up viewing angle, aspect ratio, and near/far clipping planes.
	D3DXMATRIX matProj;
	D3DXMatrixPerspectiveFovLH(&matProj,D3DX_PI/4,1.0f,1.0f,500.0f);
	g_pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);
}

void Render()
{
    if(g_pD3DDevice == NULL)
    {
        return;
    }

    //Clear the backbuffer to a green color
	 g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );
    
    //Begin the scene
    g_pD3DDevice->BeginScene();

	//Setup our viewing matrices
	SetupRotation();
	SetupCamera();
	SetupPerspective();
    
    //Rendering of our objects
	g_pD3DDevice->SetStreamSource(0,g_pVertexBuffer,sizeof(CUSTOMVERTEX));
    g_pD3DDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);
	g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); //Top
	g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 8); //Sides
	g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 14,2); //Bottom

    //End the scene
    g_pD3DDevice->EndScene();
    
    //Flip the back and front buffers so that whatever has been rendered on the back buffer
    //will now be visible on screen (front buffer).
    g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
}

void CleanUp()
{
    SafeRelease(g_pVertexBuffer);
	SafeRelease(g_pD3DDevice);
	SafeRelease(g_pD3D);
}

void GameLoop()
{
    //Enter the game loop
    MSG msg;
    BOOL fMessage;

    PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
    
    while(msg.message != WM_QUIT)
    {
        fMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);

        if(fMessage)
        {
            //Process message
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else
        {
            //No message to process, so render the current scene
            Render();
        }

    }
}

//The windows message handler
LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        break;
        case WM_KEYUP:
            switch (wParam)
            {
                case VK_ESCAPE:
                    //User has pressed the escape key, so quit
                    DestroyWindow(hWnd);
                    return 0;
                break;
            }
        break;

    }

    return DefWindowProc(hWnd, msg, wParam, lParam);
}

//Application entry point
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
    //Register the window class
    WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L,
                     GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                     "DXCube", NULL};
    RegisterClassEx(&wc);

    //Create the application's window
    HWND hWnd = CreateWindow(g_sWndHandle, g_sWndHandle,
                              WS_OVERLAPPEDWINDOW, 50, 50, 500, 500,
                              GetDesktopWindow(), NULL, wc.hInstance, NULL);

    //Initialize Direct3D
    if(SUCCEEDED(InitializeD3D(hWnd)))
    {
        //Show our window
        ShowWindow(hWnd, SW_SHOWDEFAULT);
        UpdateWindow(hWnd);
		
		//Initialize Vertex Buffer
		if(SUCCEEDED(InitializeVertexBuffer()))
		{
		
        //Start game running: Enter the game loop
        GameLoop();
		}
    }
    
    CleanUp();

    UnregisterClass(g_sWndHandle, wc.hInstance);
    
    return 0;
}

Share this post


Link to post
Share on other sites
Advertisement
Add either "/NODEFAULTLIB:[libci.lib]" (excluding the "") to your project options, or, do it by entering libci.lib into the library to be ignored in Properties->Linker->Input->Ignore Specific Library

Share this post


Link to post
Share on other sites
struct CUSTOMVERTEX
{
FLOAT x,y,z,rhw; //Transformed position for the vertex
DWORD color; //Vertex Color
};

#define D3DFVF_CUSTOMVERTEX ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE)

Hi, I've only had a quick look at your cade, but you have an rhw in your struct & fvf, I think rhw is more for 2d (quads etc), where you want them right at the front. Just try to remove the rhw from your struct and change your fvf to;

#define D3DFVF_CUSTOMVERTEX ( D3DFVF_XYZ | D3DFVF_DIFFUSE)

If you notice the xyz matches your xyz positions and the diffuse matches your diffuse (thats how the codes work).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!