473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DLLs using MinGW

Hi everybody:

I do not know if this is the right newsgroup for my issue, but I think
that someone here knows about this issue:

I am developing a set of libraries in C++ and I want to export my
classes into a .DLL using MinGW32. I know that I am able to export C
symbols but I'm not sure if class structures can be exported.

In Visual C++, I can use the __declspec(dllexport) and
__declspec(dllimport) class attributes to allow export (or import)
classes to/from DLLs. How can I do same stuff in mingw32???

If it is possible, the generated DLL will be linked to any application
compiled using MSVC++ or MinGW or the Borland C++ compiler, by
instance?

Thanks in advance

Ernesto
Jul 22 '05 #1
6 3144
"Ernesto" <eb*****@hotmail.com> wrote...
I do not know if this is the right newsgroup for my issue, but I think
that someone here knows about this issue:

I am developing a set of libraries in C++ and I want to export my
classes into a .DLL using MinGW32. I know that I am able to export C
symbols but I'm not sure if class structures can be exported.

In Visual C++, I can use the __declspec(dllexport) and
__declspec(dllimport) class attributes to allow export (or import)
classes to/from DLLs. How can I do same stuff in mingw32???

If it is possible, the generated DLL will be linked to any application
compiled using MSVC++ or MinGW or the Borland C++ compiler, by
instance?


I only have an answer to your last question (and even it contains some
kind of a disclaimer): in _my_experience_ compilers are not even compatible
at the binaries level from version to version, even less so from vendor
to vendor. Some, however, do claim object file compatibility, like Intel
to MS. But nothing like MinGW to MS or to Borland or vice versa.

Victor
Jul 22 '05 #2
Ernesto wrote:
[...]
I am developing a set of libraries in C++ and I want to export my
classes into a .DLL using MinGW32. I know that I am able to export C
symbols but I'm not sure if class structures can be exported.

In Visual C++, I can use the __declspec(dllexport) and
__declspec(dllimport) class attributes to allow export (or import)
classes to/from DLLs. How can I do same stuff in mingw32???

[...]

I'm not sure about that (and it's too compiler/platfrom-specific
anyway), but, FWIW, consider an alternative:

Declare a pure abstract base class X (all pure virtual functions,
no data). Provide an implementation of class XImpl: public X in the
shared library. Provide a factory function "X* createXInstance()"
(that one can be easily exported) to be called by the client.
The destruction is by a virtual member function or by reference
counting, and so on and so on, variations are certainly possible.

Compared to class exporting, this approach means looser coupling
between dynamic/shared modules, and, I think, is more portable.
Of course you will still run into trouble if your modules use
incompatible ABIs in regards to virtual table layout and calling
conventions, and, unfortunately, you won't know it until run-time.
Still I think that class exporting is somewhat overrated.

Denis
Jul 22 '05 #3

VB> I only have an answer to your last question (and even it contains some
VB> kind of a disclaimer): in _my_experience_ compilers are not even
VB> compatible at the binaries level from version to version, even less so
VB> from vendor to vendor. Some, however, do claim object file
VB> compatibility, like Intel to MS. But nothing like MinGW to MS or to
VB> Borland or vice versa.

I've linked .a (library) files generated by MinGW successfully using MSVC++.
It didn't seem to be too difficult, as I remember. You may need to use
stdcall convention, but it's been a while and the memory is a little hazy.

Ryan
Jul 22 '05 #4
Victor Bazarov wrote:
"Ernesto" <eb*****@hotmail.com> wrote...
I do not know if this is the right newsgroup for my issue, but I think
that someone here knows about this issue:

I am developing a set of libraries in C++ and I want to export my
classes into a .DLL using MinGW32. I know that I am able to export C
symbols but I'm not sure if class structures can be exported.

In Visual C++, I can use the __declspec(dllexport) and
__declspec(dllimport) class attributes to allow export (or import)
classes to/from DLLs. How can I do same stuff in mingw32???

If it is possible, the generated DLL will be linked to any application
compiled using MSVC++ or MinGW or the Borland C++ compiler, by
instance?

I only have an answer to your last question (and even it contains some
kind of a disclaimer): in _my_experience_ compilers are not even compatible
at the binaries level from version to version, even less so from vendor
to vendor.


Getting more off-topic, but FWIW, in my thus far limited experience with
VS.NET 2003, its generated DLLs are interoperable with VC++6 code,
including exported C++ classes.

--
Mike Smith
Jul 22 '05 #5
Ryan Mitchley wrote:
VB> I only have an answer to your last question (and even it contains some
VB> kind of a disclaimer): in _my_experience_ compilers are not even
VB> compatible at the binaries level from version to version, even less so
VB> from vendor to vendor. Some, however, do claim object file
VB> compatibility, like Intel to MS. But nothing like MinGW to MS or to
VB> Borland or vice versa.

I've linked .a (library) files generated by MinGW successfully using MSVC++.
It didn't seem to be too difficult, as I remember. You may need to use
stdcall convention, but it's been a while and the memory is a little hazy.


For C functions this will work, yes. It will not work for exported C++
classes (I've tried).

--
Mike Smith
Jul 22 '05 #6
Mike Smith wrote:
[...]
Getting more off-topic, but FWIW, in my thus far limited experience with
VS.NET 2003, its generated DLLs are interoperable with VC++6 code,
including exported C++ classes.


I'd be very surprised if it didn't (bad business practice, really) but
I've seen it happen. The whole point is since the Standard doesn't
require it, no guarantees can be given. Hell, no guarantees can be
given even for what Standard does require...

Victor
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joonas Paalasmaa | last post by:
Hi, When compiling Sketch's streamfilter C extension the errors below are raised during linking. What could cause the errors? (Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98) Here are...
4
by: John Hunter | last post by:
I am using distutils to build a python extension module on win32. I initialize the Extension class with a list of libraries with Extension("_gd", , include_dirs=incdirs, library_dirs=libdirs,...
188
by: Ilias Lazaridis | last post by:
I'm a newcomer to python: - E01: The Java Failure - May Python Helps? http://groups-beta.google.com/group/comp.lang.python/msg/75f0c5c35374f553 - I've download (as suggested) the python...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
6
by: m.arfini | last post by:
Hi All, i trying to compile ffmpeg v 0.4.9. with minGW compiler with make instruction, but at the end of the process none dlls have been created, only the exe file (in c:\program files\ffmpeg...
6
by: m.arfini | last post by:
Hi All, i trying to compile ffmpeg v 0.4.9. with minGW compiler with make instruction, but at the end of the process none dlls have been created, only the exe file (in c:\program files\ffmpeg...
2
by: wd.jonsson | last post by:
Hello! I must be doing something wrong here because I'm getting all these missing .dll messages after installing PyQT. This is what I've done (no step excluded): 1. Fresh installation of...
6
by: Brandon McCombs | last post by:
Hello, Yesterday I just started using Visual C# 2005 Express Edition and I'm trying to load external DLLs. I started out with trying to load just one like so: static extern void...
22
by: phil.pellouchoud | last post by:
I did some searching online and i couldn't find anything in reference to this. I am using MinGW, gcc 4.3 and am having the following compilation issue: class CFoo { public: ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.