Page 1 of 1

No functions found in a DLL

Posted: Sun Dec 08, 2024 5:02 pm
by Quark
PureBasic 6.12 LTS (Windows - x64) and also x32

Hi,

Just a newbie to PB struggling with simple things...
I just would like to access the functions of a DLL.
Here is my code:

Code: Select all

		LibNum = 1 
		LibHandle = OpenLibrary(LibNum,"TWSLib.dll")

		Result = IsLibrary(LibNum)
		Result = LibraryID(LibNum)
		Result = CountLibraryFunctions(LibNum)
This code works fine till the last line that returns 0. Previous functions return large positive numbers.

I used a DLL viewer such as "DLL Export Viewer" that displayed nothing at all.
An online tool "https://speedtesting.herokuapp.com/peviewer/" showed some kind of header (valid or not, I dont know) but no functions at all.

Of course the purebasic function "ExamineLibraryFunctions" does not report any functions
Why is that I cannot access the functions of this DLL ? Maybe they are just not there...

Thanking you in advance for any help

Re: No functions found in a DLL

Posted: Sun Dec 08, 2024 6:11 pm
by jacdelad
Where is the DLL from? Is it 32 or 64 bit?

Re: No functions found in a DLL

Posted: Mon Dec 09, 2024 9:36 pm
by Quark
>Where is the DLL from? Is it 32 or 64 bit?

I think it is 32 bit but I am not sure. Does this make a difference?
It comes with TWS API installation, that is an API for interfacing with "Interactive Brokers" broker (financial info, placing orders, etc).

Re: No functions found in a DLL

Posted: Mon Dec 09, 2024 11:30 pm
by normeus
They do have a Web api which PureBasic should be able to handle easily. ( or with some effort anyway )

"TWSLib.dll" is a C# dll. You should have a "TWSLib64.tlb" and a "TWSLib32.tlb, but I have no idea how to load that to be useful with PB.
Dealing with objects with PB can be stress inducing to say the least. Stick with their web interface or think about using C# for this one project.

Norm.

Re: No functions found in a DLL

Posted: Tue Dec 10, 2024 10:00 am
by Fred
Quark wrote: Mon Dec 09, 2024 9:36 pm >Where is the DLL from? Is it 32 or 64 bit?

I think it is 32 bit but I am not sure. Does this make a difference?
It comes with TWS API installation, that is an API for interfacing with "Interactive Brokers" broker (financial info, placing orders, etc).
Yes, it does, you can't open a 32-bit dll with a 64-bit exe and vice-versa

Re: No functions found in a DLL

Posted: Wed Dec 11, 2024 4:42 pm
by Quark
> They do have a Web api which PureBasic should be able to handle easily. ( or with some effort anyway )
I have no idea of what is a Web API is. I will find out

> think about using C# for this one project.
I am a bit too old to learn a new language! I just know C and VB6 languages.
Initially I thought it was almost as simple as placing an OCX control on a VB6 form, like in the old days... :D
Normally the evolution of computer science should make things easier. This is not what seems to be happening.

> "TWSLib.dll" is a C# dll.
a "C# dll" ? What is specific about this C# DLL ? I thought DLL's were something precisely defined, all the same (standardized).

> "TWSLib64.tlb" and a "TWSLib32.tlb files:
I had already placed the files "TWSLib64.tlb" and a "TWSLib32.tlb on the same folder than the DLL and the application.

> Yes, it does, you can't open a 32-bit dll with a 64-bit exe and vice-versa
I used both PB x32 and PB x64 versions of the Compiler/debugger ==> same problem

I did not find a way to attach files in this forum. Here is a download link for the DLL, just in case anyone wants to have a look:
https://www.transfernow.net/dl/20241211 ... D/qomxs5QI

Re: No functions found in a DLL

Posted: Mon Dec 16, 2024 6:26 pm
by Quark
So nobody knows what is wrong is wrong with this DLL ?

Maybe I should find a c# compiler and try to recompile TWS.lib in a more "standard" library, if I am given this possibility.
But this way could take hours or days (or weeks, who knows...) as I never did this kind of thing.

Anyway I now took the Purebasic network functions path and this seems to work as for now (just started).

As for the web API, someone in the TWS forum seems to discourage using it. It may not be well implemented by Interactive Brokers.

Re: No functions found in a DLL

Posted: Tue Dec 17, 2024 7:04 am
by Kulrom
You can't use .net dll in PureBasic or any other programming language that doesn't run on .net .
Learn what .net is
If you're not happy with the web API, you'll have to learn at least Visual Basic.net

Re: No functions found in a DLL

Posted: Tue Dec 17, 2024 4:13 pm
by Quark
> You can't use .net dll in PureBasic or any other programming language that doesn't run on .net.
OK, just to be clear: it is just not possible to use a C# or CPP compiler to generate a DLL that can be used by Purebasic. Right ?

A usable DLL could have been the simplest solution. Almost as simple as dropping an OCX control on a VB6 form, like in the simpler old days!

I am now playing with the PB network functions. I can connect and send a message successfully but dont receive any response from IBGW. I guess that IBGW does not dare responding because my ASCII command is not properly formatted.

Re: No functions found in a DLL

Posted: Tue Dec 17, 2024 4:19 pm
by Quin
Quark wrote: Tue Dec 17, 2024 4:13 pm > You can't use .net dll in PureBasic or any other programming language that doesn't run on .net.
OK, just to be clear: it is just not possible to use a C# or CPP compiler to generate a DLL that can be used by Purebasic. Right ?
You're half correct, you can make DLLs for PureBasic using C/C++, because they compile to machine code, but not .NET. .NET DLLs are actually just assemblies, they contain IL code, which you can see by running them through any decompiler like ILSpy.

Re: No functions found in a DLL

Posted: Tue Dec 17, 2024 5:27 pm
by Quark
If I can generate a PB compatible DLL I am tempted to follow this path. Which CPP compiler would you recommend for this purpose ?
I guess that it is not possible to just open the TWS API CPP project and quickly generate a DLL ? There will probably be millions of options to select as well as many lines of code to change before that. I am usually optimistic, but these past few days, I stump on everything I try :-(

Re: No functions found in a DLL

Posted: Wed Dec 18, 2024 2:22 pm
by Kulrom
Quark wrote: Tue Dec 17, 2024 5:27 pm If I can generate a PB compatible DLL I am tempted to follow this path. Which CPP compiler would you recommend for this purpose ?
I guess that it is not possible to just open the TWS API CPP project and quickly generate a DLL ? There will probably be millions of options to select as well as many lines of code to change before that. I am usually optimistic, but these past few days, I stump on everything I try :-(
Learn C# or Visual Basic .NET.
There is no other way to use .NET dlls
There is also IronPython or Python.NET. But they are so-so.
If I were you, I would choose Visual Basic .NET

The main program can be made in PureBasic. In VB .NET you can make a small CLI program that will work with your library and output the result either to a file or to stdout.

Re: No functions found in a DLL

Posted: Wed Dec 18, 2024 3:16 pm
by Kulrom
Try again as described in this topic
viewtopic.php?p=586522&hilit=dotnet+dll#p586522

But it is still better to use .NET programming language and Visual Studio!!!