Static *.lib files from Platform SDK.

New to FreeBASIC? Post your questions here.
alt160
Posts: 11
Joined: Jul 18, 2005 18:10
Location: Arizona

Static *.lib files from Platform SDK.

Post by alt160 »

There are several .lib files that are part of the Microsoft Win32 Platform SDK that do not have a .dll counterpart.

How can i use these libraries in FB?
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

You could rename them libxyz.a (where the original filename was xyz.lib) and put them in FreeBASIC\lib\win32. Then you'd need to port the relevant headers if they aren't already. Which libraries specifically are you speaking of?
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

Hmm ... does this really work? I thought there were some problems regarding name-mangling and other stuff ...

Regards,
Mark
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

I'm pretty sure it works - mingw .a files are the same format as Microsoft LIBs, if I remember correctly. Maybe I missed some problems?
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

The .lib file format should be the same, but AFAIK the M$ .o files are slightly different. That's the reason why NASM has two different COFF output formats but I don't know what the difference is ...

Regards,
Mark
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

I was under the impression that mingw used M$ COFF format for object files, but M$ didn't follow the COFF format exactly, so, for example, DJGPP COFF objects are a little different from Microsoft COFF objects. I'm pretty sure that mingw uses the PE COFF format.
alt160
Posts: 11
Joined: Jul 18, 2005 18:10
Location: Arizona

I'm a mapi coder...

Post by alt160 »

There are some really *cool* functions i'd like to get to with VB.NET that are part of the Exchange Developer Kit (EDK) that are only available as .lib files. There are full headers for each and are part of a full install of VC++ 6.0.

I'm trying right now to stumble my way thru creating a dll in VC6 that exports the methods in EDKMAPI.LIB.

I'm close, but i'm missing some libraries in my link list.

Eventually, i need to wrap all the EDK libraries.

Thanks,
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

DrV wrote:I was under the impression that mingw used M$ COFF format for object files, but M$ didn't follow the COFF format exactly, so, for example, DJGPP COFF objects are a little different from Microsoft COFF objects. I'm pretty sure that mingw uses the PE COFF format.
The PE COFF format is the executable format *g* - I guess you meant to object COFF format. Hmm ... I simply don't know it if they're different or not ...

Regards,
Mark
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Re: I'm a mapi coder...

Post by mjs »

alt160 wrote:I'm trying right now to stumble my way thru creating a dll in VC6 that exports the methods in EDKMAPI.LIB.
So using the .lib files directly didn't work? Just try it as suggested by DrV:
  1. Create "valid" library file names:

    Code: Select all

    copy *.lib lib*.a
  2. Add the path to the compiler switches
    See option "-p"
  3. Add the library to the compiler switches
    See option "-l" ... so when your library is "libkernel32.a", then you should specify "-l kernel32"
Regards,
Mark
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

mjs wrote:
DrV wrote:I was under the impression that mingw used M$ COFF format for object files, but M$ didn't follow the COFF format exactly, so, for example, DJGPP COFF objects are a little different from Microsoft COFF objects. I'm pretty sure that mingw uses the PE COFF format.
The PE COFF format is the executable format *g* - I guess you meant to object COFF format. Hmm ... I simply don't know it if they're different or not ...

Regards,
Mark
Actually, PE is also the object file format. :) http://www.microsoft.com/whdc/system/pl ... ECOFF.mspx
alt160
Posts: 11
Joined: Jul 18, 2005 18:10
Location: Arizona

Hmmm, i'll give it a try.

Post by alt160 »

I'll try the suggestions for renaming the libs to *.a

Its gonna be awhile as i have to convert some rather complex C header files...any tools out there to automate this effort? (*.h to *.bi)?

Thanks much guys!
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

For converting C headers to FB headers, v1ctor wrote a swig wrapper for FB: http://www.freebasic.net/temp/swig_fb.zip - but it's not finished yet.. you'll probably need to edit the results by hand.

If you're going to use these in VB.NET eventually, you'll probably want to write your own conversion tool anyway, since VB.NET's Declare syntax is different than FB's in subtle (and not-so-subtle) ways, though I haven't touched VB.NET in almost 2 years, so I don't remember much about it :).
alt160
Posts: 11
Joined: Jul 18, 2005 18:10
Location: Arizona

SHWEET. I'll check it...

Post by alt160 »

SHWEET! I'll check out that wrapper...

So far, as long as the exported functions support CDECL standards, VB.NET has no problems. I have created many DLLs in PowerBASIC for VB and VB.NET without issues.

Only caveats are strings... need to pass ByRef in VB if you want to have the DLL modify its contents. .NET doesnt allow direct memory access very easily due to its garbage collector implementation.

So, the ByRef works well, as long as the strings are small, like no more that a CPU page (4096 on intel).

For large strings...file streams seems to work well, or else deal with COM. which sucks ass. (which i'm sure you'd agree.)
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

Btw, FB follows VB when declaring string params, BYVAL AS STRING will pass the string data address, BYREF will pass the string descriptor, so you have to use BYVAL with strings if they are passed to/from C libs.

That doesn't mean the strings can't be modified inside FB, nor that a copy will be made.

Weird but was added to be compatible with the Win API headers borrowed from VB.
etko
Posts: 113
Joined: May 27, 2005 7:55
Location: Slovakia
Contact:

Post by etko »

Pure VB and VB.NET are two completely different languages and compilers. If I'm right VB.NET generates only bytecodes.
Post Reply