Creating purelibraries in MinGW C++ possible?
-
olejr
- Enthusiast

- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
Creating purelibraries in MinGW C++ possible?
The reason I ask this is that MinGW on Windows & gcc Linux are great for crossplatform development..
olejr,
It is possible to create userlibraries using GCC/MingW. I've compiled the provided example using Bloodsheds Dev-Cpp.
However, the userlibraries can only be bound on simple functions. You cannot use C++ classes.
If you know what you are doing it is possible to return C++ classes from simple functions using interfaces.
It is possible to create userlibraries using GCC/MingW. I've compiled the provided example using Bloodsheds Dev-Cpp.
However, the userlibraries can only be bound on simple functions. You cannot use C++ classes.
If you know what you are doing it is possible to return C++ classes from simple functions using interfaces.
-
olejr
- Enthusiast

- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
Ok.. I think some more investigation is required on my side..
BTW. It would be great to see some kind of example...
I was trying to do a simple "hello world" Function in C++,
but ended up with a POLINK unresolved external symbol.. _PB_MyFunction..
*EDIT: In MingW there's a switch -fno-leading-underscore..
But I get the same error no matter what, in C++ that is. Standard C works..
BTW. It would be great to see some kind of example...
I was trying to do a simple "hello world" Function in C++,
but ended up with a POLINK unresolved external symbol.. _PB_MyFunction..
*EDIT: In MingW there's a switch -fno-leading-underscore..
But I get the same error no matter what, in C++ that is. Standard C works..
I don't know these __ZNKS* but it looks like there's some kind of c-runtimeIf I use extern "C", I get 4 POLINK errors..
__ZNKSs4sizeEv
__ZNKSsixEj
__ZNKSst8ios_base4InitC1Ev
__ZNKSst8ios_base4InitD1Ev
All is unresolved external...
missing. I never used MingW so can't help but extern "C" is the way to go,
otherwise your exported function will be unkown (as POLINK told you)
(If __ZNKS* are no real or used functions you could also try to simply define
them, like char _ZNKSsixEj; but because I don't know __ZNKS* I personally
can't recommend this
Good programmers don't comment their code. It was hard to write, should be hard to read.
-
olejr
- Enthusiast

- Posts: 152
- Joined: Sun Jul 11, 2004 7:48 pm
- Location: Lillehammer, No(r)way
- Contact:
Well.. Maybe I also should add that I'm trying to use polib to do the job.. 
But it doesn't matter
Only difference is that when using the objectfile
directly, instead of a LIB file I end up with just the one error..
The Linux gcc has the -fno-gnu-linker switch, but it seems that it is missing in MingW..
I think maybe that's the one I need...
From the gcc manual.
(Don't know my way around C++ that well anyway)
But it doesn't matter
directly, instead of a LIB file I end up with just the one error..
The Linux gcc has the -fno-gnu-linker switch, but it seems that it is missing in MingW..
I think maybe that's the one I need...
From the gcc manual.
So it seems I'm back to just C then.. Oh well.. :roll:-fno-gnu-linker
Do not output global initializations (such as C++ constructors and destructors) in the form used by the GNU linker (on systems where the GNU linker is the standard method of handling them). Use this option when you want to use a non-GNU linker.....
(Don't know my way around C++ that well anyway)
I fully understand what you're saying but have to disagree to a certain extent.KarLKoX wrote:It is not possible to use C++ code ! I played a lot with compilers to say this but this is not a purebasic limitation but as PureBasic use Pelles'C (wich is a C compiler/linker), we can't use C++.
It's of course not possible to simply write a C++ class and use this directly as a
PureLibrary but using a C++ Compiler can still have some advantages.
Try/catch, new/delete, d3d->Clear(...) instead of IDirect3DDevice_Clear(d3d,...) etc.
There're also ways to use C++ from within C - writing the required wrappers can
be a quite painful job, though.
So seeing it that way you can actually use C++ code (at least elements of it).
But as I initially said, I got your point.
(BTW: Is it OK to start an english sentence with 'but' ?
Good programmers don't comment their code. It was hard to write, should be hard to read.
-
dracflamloc
- Addict

- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
Let me get this straight (I'm new to pb userlibraries), lets say I have a DLL which has an exposed function i want PB to be able to call:
void Initialize()
{
Device* device=new Device();
device->createWindow();
}
Device is a C++ class provided in a header.
Can I use Initialize() in PB? Probably not, correct?
How would I go about making an Initialize() function that could be called from PB, that calls C++ object functions.
void Initialize()
{
Device* device=new Device();
device->createWindow();
}
Device is a C++ class provided in a header.
Can I use Initialize() in PB? Probably not, correct?
How would I go about making an Initialize() function that could be called from PB, that calls C++ object functions.
