Re: Creating a DLL using Qt
Hi, This is not Qt Behavior. Please learn what is name mangling and when to use extern "C"
Re: Creating a DLL using Qt
Hi,
I know what name mangling is and the use of extern c
My two questions are
why does qt export all the functions inside the dll by default?
and why does qt export only the functions with '__declspec(dllexport)' declarations if I use it?
Regards
Re: Creating a DLL using Qt
Althor,
Quote:
why does qt export all the functions inside the dll by default?
1. Qt is not used/responsible to create your dll. It is just a toolkit to create gui's and do other common task in platform independent way.
2. Your compiler creates the dll. In windows you have to use __declspec(dllexport) or use a .def file to export a function from a dll.
The following link may be useful... ?
Creating a DLL using Qt is different from Creating a DLL to use with Qt App.
Re: Creating a DLL using Qt
Quote:
Originally Posted by
Althor
I don´t understand why qt has this behaviour.
Can you help me?
Regards.
The behaviour you describe has nothing to do with Qt. This is a behaviour of your compiler and linker. I assume from your conflation of Qt and compiler that you are using the Qt SDK for Windows, which bundles the MingW includes, GNU compiler and tools. From the GNU ld manual:
Quote:
_exporting DLL symbols_
The cygwin/mingw `ld' has several ways to export symbols for dll's.
_using auto-export functionality_
By default `ld' exports symbols with the auto-export
functionality, which is controlled by the following command
line options:
* -export-all-symbols [This is the default]
* -exclude-symbols
* -exclude-libs
* -exclude-modules-for-implib
* -version-script
When auto-export is in operation, `ld' will export all the
non-local (global and common) symbols it finds in a DLL, with
the exception of a few symbols known to belong to the
system's runtime and libraries. As it will often not be
desirable to export all of a DLL's symbols, which may include
private functions that are not part of any public interface,
the command-line options listed above may be used to filter
symbols out from the list for exporting. The `--output-def'
option can be used in order to see the final list of exported
symbols with all exclusions taken into effect.
If `--export-all-symbols' is not given explicitly on the
command line, then the default auto-export behavior will be
_disabled_ if either of the following are true:
* A DEF file is used.
* Any symbol in any object file was marked with the
__declspec(dllexport) attribute.
Re: Creating a DLL using Qt
Hi
Now I undestand this behaviour. I thought that qMake was the responsible for saying to g++ what methods must be exported.
All is clear now.
Thanks a lot guys.
My best regards.