Archiv verlassen und diese Seite im Standarddesign anzeigen : shared lib erstellen ?
HeadShot
22-10-2002, 17:17
Hi!
Kann mir wer verraten, wie ich jetzt auf diesen Dateien:
- lgfx.h
- lgfx.cpp
eine shared-lib namens
- libLGFX.so
erstellen kann?
mfg headi
Hi,
Als erstes kompilierst du die entsprechenden Module wie folgt:
g++ -fPIC -Wall -g -c lgfx.cpp
PIC steht für 'Position Independent Code', d.h. du kannst ihn an jede Stelle im Speicher laden. Es werden also nur relative Sprünge erzeugt, und kein Sprung auf eine statische Adresse.
Die Objektdateien linkst du jetzt noch wie folgt:
g++ -g -shared -WL,soname,libLGFX.so.1 -o libLGFX.so.1.0 lgfx.o
und fertig ist deine neue Bibliothek 'libLGFX.so.1.0 :) Mit ldconfig noch laden, bzw. vorher in ein Libdir kopieren und fertig. Deine Programme immer schön mit -lLGFX linken und schon müssten deine Funktionen dabei sein.
tkortkamp
22-10-2002, 22:06
Lesenswert zu diesem Thema: das Program Library HowTo
http://www.dwheeler.com/program-library/Program-Library-HOWTO/index.html
c ya,
Tobias
HeadShot
23-10-2002, 12:12
Habn problem, da ich ja in meiner Engine auch erwähnt werden will, will ich ein logo 3sekunden lang anzeigen lassen, hab also in der Video-Klasse eine instanz der Image-Klasse erstellt, und die dann nach der Video-Initialisierung aufgerufen, doch beim kompilieren kommen diese fehler:
[codemasta@Pasqual lingfx]$ make
g++ `sdl-config --cflags` `sdl-config --libs` -lSDL_image -lSDL_mixer -lSDL_net lingfx.cpp main.cpp -o lingfx
In file included from lingfx.cpp:13:
lingfx.h:76: field `m_imgLogo' has incomplete type
lingfx.cpp: In constructor `lgfxVIDEO::lgfxVIDEO()':
lingfx.cpp:67: `class lgfxVIDEO' has no member named `m_imgLogo'
lingfx.cpp: In member function `bool lgfxVIDEO::Init(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, bool)':
lingfx.cpp:118: `class lgfxVIDEO' has no member named `m_imgLogo'
In file included from main.cpp:14:
lingfx.h:76: field `m_imgLogo' has incomplete type
lingfx.h: In function `int main(int, char**)':
lingfx.h:35: too few arguments to function `bool Init(bool, bool, bool, bool)'
main.cpp:37: at this point in file
make: *** [all] Fehler 1
der code dazu sieht so aus:
//----------------------------------------------------------
// File : lingfx.h
// Author : Pasqual Brettner
// Date : Die Okt 22 2002
// Copyright: (C) 2002 by Pasqual Brettner
// E-Mail : pasqualb@web.de
//----------------------------------------------------------
#ifndef __LINGFX_H_
#define __LINGFX_H_
//----------------------------------------------------------
// I N C L U D E S
//----------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
#include "SDL_net.h"
//----------------------------------------------------------
// D E F I N I T I O N S
//----------------------------------------------------------
//----------------------------------------------------------
// F U N C T I O N S
//----------------------------------------------------------
bool Init(bool bVideo, bool bTimer, bool bAudio, bool bJoystick);
void Kill(void);
//----------------------------------------------------------
// C L A S S E S
//----------------------------------------------------------
class lgfxIMAGE;
//SDL-Class, to init SDL and use SDL
class lgfxVIDEO
{
public:
lgfxVIDEO(void);
~lgfxVIDEO(void);
bool Init(string sT, int iW, int iH, int iB, bool bF);
void InitStates(Uint8 uiC[4]);
void Free(void);
void Flip(void);
inline SDL_Surface *getSurface(void) { return m_pSurface; }
inline bool getMode(void) { return m_bFullscreen; }
inline int getWidth(void) { return m_iWidth; }
inline int getHeight(void) { return m_iHeight; }
inline int getBpp(void) { return m_iBpp; }
private:
SDL_Surface *m_pSurface;
bool m_bFullscreen;
int m_iWidth;
int m_iHeight;
int m_iBpp;
Uint32 m_uiVideoFlags;
Uint32 m_uiClearColor;
lgfxIMAGE m_imgLogo;
};
//SDL_image-Class, to load Images with Colorkeys and render them.
class lgfxIMAGE
{
public:
lgfxIMAGE(void);
~lgfxIMAGE(void);
bool Init(string sF, bool bWC, Uint8 uiR, Uint8 uiG, Uint8 B, Uint8 uiA);
void Render(int iX, int iY, float fR, lgfxVIDEO &pVideo);
private:
SDL_Surface *m_pImage;
Uint32 m_uiColorkey;
bool m_bWithColorkey;
string m_strFilename;
};
#endif
hoffe ihr könnt mir helfen!
mfg headi
anda_skoa
23-10-2002, 13:09
die zweite Klasse vor der ersten deklarieren, oder in einem extra File und dann inkludierern, oder m_imgLogo zu einem Pointer machen.
Im letzteren Fall muß der Compiler nur, wissen, dass es ein Pointer ist.
dann geht da auch mit forward declaration.
Sonst muß er die Klasse kennen (Möglichkeiten 1 und 2)
Ciao,
_
Powered by vBulletin® Version 4.2.5 Copyright ©2025 Adduco Digital e.K. und vBulletin Solutions, Inc. Alle Rechte vorbehalten.