Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linking to C .LIB library files.
#1
If you haven't already guessed by now, I'm C illiterate.

My C co-workers have made me a C library that I want to
link to in FB to try some functions that they wrote for me
in C. They have generated .LIB files.

All the examples I see of including libraries in FB are with
.BI file extensions. They don't recognize those, and
I'm not sure if I need to do something special to link to a .LIB file.

So if they made a library called File64.LIB, what do I have to do
to link to that library from FB?

Dean
Reply
#2
You have to name the lib as libmylib.a
You have to translate the .h header file to a .bi FB.
Then you must include the .bi file in your source and call fbc with the
Code:
-l mylib
option. Or use the #inclib metacommand in the source
Antoni
Reply
#3
So, this is what you're saying all that I have to do is?:

1. Rename FILE64.LIB as FILE64.a
2. Rename FILE64.h as FILE64.bi
3. Put an include line in the .bas program as:

'$include: "FILE64.bi"

4. Then call FBC as FBC -l FILE64

Right?
Reply
#4
libFILE64.a, not just FILE64.a. It's ancient UNIX ugliness. Sad
Reply
#5
Quote:2. Rename FILE64.h as FILE64.bi
Wrong!
Renaming the file will not help you.

Quote:You have to translate the .h header file to a .bi FB.
Translate means convert the c code to basic...

struct -> type
etc.
Reply
#6
yo upload the lib package some ware and give a link somone here can translate the .h for ya most likely won't be all that complex.
Reply
#7
Post the header, i can translate it if it's simple enough.. not by hand, course.. i should release the .h to .bi translator, i didn't finish it yet though, there are some bugs..
Reply
#8
I will be posting a link in about an hour. This is what I've asked
my guy here to do:

Create 64bit functions for the following:

OPEN64
CLOSE64
SEEK64
GET64
PUT64

For now, I've asked him just to deal with binary access.
You guys can test this better than me, so I'll include the source,
which is not very much -- this is as I understand it, just calling
windows API calls and giving me functions that are Basic-like syntax.

Dean
Reply
#9
Here's the link to the files.

http://www.cct.com/lib/file64.h
http://www.cct.com/lib/file64.cpp
http://www.cct.com/lib/file64.lib

Hope this works.

Dean
Reply
#10
There:

Code:
''
''
'' file64 -- header translated with help of SWIG FB wrapper
''
'' NOTICE: This file is part of the FreeBASIC Compiler package and can't
''         be included in other distributions without authorization.
''
''
#ifndef __file64_bi__
#define __file64_bi__

#define NOT_FOUND -1
#define INV_ARG -2
#define NO_HANDLE -3
#define INV_HANDLE -1
#define FILE_SEEK_CUR 0
#define FILE_SEEK_ORIG 1
#define FILE_SEEK_END 2

declare function Open64 cdecl alias "Open64" (byval filename as string, byval mode as string, byval lock as string, byval fnumber as integer) as integer
declare function Seek64 cdecl alias "Seek64" (byval fnum as integer, byval offset as longint, byval origin as integer) as integer
declare function Close64 cdecl alias "Close64" (byval fnum as integer) as integer
declare function SeekStr64 cdecl alias "SeekStr64" (byval fnum as integer, byval offset as string, byval origin as integer) as integer
declare function Get64 cdecl alias "Get64" (byval fileNum as integer, byval buff as string, byval len as integer) as integer
declare function Put64 cdecl alias "Put64" (byval fileNum as integer, byval buff as string, byval len as integer) as integer
declare function GetHandleFromMap cdecl alias "GetHandleFromMap" (byval filenum as integer) as integer
declare sub RemoveHandleFromMap cdecl alias "RemoveHandleFromMap" (byval fileNum as integer)

#endif
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)