Hello,

I am trying to create a simple dll containing some qt code.
I thought that this would be easy, but somehow I am getting a compiler error telling me:

1>------ Build started: Project: dll_test, Configuration: Debug Win32 ------
1>Compiling...
1>moc_qtestdll.cpp
1>qtestdll.cpp
1>Generating Code...
1>Linking...
1> Creating library ..\..\libs\dll_test.lib and object ..\..\libs\dll_test.exp
1>qtmaind.lib(qtmain_win.obj) : error LNK2019: unresolved external symbol _main referenced in function _WinMain@16
1>..\..\libs\dll_test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\tmp\project\lab\dll_test\debug\BuildLog.htm"
1>dll_test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


It looks like that my Visual C++ compiler is trying to compile this as an apllication.

This is my code:

dll_test.pro

Qt Code:
  1. TEMPLATE = lib
  2. CONFIG += dll qt thread
  3.  
  4. # DEFINES only for Windows
  5. win32 {
  6. CONFIG(dll) {
  7. DEFINES += BUILD_DLL
  8. }
  9. }
  10.  
  11. # Input
  12. HEADERS += src/qtestdll.h
  13. SOURCES += src/qtestdll.cpp
To copy to clipboard, switch view to plain text mode 

qtestdll.h
Qt Code:
  1. #ifndef QTTESTDLL_H
  2. #define QTTESTDLL_H
  3.  
  4. #ifdef BUILD_DLL
  5. #define EXPORT_DLL Q_DECL_EXPORT // for Windows
  6. #else
  7. #define EXPORT_DLL
  8. #endif
  9.  
  10. #include <QtGui>
  11. #include <QObject>
  12.  
  13. class EXPORT_DLL myTestLib : public QObject {
  14. Q_OBJECT
  15. public:
  16. myTestLib() {};
  17. ~myTestLib(){};
  18. void printOut();
  19. };
  20. #endif
To copy to clipboard, switch view to plain text mode 

qtestdll.cpp
Qt Code:
  1. #include "qtestdll.h"
  2.  
  3. void myTestLib::printOut() {
  4. QMessageBox::information (
  5. NULL,
  6. QObject::tr("Yeahh"),
  7. QObject::tr("This message box comes"
  8. " from my dynamic library") );
  9. }
To copy to clipboard, switch view to plain text mode 

As usual I did qmake dll_test.pro and qmake -t vcapp to generate the Makefile and the Visual Studio project.

If anyone has an idea...