Import c++ DLL with classes

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Import c++ DLL with classes

Post by skinkairewalker »

hello guys, I would like to let you know that it would be interesting to import DLLs with classes in C++
this would make it easier to create wrappers and features for PB, an example of libraries with classes is the SteamWorks library ( steampowered.com )
User avatar
IceSoft
Addict
Addict
Posts: 1616
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: Import c++ DLL with classes

Post by IceSoft »

Code: Select all

#steam = 1
res = OpenLibrary(#steam, ".\steamworks_sdk_151\sdk\redistributable_bin\win64\steam_api64.dll")
Debug res
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Import c++ DLL with classes

Post by Rinzwind »

not helpful.

Anyway, won't happen c++ class style

This might help: "Flat interface for binding to other languages
The SDK has a few features to facilitate the creation of binding layers for other languages.

steam_api_flat.h declares a set of "flat" functions that mirror the interface functions in the SDK. This is not pure C code, but it does use plain C linkage and calling conventions, so it is easy to interop with other languages. These functions are exported by steam_api[64][.dll/.so/dylib]."

https://partner.steamgames.com/doc/sdk/api#thirdparty
Bitblazer
Enthusiast
Enthusiast
Posts: 732
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Import c++ DLL with classes

Post by Bitblazer »

The upcoming PureBasic Version 6 should make this a lot different and easier.
webpage - discord chat links -> purebasic GPT4All
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Import c++ DLL with classes

Post by Rinzwind »

It won't. C++ is known to be hard to link to from other languages, as is any other more complex language that supports OOP because they all do it in different ways. You always need a flat C "proxy" created in C++ that interfaces with the C++ code. Or a standard like COM on Windows... Weird there is no universal low level inter language communication standard. A thing we may hope for is direct import of C headers in PB, but even that I question since it seems they want to keep it feature-wise a copy of the asm backend and PB does not have all exact C data types (signed/unsigned). Hope the C backend brings language enhancements that obviously break comparability with the asm backend because nothing happens on that side. Just leave it in as classic mode and use the opportunity to make some needed language improvements. Just my 2 guilders.
Post Reply