Using DLLs

BlitzMax Forums/BlitzMax Programming/Using DLLs

MattVonFat(Posted 2006) [#1]
Hi,

I'm trying to use the WinInet DLL in a program (for SSL features). I did a search on the forums and found out that I needed to have the libwininet.a file in libs in order for Extern to work for DLLs. I've put the libwininet.a file from a C++ compiler I have in the libs folder for BlitzMAX but it wont let me use the functions. I'm guessing it's because I need the .h file somewhere aswell.

Is there a folder I can just put the .h file and forget about it or do I have to make a module for it to work?

Thanks for any help
Matthew


Chris C(Posted 2006) [#2]
you'd need to import the archive

import "libwininet.a"

assuming its in the same dir as the bmx your compiling

also you'll need to declare the routines it contains in an extern block

extern
function functionname:returntype(a:vartype,b:vartype)
endextern

you can usuallu use the .h file to guide you in making the right prototypes im blitzmax


MattVonFat(Posted 2006) [#3]
Ok, I've done what you said and I used the .h file to workout what the Extern function i want should be but I get an undefined refrence error. I've got the variable types right, return type right and the name of the function right.

I only get the error though when I try to use the function - not sure if that makes any difference or not.

Thanks,
Matthew


Gabriel(Posted 2006) [#4]
Remember that these function calls will be case sensitive, so make sure you've got your capitalization correct.

import "libwininet.a"


Not sure about this line. In my WinInet module, I'm using

Import "-lwininet"


And that works fine.

Also your Extern block should be defined as Extern "Win32" or things will go doolally ( done this a couple times by mistake. )


MattVonFat(Posted 2006) [#5]
Thanks very much!

I think my problem was the "Win32" bit. I assumed that was just for the user32 stuff.

It works perfectly now!