Hi!

I am learning to create a DLL which will be used from no-qt apps and I have a doubt.

My dll has only a cpp file:

Qt Code:
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void hello3() {
  5. cout << "!!!Hello World 3!!!" << endl; // prints !!!Hello World!!!
  6. }
  7.  
  8. void hello2() {
  9. cout << "!!!Hello World 2!!!" << endl; // prints !!!Hello World!!!
  10. }
To copy to clipboard, switch view to plain text mode 

If I build the dll with that cpp file then my dll exports the following symbols:
Qt Code:
  1. _CRT_MT
  2. _Z6hello2v
  3. _Z6hello3v
  4. _get_output_format
To copy to clipboard, switch view to plain text mode 

It exports all the functions inside the dll.


But if I add export declaration to one of my functions
Qt Code:
  1. void hello3() {
  2. cout << "!!!Hello World 3!!!" << endl; // prints !!!Hello World!!!
  3. }
  4.  
  5. extern "C" __declspec(dllexport) void hello2() {
  6. cout << "!!!Hello World 2!!!" << endl; // prints !!!Hello World!!!
  7. }
To copy to clipboard, switch view to plain text mode 

then my dll exports only the symbol:
Qt Code:
  1. hello2
To copy to clipboard, switch view to plain text mode 

It only exports the functions I have delcared explicitily as exported. Why??



Finally, if I add the 'extern "C"' to all my functions
Qt Code:
  1. extern "C" void hello3() {
  2. cout << "!!!Hello World 3!!!" << endl; // prints !!!Hello World!!!
  3. }
  4.  
  5. extern "C" void hello2() {
  6. cout << "!!!Hello World 2!!!" << endl; // prints !!!Hello World!!!
  7. }
To copy to clipboard, switch view to plain text mode 

then the symbols exported are:

Qt Code:
  1. _CRT_MT
  2. _get_output_format
  3. hello2
  4. hello3
To copy to clipboard, switch view to plain text mode 


I don´t understand why qt has this behaviour.
Can you help me?

Regards.