how to add new .LIB into PureBASIC 4 ?

Just starting out? Need help? Post your questions and find answers here.
freddix
Enthusiast
Enthusiast
Posts: 100
Joined: Sun Feb 08, 2004 7:22 pm
Location: South France
Contact:

how to add new .LIB into PureBASIC 4 ?

Post 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.
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

Try the "Import" keyword

Dri ;)
..::Origin::..
Enthusiast
Enthusiast
Posts: 125
Joined: Sat Jun 17, 2006 3:15 pm

Post 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
freddix
Enthusiast
Enthusiast
Posts: 100
Joined: Sun Feb 08, 2004 7:22 pm
Location: South France
Contact:

Post 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 ?
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Post 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.
Check out OOP support for PB here!
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
freddix
Enthusiast
Enthusiast
Posts: 100
Joined: Sun Feb 08, 2004 7:22 pm
Location: South France
Contact:

Post 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...
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
freddix
Enthusiast
Enthusiast
Posts: 100
Joined: Sun Feb 08, 2004 7:22 pm
Location: South France
Contact:

Post 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 ?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
freddix
Enthusiast
Enthusiast
Posts: 100
Joined: Sun Feb 08, 2004 7:22 pm
Location: South France
Contact:

Post by freddix »

if I understand what you say ...

un the procedure SetPoint & GetPoint are procedure in my .LIB ?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
freddix
Enthusiast
Enthusiast
Posts: 100
Joined: Sun Feb 08, 2004 7:22 pm
Location: South France
Contact:

Post by freddix »

ok and Thanks :)

With these informations, I'll try to integrate DarkGame SDK into PureBASIC :)
freddix
Enthusiast
Enthusiast
Posts: 100
Joined: Sun Feb 08, 2004 7:22 pm
Location: South France
Contact:

Post 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 ...
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Curiouse. What if you add the "_" at the beginning of the function names in the import section?
El_Choni
Post Reply