DLL Importer howto?

Just starting out? Need help? Post your questions and find answers here.
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

DLL Importer howto?

Post by Rinzwind »

I can't seem to get it to work. Talking about the tool in C:\Program Files (x86)\PureBasic571\SDK\DLL Importer .

I created PUREBASIC.dll from the included DLLSample.pb (which also creates a .lib file)

I created a PUREBASIC.pbl file:
PUREBASIC.DLL
EasyRequester 1

All files are in the same folder.

I run DLL Importer and get this message:
---------------------------
Info
---------------------------
Conversion correctly finished.

Files created:

C:\Program Files (x86)\PureBasic571\PureLibraries\Windows\PUREBASIC
C:\Program Files (x86)\PureBasic571\PureLibraries\Windows\Libraries\PUREBASIC.lib
C:\TestDLL\Exports\purebasic.def
---------------------------
OK
---------------------------

I restart PB and try to get EasyRequester_("EasyRequester") to work.
---------------------------
PureBasic
---------------------------
Line 1: EasyRequester_() is not a function, array, list, map or macro.
---------------------------
OK
---------------------------

Where should the DLL be placed? Next to binary or does it have to be in system32?

I tried copying the DLL to C:\Windows\SysWOW64 (32 bit DLL). But still same message.

Btw. can't the tool create those IDL files from a .lib file (or .h if available)? Or use an existing.lib file instead? (the DLL Importer creates a .lib file too?).

The readme is quite basic and uses a weird translation for folder as 'drawer' it seems.
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: DLL Importer howto?

Post by Mijikai »

I think (i never used it) the dll importer just creates a *.lib by reading all the exports of a *.dll into *.def file.

To import *.dll functions u only need the *.lib file (which in PBs case is never a static one!)

Compile your *.dll and place it (and the *.lib) either in the working directory (where your source is) or in the appropriate system directory.
Then use the *.lib file to import all functions needed (with the same function names and parameters as you defined in the dll src).

DLL:

Code: Select all

ProcedureDLL.i Dummy()
   ProcedureReturn 123
EndProcedure

Source that uses the DLL:

Code: Select all

Import "Some.lib";<- or the path "...\Some.lib" to the *.lib file if it is not placed in the source directory!
  Dummy.i()
EndImport

Dummy()
The *.lib file is only needed for compiling (no need to supply it with your *.dll later)!
Last edited by Mijikai on Wed Mar 04, 2020 7:12 am, edited 1 time in total.
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: DLL Importer howto?

Post by Rinzwind »

Thought the idea being that the functions in the DLL became 'build-in' functions, no need for import endimport.

But can't make it work. Also fiddling around with C:\Program Files (x86)\PureBasic571\SDK\LibraryMaker.exe , how does that work with the basic DLLSample.pb's .lib file (just as proof of concept)?
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: DLL Importer howto?

Post by Mijikai »

Rinzwind wrote:Thought the idea being that the functions in the DLL became 'build-in' functions, no need for import endimport...
Oh, you want to create user libraries (sorry my english isnt the best).
I cant really help u with that but i suspect that the *.pbl file is probably just a source file which contains the Import "" function i showed before.
I dont really get the drawer stuff in the readme...
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1243
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: DLL Importer howto?

Post by Paul »

Rinzwind wrote:Thought the idea being that the functions in the DLL became 'build-in' functions, no need for import endimport.

But can't make it work. Also fiddling around with C:\Program Files (x86)\PureBasic571\SDK\LibraryMaker.exe , how does that work with the basic DLLSample.pb's .lib file (just as proof of concept)?
For me the Library Importer worked up to PureBasic 5.31
Starting PureBasic 5.40 the files in "PureLibraries\Windows" all ended with ".imp" and DLL's imported with Library Importer would no long work ;(
Image Image
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: DLL Importer howto?

Post by Fred »

I will take a look, but we use it in the build server to create all the imports so it should still work somehow..
empty
User
User
Posts: 27
Joined: Sat Apr 12, 2014 11:31 am

Re: DLL Importer howto?

Post by empty »

Fred wrote:I will take a look, but we use it in the build server to create all the imports so it should still work somehow..
Any news on that? While the importer says it created files in PureLibraries\Windows and PureLibraries\Windows\Libraries no such files are there to be found.
The .def file gets written in the export folder, though.
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: DLL Importer howto?

Post by chi »

Paul wrote:For me the Library Importer worked up to PureBasic 5.31
Starting PureBasic 5.40 the files in "PureLibraries\Windows" all ended with ".imp" and DLL's imported with Library Importer would no long work ;(
Take a look at this...
Et cetera is my worst enemy
Post Reply