Page 1 of 2

how to add new .LIB into PureBASIC 4 ?

Posted: Fri Aug 25, 2006 1:45 pm
by freddix
Hello all :)

All is in the title.

I have some .lib files and I know the functions names and arguments.
I'd like to use these .LIB to create new PB commands. Is it possible ?

Thanks.

Posted: Fri Aug 25, 2006 1:49 pm
by Dr. Dri
Try the "Import" keyword

Dri ;)

Posted: Fri Aug 25, 2006 1:57 pm
by ..::Origin::..
Are you trying to make the libraries? Or enable them in purebasic.

If you wish to enable them, copy them to
purebasic directory > purelibraries > userlibraries

Posted: Fri Aug 25, 2006 2:47 pm
by freddix
@Origin: I want to enable them in PureBASIC.

@Dri: will it include automatically the .LIB in the .exe I'll create with PureBASIC ?

Posted: Fri Aug 25, 2006 3:13 pm
by inc.
@Dri: will it include automatically the .LIB in the .exe I'll create with PureBASIC ?
It does statically link with the lib, so the needed symbols out of the lib will be included in your final compiled exe.

Posted: Fri Aug 25, 2006 7:06 pm
by netmaestro
If you're looking to make libs into permanent PB commands, you use Tailbite for that. It can be done manually but it's not for the faint-hearted. If you have both the .lib and the .dll you can use Import, but the dll will have to be available to your program at runtime, as the .lib file does not contain executable instructions.

Posted: Fri Aug 25, 2006 8:27 pm
by freddix
as the .lib file does not contain executable instructions.
I try to use DGDK into PureBASIC 4 and .LIB are the executable instructions !!! I have no DLL...

Posted: Fri Aug 25, 2006 8:34 pm
by ts-soft
Some static libs a only wrapper for static linking to dll, some others doesn't require a dll
To create a UserLib from static lib, you can use the last tailbite-version, this included the static lib in userlib, like PureZip from Gnozal.
If DLL required, so distibute the DLL with your Application.

Posted: Fri Aug 25, 2006 10:07 pm
by freddix
How can I use Tailbite with my .LIB to create userDLL ?
Must I create DESC files for these DLLS and use them in Tailbite ?

Posted: Fri Aug 25, 2006 10:15 pm
by ts-soft
small CodeExample:

Code: Select all

Import "MyLib.lib"
  SetPoint(x.l, y.l)
  GetPoint()
EndImport

ProcedureDLL MySetPoint(x.l, y.l) ; x = x-coordinate, y = y-coordinate
  SetPoint(x, y)
EndProcedure

ProcedureDLL MyGetPoint()
  ProcedureReturn GetPoint()
EndProcedure
Save and compile with TailBite, thats all

Posted: Sat Aug 26, 2006 12:24 pm
by freddix
if I understand what you say ...

un the procedure SetPoint & GetPoint are procedure in my .LIB ?

Posted: Sat Aug 26, 2006 12:36 pm
by ts-soft
> un the procedure SetPoint & GetPoint are procedure in my .LIB ?
Yes, this the Functions of the static lib
After TailBiteing in PB the new Functions MySetPoint and MyGetPoint

Posted: Sat Aug 26, 2006 1:00 pm
by freddix
ok and Thanks :)

With these informations, I'll try to integrate DarkGame SDK into PureBASIC :)

Posted: Wed Aug 30, 2006 9:35 pm
by freddix
when I try to Tailbite on the Basic2D.lib from DGDK i get this error:

POLINK: fatal error: 6 unresolved external(s)

Basic2D.lib file is in the same drawer than the .PB file.

here is my .PB file:

Code: Select all

Import "Basic2D.lib" 
  dbCls( RGBBackColor.l )
  dbInk( RGBForeColor.l, RGBBackColor.l )
  dbDot( X.l, Y.l )
  dbBox( Left.l, Top.l, Right.l, Bottom.l )
  dbLine( X1.l, Y1.l, X2.l, Y2.l )
  dbCircle( X.l, Y.l, Radius.l )
 EndImport 

ProcedureDLL DgdkCLS( RGBColor.l )
  dbCls( RGBColor )
 EndProcedure

ProcedureDLL DgdkINK( ForeRGBColor.l, BackRGBColor.l )
  dbInk( ForeRGBColor, BackRGBColor )
 EndProcedure

ProcedureDLL DgdkDOT( X.l, Y.l )
  dbDot( X, Y )
 EndProcedure

ProcedureDLL DgdkBOX( Left.l, Top.l, Right.l, Bottom.l )
  dbBox( Left, Top, Right, Bottom )
 EndProcedure

ProcedureDLL DgdkLINE( X1.l, Y1.l, X2.l, Y2.l )
  dbLine( X1, Y1, X2, Y2 )
 EndProcedure

ProcedureDLL DgdkCIRCLE( X.l, Y.l, Radius.l )
  dbCircle( X, Y, Radius )
 EndProcedure
the original .h file is :

Code: Select all

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// BASIC 2D COMMANDS ////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////




/////////////////////////////////////////////////////////////////////////////////////////////////////////
// INCLUDES /////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <windows.h>

/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////




/////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION LISTINGS ////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

void	dbCLS					( DWORD RGBBackColor );
void	dbInk					( DWORD RGBForeColor, DWORD RGBBackColor );
void	dbDot					( int iX, int iY );
void	dbBox					( int iLeft, int iTop, int iRight, int iBottom );
void	dbLine					( int iXa, int iYa, int iXb, int iYb );
void	dbCircle				( int iX, int iY, int iRadius );
void	dbElipse				( int iX, int iY, int iXRadius, int iYRadius );
DWORD	dbRgb					( int iRed, int iGreen, int iBlue );
int		dbRgbR					( DWORD iRGB );
int		dbRgbG					( DWORD iRGB );
int		dbRgbB					( DWORD iRGB );
DWORD	dbPoint					( int iX, int iY );

void	dbDot					( int iX, int iY, DWORD dwColor );
void	dbBox					( int iLeft, int iTop, int iRight, int iBottom, DWORD dw1, DWORD dw2, DWORD dw3, DWORD dw4 );
void	dbLockPixels			( void );
void	dbUnLockPixels			( void );
DWORD	dbGetPixelsPointer		( void );
DWORD	dbGetPixelsPitch		( void );

void	ConstructorBasic2D		( HINSTANCE );
void	DestructorBasic2D		( void );
void	SetErrorHandlerBasic2D	( LPVOID pErrorHandlerPtr );
void	PassCoreDataBasic2D		( LPVOID pGlobPtr );
void	RefreshD3DBasic2D		( int iMode );
void	UpdateBPPBasic2D		( void );
void	dbCopyArea				( int iDestX, int iDestY, int iWidth, int iHeight, int iSourceX, int iSourceY );

// lee - 300706 - GDK fixes
DWORD	dbRGB					( int iRed, int iGreen, int iBlue );
int		dbRGBR					( DWORD iRGB );
int		dbRGBG					( DWORD iRGB );
int		dbRGBB					( DWORD iRGB );
void	dbEllipse				( int iX, int iY, int iXRadius, int iYRadius );
void	dbUnlockPixels			( void );

/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

EDIT:
if I try to compile the PB code directly in pb I get this :
POLINK: error: Unresolved external symbol '_dbCls'
POLINK: error: Unresolved external symbol '_dbInk'
POLINK: error: Unresolved external symbol '_dbDot'
POLINK: error: Unresolved external symbol '_dbBox'
POLINK: error: Unresolved external symbol '_dbLine'
POLINK: error: Unresolved external symbol '_dbCircle'
POLINK: fatal error: 6 unresolved external(s)

Apparently, it add a _ before the function names taken from my .LIB file ... Strange ...

Posted: Fri Sep 01, 2006 10:26 am
by El_Choni
Curiouse. What if you add the "_" at the beginning of the function names in the import section?