Page 1 of 1

Import c++ DLL with classes

Posted: Mon Jul 19, 2021 2:12 pm
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 )

Re: Import c++ DLL with classes

Posted: Tue Jul 20, 2021 8:05 am
by IceSoft

Code: Select all

#steam = 1
res = OpenLibrary(#steam, ".\steamworks_sdk_151\sdk\redistributable_bin\win64\steam_api64.dll")
Debug res

Re: Import c++ DLL with classes

Posted: Tue Jul 20, 2021 11:36 am
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

Re: Import c++ DLL with classes

Posted: Tue Jul 20, 2021 5:41 pm
by Bitblazer
The upcoming PureBasic Version 6 should make this a lot different and easier.

Re: Import c++ DLL with classes

Posted: Mon Oct 18, 2021 3:21 am
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.