Linkerfehler



  • Hi,
    Mein linker zeigt einen fehler an,aber ich diesen nicht lösen.
    Kann mir jemand helfen???

    [code]
    Quellcode:

    //Age of the dragon
    # include <windows.h>
    # include <stdio.h>
    # include <stdarg.h>
    # include <commctrl.h>
    # include <d3dx8.h>
    # include <dsound.h>
    # include <dinput.h>
    # include "dsutil.h"
    # include "d3dfont.h"

    HWND hWnd;
    LPDIRECT3D8 d3d;
    LPDIRECT3DDEVICE8 device;
    D3DPRESENT_PARAMETERS d3dpp;

    // Prototyp der Callback-Funktion
    LRESULT CALLBACK WindowProc (HWND hWnd, UINT message,
    WPARAM wParam, LPARAM lParam);
    //Direct X
    class directx
    {
    public:
    LPDIRECT3D8 d3d;
    LPDIRECT3DDEVICE8 device;
    D3DPRESENT_PARAMETERS d3dpp;

    int init();
    void adjust(int breite, int hoehe);
    };

    int directx::init()
    {
    D3DDISPLAYMODE d3ddm;
    D3DDEVTYPE devtype;
    D3DCAPS8 caps;

    d3d = Direct3DCreate8( D3D_SDK_VERSION);
    if( !d3d)
    return 0;

    if( d3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm) < 0)
    return 0;

    ZeroMemory( &d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
    d3dpp.BackBufferFormat = d3ddm.Format;

    if( d3d->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps) < 0)
    {
    MessageBox( hWnd, "Kein HAL-Device - das wird langsam!", "Dragon-Meldung", MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
    devtype = D3DDEVTYPE_REF;
    }
    else
    devtype = D3DDEVTYPE_HAL;

    if( d3d->CreateDevice( D3DADAPTER_DEFAULT, devtype, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &device) < 0)
    return 0;
    return 1;
    }

    void directx::adjust( int breite, int hoehe)
    {
    D3DXMATRIX proj;

    d3dpp.BackBufferWidth = breite;
    d3dpp.BackBufferHeight = hoehe;
    device->Reset( &d3dpp);
    device->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE);
    device->SetRenderState( D3DRS_AMBIENT, 0xffffff);
    D3DXMatrixPerspectiveFovLH( &proj, D3DX_PI/4, ((float)breite)/hoehe, 1.0f, 500.0f);
    device->SetTransform( D3DTS_PROJECTION, &proj);
    }

    directx mein_directx;

    class objekt
    {
    private:
    LPD3DXMESH mesh;
    D3DMATERIAL8 *materialien;
    DWORD anz_mat;
    LPDIRECT3DTEXTURE8 *texturen;
    public:
    objekt();
    void load( char *xfile);
    void draw();
    ~objekt();
    };

    objekt::objekt()
    {
    mesh = NULL;
    materialien = NULL;
    anz_mat = 0;
    texturen = NULL;
    }

    objekt::~objekt()
    {
    unsigned int i;

    if( materialien)
    delete[] materialien;

    if( texturen)
    {
    for( i = 0; i < anz_mat; i++ )
    {
    if( texturen[i])
    texturen[i]->Release();
    }
    delete[] texturen;
    }
    if( mesh)
    mesh->Release();
    }

    void objekt::load( char xfile)
    {
    LPD3DXBUFFER buf;
    D3DXMATERIAL
    mat;
    DWORD i;

    D3DXLoadMeshFromX( xfile, D3DXMESH_SYSTEMMEM, mein_directx.device, NULL, &buf, &anz_mat, &mesh);

    mat = (D3DXMATERIAL*)buf->GetBufferPointer();
    materialien = new D3DMATERIAL8[anz_mat];
    texturen = new LPDIRECT3DTEXTURE8[anz_mat];

    for( i=0; i<anz_mat; i++)
    {
    materialien[i] = mat[i].MatD3D;
    materialien[i].Ambient.r = 1.0f;
    materialien[i].Ambient.g = 1.0f;
    materialien[i].Ambient.b = 1.0f;
    if( D3DXCreateTextureFromFile( mein_directx.device, mat[i].pTextureFilename, &texturen[i]) < 0)
    texturen[i] = NULL;
    }
    buf->Release();
    }

    void objekt::draw()
    {
    unsigned int i;

    for( i=0; i < anz_mat; i++ )
    {
    mein_directx.device->SetMaterial( &materialien[i]);
    mein_directx.device->SetTexture( 0, texturen[i]);
    mesh->DrawSubset( i);
    }
    }

    # define GAROS 0

    class objekte
    {
    public:
    objekt Garos;
    void lade_objekte();
    };

    void objekte::lade_objekte()
    {
    Garos.load( "Garos.x");

    }

    objekte meine_objekte;
    //Dragonclass
    class dragon
    {
    private:
    D3DXVECTOR3 hier_bin_ich;
    D3DXVECTOR3 da_gucke_ich_hin;
    public:
    int init();
    void start();
    void render();
    };

    void dragon::start()
    {

    hier_bin_ich = D3DXVECTOR3( 0.0f, 3.5f,0.0f);
    da_gucke_ich_hin = D3DXVECTOR3( 0.0f, 0.0f, 0.0f);
    }

    int dragon::init()
    {
    if( !mein_directx.init())
    return 0;
    meine_objekte.lade_objekte();
    return 1;
    }

    void dragon::render()
    {

    D3DXMATRIX world;
    D3DXMATRIX view;

    mein_directx.device->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );
    mein_directx.device->BeginScene();

    D3DXMatrixLookAtLH( &view, &hier_bin_ich, &da_gucke_ich_hin, &D3DXVECTOR3( 0.0f, 1.0f, 0.0f));
    mein_directx.device->SetTransform( D3DTS_VIEW, &view);

    mein_directx.device->SetTransform( D3DTS_WORLD, &world);
    meine_objekte.Garos.draw();

    mein_directx.device->EndScene();
    mein_directx.device->Present( NULL, NULL, NULL, NULL);

    }

    dragon mein_spiel;
    // Hauptprogramm
    //
    int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
    LPSTR lpcmdline, int ncmdshow)
    {
    WNDCLASSEX windowclass; // Struktur für Fenstereigenschaften
    HWND hWnd; // Fenster-Handle
    MSG message; // Nachricht

    // Der Klassen-Name des Fensters ist frei wählbar
    const char szClassName[] = "Age of the Dragon";

    // Struktur mit gewünschten Eigenschaften füllen
    //

    // Größe der Struktur zwischenspeichern
    windowclass.cbSize = sizeof (WNDCLASSEX);

    // Fenster soll beim Verschieben neu gezeichnet werden
    windowclass.style = CS_HREDRAW | CS_VREDRAW;

    // Zeiger auf Callback-Funktion
    windowclass.lpfnWndProc = WindowProc;

    // Keine erweiterten Einstellungen
    windowclass.cbClsExtra = 0;
    windowclass.cbWndExtra = 0;

    // Instanz speichern
    windowclass.hInstance = hInst;

    // Icons und Cursor festlegen
    windowclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    windowclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    windowclass.hCursor = LoadCursor (NULL, IDC_ARROW);

    // Hintergrundfarbe festlegen
    windowclass.hbrBackground = (HBRUSH)COLOR_BACKGROUND+1;

    // Ein Menü brauchen wir nicht
    windowclass.lpszMenuName = NULL;

    // Klassenname angeben
    windowclass.lpszClassName = szClassName;

    // Fensterklasse registrieren
    if (!RegisterClassEx (&windowclass) )
    return (0);

    // Das Fenster erzeugen
    hWnd = CreateWindowEx (NULL,
    szClassName,
    "Age of the Dragon",
    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
    100, 100,
    300, 250,
    NULL,
    NULL,
    hInst,
    NULL);

    // Prüfen, ob alles glatt ging
    if (hWnd == NULL)
    return (0);

    // Der "Herzschlag" des Programms.
    // Hier werden alle Nachrichten abgeholt,
    // übersetzt und weitergeleitet.
    while (GetMessage (&message, NULL, 0, 0) )
    {
    TranslateMessage (&message);
    DispatchMessage (&message);

    }

    // Programm beenden
    return (int)(message.wParam);

    } // WinMain

    // Callback-Funktion zur Nachrichtenverarbeitung
    //
    LRESULT CALLBACK WindowProc (HWND hWnd, UINT message,
    WPARAM wParam, LPARAM lParam)
    {
    // Messages auswerten
    switch (message)
    {
    // Fenster schließen? (Auch Alt-F4)
    case WM_DESTROY:
    {
    // Nachricht zum Beenden schicken
    PostQuitMessage (0);
    return (0);

    }

    // Wurde eine Taste gedrückt?
    case WM_KEYDOWN:
    {
    // Ja, also je nach Taste verzweigen
    switch (wParam)
    {
    // Wurde "Escape" gedrückt?
    case VK_ESCAPE:
    {
    // Ja, also Nachricht zum Beenden schicken
    PostQuitMessage (0);
    return (0);

    }
    }
    } break;
    }

    // Die Nachricht wurde nicht von uns verarbeitet, also
    // von Windows verarbeiten lassen.
    return (DefWindowProc (hWnd, message, wParam, lParam) );

    } // WindowProc

    Beim Kompilieren geht noch alles klar aber...

    Kompilieren:
    --------------------Konfiguration: Age of the Dragon - Win32 Debug--------------------
    Kompilierung läuft...
    main.cpp
    c:\dxsdk\include\dinput.h: DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800

    main.obj - 0 Fehler, 0 Warnung(en)

    beim Linken zeigt er folgende Fehler:

    Linken:
    --------------------Konfiguration: Age of the Dragon - Win32 Debug--------------------
    Linker-Vorgang läuft...
    main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _Direct3DCreate8@4
    main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _D3DXMatrixPerspectiveFovLH@20
    main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _D3DXCreateTextureFromFileA@12
    main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _D3DXLoadMeshFromX@28
    main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _D3DXMatrixLookAtLH@16
    Debug/Age of the Dragon.exe : fatal error LNK1120: 5 unaufgeloeste externe Verweise



  • Kann es sein, dass du noch keine libs eingebunden hast?



  • Kann sein.Wie geht das?Das wurde in dem Buch was ich als Grundlage benutze nicht erwähnt. 😕



  • I.

    Präprozessor-Direktive (nach dem Include)

    #pragma comment(lib, "libname.lib")
    

    Oder im Compiler bei den Projekteinstellungen.



  • Danke.Ich schau mal obs hinhaut.



  • #include <d3d9.h>
    #include <d3dx9.h>
    
    #pragma comment (lib, "d3d9.lib")  // D3D library
    #pragma comment (lib, "d3dx9.lib") // D3DX library
    


  • Bitte mal den restlichen Code posten... 😎

    Bye, TGGC (Demo or Die)


Anmelden zum Antworten