Linkfehler bei statischer lib



  • hi,
    ich hoff mal, dass ich hier richtig bin und das auch wirklich in die C++ Abteilung gehört.

    Hier erstmal meine Fehlermeldungen:

    --------------------Konfiguration: Billard2k3 - Win32 Debug--------------------
    Linker-Vorgang läuft...
    enginelib.lib(2D.obj) : error LNK2001: Nichtaufgeloestes externes Symbol "public: char const * __thiscall CGFX_Object::GetTexturePath(void)const " (?GetTexturePath@CGFX_Object@@QBEPBDXZ)
    enginelib.lib(2D.obj) : error LNK2001: Nichtaufgeloestes externes Symbol "public: struct _D3DXIMAGE_INFO __thiscall CGFX_Object::GetImgInfo(void)const " (?GetImgInfo@CGFX_Object@@QBE?AU_D3DXIMAGE_INFO@@XZ)
    enginelib.lib(2D.obj) : error LNK2001: Nichtaufgeloestes externes Symbol "public: struct IDirect3DTexture8 * & __thiscall CGFX_Object::GetTexturePointer(void)" (?GetTexturePointer@CGFX_Object@@QAEAAPAUIDirect3DTexture8@@XZ)
    enginelib.lib(2D.obj) : error LNK2001: Nichtaufgeloestes externes Symbol "public: struct D3DXVECTOR2 __thiscall CGFX_Object::GetRotVec(void)const " (?GetRotVec@CGFX_Object@@QBE?AUD3DXVECTOR2@@XZ)
    enginelib.lib(2D.obj) : error LNK2001: Nichtaufgeloestes externes Symbol "public: float __thiscall CGFX_Object::GetRotation(void)const " (?GetRotation@CGFX_Object@@QBEMXZ)
    enginelib.lib(2D.obj) : error LNK2001: Nichtaufgeloestes externes Symbol "public: float __thiscall CGFX_Object::GetX(void)const " (?GetX@CGFX_Object@@QBEMXZ)
    enginelib.lib(2D.obj) : error LNK2001: Nichtaufgeloestes externes Symbol "public: float __thiscall CGFX_Object::GetY(void)const " (?GetY@CGFX_Object@@QBEMXZ)
    enginelib.lib(2D.obj) : error LNK2001: Nichtaufgeloestes externes Symbol "public: unsigned long __thiscall CGFX_Object::GetTranparency(void)const " (?GetTranparency@CGFX_Object@@QBEKXZ)
    Debug/Billard2k3.exe : fatal error LNK1120: 8 unaufgeloeste externe Verweise
    Fehler beim Ausführen von link.exe.

    Billard2k3.exe - 9 Fehler, 0 Warnung(en)

    Meine *.lib Datei besteht aus 3 *.h und 3 *.cpp (ich werd sie unten mal posten)
    Bei der Kompilierung der *.lib gibts keine Fehlermeldungen, aber in meinem Projekt, dass die *.lib benutzen will schon.

    In meinem Projekt hab ich in der Main.cpp die Header der *.lib inkludiert und die *.lib im Linker eingetragen

    Die Fehler kommen nicht in der GFX_Object.obj Datei, obwohl sich in der eigentlich die Funktionen, die er nicht finden kann befinden, sondern in der 2D.obj Datei, die in ein paar Funktionen ein GFX_Object verwendet.
    Eigentlich denke ich, dass ich die Sache mit der Vorwärtsdeklaration richtig gemacht hab...

    Ich hoffe ihr könnt mir helfen

    // 2D.h: Schnittstelle für die Klasse C2D.
    //
    //////////////////////////////////////////////////////////////////////
    
    #if !defined(AFX_2D_H__F6DBF136_4AEC_47FE_883D_972CB8085303__INCLUDED_)
    #define AFX_2D_H__F6DBF136_4AEC_47FE_883D_972CB8085303__INCLUDED_
    
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    
    #include<vector>
    
    #include <d3d8.h>
    #include <d3dx8.h>
    #include "Log.h"
    
    #define VERTEXCAPS (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)
    
    class CGFX_Object;
    
    struct VERTEX
    {
        float       x, y, z; // transformierte Koordinaten
        float       rhw;     // für die Tiefenberechnung (Depthbuffering)
        D3DCOLOR    color;   // Farbe
    };
    
    class C2D  
    {
    private:
        LPDIRECT3D8 lpd3d;                  
        LPDIRECT3DDEVICE8 lpd3dDevice;          
        LPDIRECT3DVERTEXBUFFER8 lpVBpunkt;  // VB für Punkte
        LPDIRECT3DVERTEXBUFFER8 lpVBlinie;  // VB für Linien
        LPD3DXSPRITE lpd3dxSprite;              
        D3DCAPS8 *pd3dCaps;                 // ???
        CLog log;                           // Log_Objekt
        VERTEX* pPunktVertices;
        VERTEX* pLinieVertices;
        VERTEX a_punkt[50];
        VERTEX a_linie[50];
        int anz_pts,anz_lines;
    
        void DrawScene(std::vector<CGFX_Object>&);         // ruft DrawObject für jedes Element im Vektor auf
        void DrawObject(CGFX_Object&);   // GFX-Objekt wird 'gedrawt'   
    
    public:
        C2D();
        virtual ~C2D();
        HRESULT Init_DG(HWND);                      
        void Cleanup_DG();                      
        void Render(std::vector<CGFX_Object>&);                               
        void DrawPixel(int,int,D3DCOLOR);
        void DrawLine(int,int,int,int,D3DCOLOR);
    
        LPDIRECT3DTEXTURE8 LoadTexture(CGFX_Object&);
    
    };
    
    #endif // !defined(AFX_2D_H__F6DBF136_4AEC_47FE_883D_972CB8085303__INCLUDED_)
    
    // 2D.cpp: Implementierung der Klasse C2D.
    //
    //////////////////////////////////////////////////////////////////////
    
    #include "2D.h"
    #include "GFX_Object.h"
    
    //////////////////////////////////////////////////////////////////////
    // Konstruktion/Destruktion
    //////////////////////////////////////////////////////////////////////
    
    C2D::C2D()
    {
        lpd3d = 0; lpd3dDevice = 0; lpVBpunkt = 0;
        lpVBlinie = 0; lpd3dxSprite = 0; anz_pts = anz_lines = 0;
        pd3dCaps = new D3DCAPS8;
        log.Error("Ctor aufgerufen");
    }
    
    C2D::~C2D()
    {
        if(pd3dCaps) delete pd3dCaps;
        this->Cleanup_DG();
        log.Error("Destrukor aufgerufen");
    }
    
    void C2D::Cleanup_DG()
    {   
        if(lpd3dxSprite)
            lpd3dxSprite->Release();
        if(lpVBpunkt)
            lpVBpunkt->Release();
        if(lpVBlinie)
            lpVBlinie->Release();
        if(lpd3dDevice)
            lpd3dDevice->Release();
        if(lpd3d)
            lpd3d->Release();
        log.Error("CLeanup aufgerufen");
    }
    
    void C2D::DrawLine(int x1,int y1,int x2, int y2,D3DCOLOR color)
    {
        anz_lines++;
        a_linie[anz_lines*2].color = color;
        a_linie[anz_lines*2].x = x1;
        a_linie[anz_lines*2].y = y1;
        a_linie[anz_lines*2].z = 1;
        a_linie[anz_lines*2 +1].color = color;
        a_linie[anz_lines*2 +1].x = x2;
        a_linie[anz_lines*2 +1].y = y2;
        a_linie[anz_lines*2 +1].z = 1;
    }
    
    void C2D::DrawPixel(int x, int y, D3DCOLOR color)
    {
        anz_pts++;
        a_punkt[anz_pts].color = color;
        a_punkt[anz_pts].x = x;
        a_punkt[anz_pts].y = y;
        a_punkt[anz_pts].z = 1;
    }
    
    LPDIRECT3DTEXTURE8 C2D::LoadTexture(CGFX_Object& gfx)
    {
        D3DCOLOR colorkey = 0xFFFF00FF; //Magenta
    
        if(FAILED(D3DXCreateTextureFromFileEx(lpd3dDevice,gfx.GetTexturePath(),D3DX_DEFAULT,D3DX_DEFAULT
                                    ,1,0,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,D3DX_FILTER_NONE,
                                    D3DX_FILTER_NONE,colorkey,&gfx.GetImgInfo(),0,&gfx.GetTexturePointer())))
                                    log.Error("CreateTextureFromFile");
    
        return gfx.GetTexturePointer();
    }
    
    void C2D::Render(std::vector<CGFX_Object>& x)
    {
        if(lpd3dDevice == NULL)
            return;
    
        if(anz_pts != 0)
        {
            lpVBpunkt->Lock(0,0,(BYTE**)&pPunktVertices,0);
    
            memcpy(pPunktVertices,a_punkt,sizeof(VERTEX)* anz_pts);
    
            lpVBpunkt->Unlock();
        }
        if(anz_lines != 0)
        {
            lpVBlinie->Lock(0,0,(BYTE**)&pLinieVertices,0);
    
            memcpy(pLinieVertices,a_linie,sizeof(VERTEX)* anz_lines);
    
            lpVBlinie->Unlock();
        }
    
        lpd3dDevice->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,255),1.0f,0);
        lpd3dDevice->BeginScene();
        DrawScene(x);
        if(anz_pts != 0)
        {
            lpd3dDevice->SetStreamSource(0,lpVBpunkt,sizeof(VERTEX));
            lpd3dDevice->SetVertexShader(VERTEXCAPS);
            lpd3dDevice->DrawPrimitive(D3DPT_POINTLIST,0,anz_pts);
        }
        if(anz_lines != 0)
        {
            lpd3dDevice->SetStreamSource(0,lpVBlinie,sizeof(VERTEX));
            lpd3dDevice->SetVertexShader(VERTEXCAPS);
            lpd3dDevice->DrawPrimitive(D3DPT_LINELIST,0,anz_lines);
        }
        lpd3dDevice->EndScene();
        lpd3dDevice->Present(0,0,0,0);
    }
    
    void C2D::DrawScene(std::vector<CGFX_Object>& v)
    {
        for(int i=0;i <= v.size();i++)
        {
            DrawObject(v[i]);
        }
    }
    
    void C2D::DrawObject(CGFX_Object& gfx)
    {
        if(FAILED(lpd3dxSprite->Draw(gfx.GetTexturePointer(),0,0,&gfx.GetRotVec(),D3DXToRadian(gfx.GetRotation()),
                           &D3DXVECTOR2(gfx.GetX(),gfx.GetY()),gfx.GetTranparency())))
                           log.Error("Draw");
    }
    
    HRESULT C2D::Init_DG(HWND hwnd)
    {
        if((lpd3d = Direct3DCreate8(D3D_SDK_VERSION)) == NULL)
        {
            log.Error("Direct3DCreate8");       
            return E_FAIL;
        }
    
        D3DFORMAT format = D3DFMT_UNKNOWN;
    
        // Unterstüzung von 16bpp prüfen und entsprechendes Format speichern
        if(SUCCEEDED(lpd3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_R5G6B5, D3DFMT_R5G6B5, false)))
        {
            format = D3DFMT_R5G6B5;
            log.Error("D3DFMT_R5G6B5 wird verwendet");
        }
        else 
        {
            if(SUCCEEDED(lpd3d->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X1R5G5B5, D3DFMT_X1R5G5B5, false)))
                format = D3DFMT_X1R5G5B5;
                log.Error("D3DFMT_X1R5G5B5 wird verwendet");
        }
    
        // Grafikformat wird von der Grafikkarte nicht unterstützt
        if(format == D3DFMT_UNKNOWN)
        {
            log.Error("Kein Format gefunden");
            return E_FAIL;
        }
    
        D3DPRESENT_PARAMETERS   params;
        ZeroMemory(¶ms, sizeof(params));
    
        // Eigenschaften für Vollbildmodus setzten
        params.BackBufferCount                  =   1;
        params.BackBufferWidth                  =   800;
        params.BackBufferHeight                 =   600;
        params.BackBufferFormat                 =   format;
        params.FullScreen_PresentationInterval  =   D3DPRESENT_INTERVAL_DEFAULT;
        params.FullScreen_RefreshRateInHz       =   D3DPRESENT_RATE_DEFAULT;
        params.Windowed                         =   FALSE;
        params.hDeviceWindow                    =   hwnd;
        params.SwapEffect                       =   D3DSWAPEFFECT_COPY;
    
        // Grafikdevice erschaffen
        if(FAILED(lpd3d->CreateDevice(D3DADAPTER_DEFAULT,
                                      D3DDEVTYPE_HAL,
                                      hwnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      ¶ms,
                                      &lpd3dDevice)))
        {
            log.Error("CreateDevice");
            return E_FAIL;
        }
    
        if(!(D3DXCreateSprite(lpd3dDevice, &lpd3dxSprite)))
        {
            log.Error("CreateSprite");
            return E_FAIL;
        }
    
        UINT wVBLenght = sizeof(VERTEX) * 50;
    
        if(FAILED(lpd3dDevice->CreateVertexBuffer(wVBLenght,
            D3DUSAGE_WRITEONLY,
            VERTEXCAPS,
            D3DPOOL_DEFAULT,
            &lpVBpunkt)))
        {
            log.Error("CreateVertexBufferPunkt");
            return E_FAIL;
        }
    
        if(FAILED(lpd3dDevice->CreateVertexBuffer(wVBLenght,
            D3DUSAGE_WRITEONLY,
            VERTEXCAPS,
            D3DPOOL_DEFAULT,
            &lpVBlinie)))
        {
            log.Error("CreateVertexBufferLinie");
            return E_FAIL;
        }
    
        lpd3dDevice->SetRenderState(D3DRS_LIGHTING,FALSE);
    
        return S_OK;
    }
    
    // GFX_Object.h: Schnittstelle für die Klasse CGFX_Object.
    //
    //////////////////////////////////////////////////////////////////////
    
    #if !defined(AFX_GFX_OBJECT_H__D81D890D_8BF5_4518_AA3C_F3AEB4851AF2__INCLUDED_)
    #define AFX_GFX_OBJECT_H__D81D890D_8BF5_4518_AA3C_F3AEB4851AF2__INCLUDED_
    
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    
    #include <d3d8.h>
    #include <d3dx8.h>
    //#include "Log.h"
    
    class C2D;
    
    class CGFX_Object  
    {
    private:
        float m_x,m_y,m_z;                                  
        const char* m_chTexturePath;            
        LPDIRECT3DTEXTURE8 m_lpTextur;      
        D3DCOLOR m_AlphablendingWert;       
        float m_fRotation;
        D3DXIMAGE_INFO m_SrcInfo;
        D3DXVECTOR2 m_rotVec;
    public:
        CGFX_Object(float x, float y,float z,const char*,C2D& d3d);
        virtual ~CGFX_Object();
        void Transparenz_festlegen(D3DCOLOR);
        void Rotation_festlegen(int);
        void Position_festlegen(float,float,float);
        //Lesezugriff
        D3DXIMAGE_INFO GetImgInfo() const;
        float GetRotation() const;
        D3DCOLOR GetTranparency() const;
        LPDIRECT3DTEXTURE8& GetTexturePointer();
        const char* GetTexturePath() const;
        float GetX() const;
        float GetY() const;
        float GetZ() const;
        D3DXVECTOR2 GetRotVec() const;
    
    };
    
    #endif // !defined(AFX_GFX_OBJECT_H__D81D890D_8BF5_4518_AA3C_F3AEB4851AF2__INCLUDED_)
    
    // GFX_Object.cpp: Implementierung der Klasse CGFX_Object.
    //
    //////////////////////////////////////////////////////////////////////
    
    #include "GFX_Object.h"
    #include "2D.h"
    
    //////////////////////////////////////////////////////////////////////
    // Konstruktion/Destruktion
    //////////////////////////////////////////////////////////////////////
    
    CGFX_Object::CGFX_Object(float x, float y,float z,const char* pfad,C2D& d3d)
    : m_chTexturePath(pfad), m_x(x),m_y(y),m_z(z)
    {
        m_fRotation = 0.0f;
        m_AlphablendingWert = 0xFFFFFFFF;
        m_lpTextur = d3d.LoadTexture(*this);
        m_rotVec.x = m_SrcInfo.Width/2;
        m_rotVec.y = m_SrcInfo.Height/2;
    }
    
    CGFX_Object::~CGFX_Object()
    {
    
    }
    
    inline void CGFX_Object::Rotation_festlegen(int rot)
    {
        m_fRotation = D3DXToRadian(-rot);
    }
    
    inline void CGFX_Object::Transparenz_festlegen(D3DCOLOR color)
    {
        m_AlphablendingWert = color;
    }
    
    inline void CGFX_Object::Position_festlegen(float X, float Y,float Z)
    {
        m_x = X;
        m_y = Y;
        m_z = Z;
    }
    
    inline float CGFX_Object::GetRotation() const {return m_fRotation;}
    
    inline D3DCOLOR CGFX_Object::GetTranparency() const {return m_AlphablendingWert;}
    
    inline LPDIRECT3DTEXTURE8& CGFX_Object::GetTexturePointer() {return m_lpTextur;}
    
    inline const char* CGFX_Object::GetTexturePath() const {return m_chTexturePath;}
    
    inline float CGFX_Object::GetX() const {return m_x;}
    
    inline float CGFX_Object::GetY() const {return m_y;}
    
    inline float CGFX_Object::GetZ() const {return m_z;}
    
    inline D3DXIMAGE_INFO CGFX_Object::GetImgInfo() const {return m_SrcInfo;} 
    
    inline D3DXVECTOR2 CGFX_Object::GetRotVec() const {return m_rotVec;}
    
    // Log.h: Schnittstelle für die Klasse CLog.
    //
    //////////////////////////////////////////////////////////////////////
    
    #if !defined(AFX_LOG_H__98323A22_309E_48F3_B11C_21E50BC2EC59__INCLUDED_)
    #define AFX_LOG_H__98323A22_309E_48F3_B11C_21E50BC2EC59__INCLUDED_
    
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    
    #include <iostream>
    #include <fstream>
    #include <string>
    
    class CLog  
    {
    private:
        std::ofstream OutPutFile;
        const std::string Path;    // Pfad der Datei
    public:
        CLog();
        virtual ~CLog();
        void Error(const std::string&);
    
    };
    
    #endif // !defined(AFX_LOG_H__98323A22_309E_48F3_B11C_21E50BC2EC59__INCLUDED_)
    
    // Log.cpp: Implementierung der Klasse CLog.
    //
    //////////////////////////////////////////////////////////////////////
    
    #include "Log.h"
    
    //////////////////////////////////////////////////////////////////////
    // Konstruktion/Destruktion
    //////////////////////////////////////////////////////////////////////
    
    CLog::CLog()
    : Path("log.txt")
    {
    
    }
    
    CLog::~CLog()
    {
    
    }
    
    void CLog::Error(const std::string& Error_Message)
    {
        OutPutFile.open(Path.c_str());
        if(!OutPutFile)
        {
            std::cerr << OutPutFile << " kann nicht geoeffnet werden!\n";
            exit(-1);
        }
    
        OutPutFile << Error_Message << "\n";
    
        OutPutFile.close();
    }
    

    thnx,
    cu



  • Sorry Standard C++ kümmert sich nicht um details wir static/nicht static libs.
    Ich verschieben den thread mal ins msvc forum. MFC mit dem Visual C++


Anmelden zum Antworten