Results 1 to 20 of 28

Thread: project with a dll and a testprog (doesn't compile)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    can't you send us the very last lines of compilation output? Those which would inform us of the linking process... If I remember well, under Windows, a missing symbol (e.g. a function defined but not implemented) can prevent the import library from being created...
    Current Qt projects : QCodeEdit, RotiDeCode

  2. #2
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Qt Code:
    1. compiling, compiling blabla...
    2. cl -c -nologo -Zm200 -GS -O2 -MD -DNDEBUG -GR -EHsc -W3 -DUNICODE -DQT_L
    3. ARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
    4. -DQT_THREAD_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_XML_LIB -DQT_OPENGL_LIB -DQT_GUI
    5. _LIB -DQT_CORE_LIB -I"c:\qt\include\QtCore" -I"c:\qt\include\QtCore" -I"c:\qt\in
    6. clude\QtGui" -I"c:\qt\include\QtGui" -I"c:\qt\include\QtOpenGL" -I"c:\qt\include
    7. \QtOpenGL" -I"c:\qt\include\QtXml" -I"c:\qt\include\QtXml" -I"c:\qt\include" -I"
    8. c:\qt\include\ActiveQt" -I"release" -I"." -I"c:\qt\mkspecs\win32-msvc2005" -Fore
    9. lease\ @C:\DOKUME~1\damdam\LOKALE~1\Temp\nm2.tmp
    10. moc_widget.cpp
    11. moc_layout.cpp
    12. moc_glwidget.cpp
    13. moc_graphicsobject.cpp
    14. Code is getting generated... //orig german: Code wird generiert..
    15. link /LIBPATH:"c:\qt\lib" /NOLOGO /DLL /MANIFESTFILE:"release\calina.int
    16. ermediate.manifest" /incremental:no /OUT:"..\bin\calina.dll" @C:\DOKUME~1\damdam
    17. \LOKALE~1\Temp\nm3.tmp
    18. mt.exe -nologo -manifest "release\calina.intermediate.manifest" -outputr
    19. esource:..\bin\calina.dll;2
    To copy to clipboard, switch view to plain text mode 

    There are some warnings because of converting double to float, but i don't think that should make any difference..

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    C:\environments\tests\libtest>nmake

    Microsoft (R) Program Maintenance Utility Version 7.10.3077
    Copyright (C) Microsoft Corporation. All rights reserved.

    nmake -f Makefile.Debug

    Microsoft (R) Program Maintenance Utility Version 7.10.3077
    Copyright (C) Microsoft Corporation. All rights reserved.

    cl -c -nologo -Zm300 -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -D
    WIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUP
    PORT -I"..\..\..\Qt\4.3.0rc1\include\QtCore" -I"..\..\..\Qt\4.3.0rc1\include\QtC
    ore" -I"..\..\..\Qt\4.3.0rc1\include\QtGui" -I"..\..\..\Qt\4.3.0rc1\include\QtGu
    i" -I"..\..\..\Qt\4.3.0rc1\include" -I"." -I"..\..\..\Qt\4.3.0rc1\include\Active
    Qt" -I"debug" -I"." -I"..\..\..\Qt\4.3.0rc1\mkspecs\default" -Fodebug\ @D:\DOCUM
    E~1\Marcel\LOCALS~1\Temp\nm76E.tmp
    libtest.cpp
    libtest.cpp(4) : warning C4273: 'libtest::libtest' : inconsistent dll linkage
    libtest.cpp(9) : warning C4273: 'libtest::~libtest' : inconsistent dll linkage
    link /LIBPATH:"c:\Qt\4.3.0rc1\lib" /NOLOGO /DEBUG /DLL /OUT:debug\libtes
    t.dll @D:\DOCUME~1\Marcel\LOCALS~1\Temp\nm76F.tmp
    Creating library debug\libtest.lib and object debug\libtest.exp

    C:\environments\tests\libtest>
    ################################################## ####################
    # Automatically generated by qmake (2.01a) Tue Jul 24 22:10:16 2007
    ################################################## ####################

    TEMPLATE = lib
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .

    # Input
    HEADERS += libtest.h libtest_global.h
    SOURCES += libtest.cpp
    That is what you should get.

    Regards

  4. #4
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    I now have nearly the same pro file (only some more headers and sources), I have even dropped the double->floats and the opengl support.

    But the lib files are still not generating..


    Edit: I now see, that there is a difference. I have VS 8 (2005, no sp1) and you 7 (afaik 2003). Is that importand?

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Can you post the code for the library?

    The problem must lie there.

    Regards

  6. #6
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    here you are..
    and thanks for looking into it..
    Attached Files Attached Files

  7. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Yes. You didn't export anything for the library so the linker didn't need to create a lib.
    You have to add Q_DECL_EXPORT to every class you want to export.
    Something like:
    Qt Code:
    1. //==========================================================//
    2. // //
    3. // Diplomprojekt Calina (platformuebergreifende 3d GUI) //
    4. // //
    5. //==========================================================//
    6. // Autoren: Adam Celarek (diplom_arbeit at xibo at) //
    7. // Patrick Freninger () //
    8. // Sebastian Raggl () //
    9. //==========================================================//
    10.  
    11. /***************************************************************************
    12.  * This program is free software; you can redistribute it and/or modify *
    13.  * it under the terms of the GNU General Public License as published by *
    14.  * the Free Software Foundation; either version 2 of the License, or *
    15.  * (at your option) any later version. *
    16.  * *
    17.  * This program is distributed in the hope that it will be useful, *
    18.  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
    19.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
    20.  * GNU General Public License for more details. *
    21.  * *
    22.  * You should have received a copy of the GNU General Public License *
    23.  * along with this program; if not, write to the *
    24.  * Free Software Foundation, Inc., *
    25.  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
    26.  ***************************************************************************/
    27. #ifndef CALINAGLWIDGET_H
    28. #define CALINAGLWIDGET_H
    29.  
    30. #include <QGLWidget>
    31. #include "helper.h"
    32.  
    33. namespace calina {
    34.  
    35. /**
    36.  * @brief
    37.  *
    38.  *
    39.  *
    40.  * @author Adam Celarek <testman@xibo.at>
    41.  * @todo Dokumentation von da Klassn.. Wegn Prototyp deadline keine Zeit..
    42.  */
    43.  
    44. class World;
    45.  
    46. class [B]Q_DECL_EXPORT[/B] GLWidget : public QGLWidget {
    47. Q_OBJECT
    48. public:
    49. GLWidget(WidgetList& widgetList, QObject *parent = 0);
    50. ~GLWidget();
    51.  
    52. void initializeGL();
    53. void resizeGL(int w, int h);
    54. void paintGL();
    55. World* parentWorld() const;
    56.  
    57. private:
    58. WidgetList& p_widgetList;
    59. };
    60.  
    61. }
    62.  
    63. #endif
    To copy to clipboard, switch view to plain text mode 

    I added them and got:
    Generating Code...
    cl -c -nologo -Zm300 -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -D
    WIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_XML_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB
    -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\4.3.0rc1\include\QtCore" -I"c:\Qt\4.3
    .0rc1\include\QtCore" -I"c:\Qt\4.3.0rc1\include\QtGui" -I"c:\Qt\4.3.0rc1\include
    \QtGui" -I"c:\Qt\4.3.0rc1\include\QtOpenGL" -I"c:\Qt\4.3.0rc1\include\QtOpenGL"
    -I"c:\Qt\4.3.0rc1\include\QtXml" -I"c:\Qt\4.3.0rc1\include\QtXml" -I"c:\Qt\4.3.0
    rc1\include" -I"." -I"c:\Qt\4.3.0rc1\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\
    4.3.0rc1\mkspecs\default" -Fodebug\ @D:\DOCUME~1\Marcel\LOCALS~1\Temp\nm783.tmp
    moc_glwidget.cpp
    moc_graphicsobject.cpp
    moc_layout.cpp
    moc_widget.cpp
    Generating Code...
    link /LIBPATH:"c:\Qt\4.3.0rc1\lib" /NOLOGO /DEBUG /DLL /OUT:debug\calina
    .dll @D:\DOCUME~1\Marcel\LOCALS~1\Temp\nm784.tmp
    Creating library debug\calina.lib and object debug\calina.exp

    D:\Documents and Settings\Marcel\Desktop\calina\calina\calina>

  8. #8
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Quote Originally Posted by marcel View Post
    Yes. You didn't export anything for the library so the linker didn't need to create a lib.
    You have to add Q_DECL_EXPORT to every class you want to export.
    Nice catch! however the solution isn't that simple... If Q_DECL_EXPORT is put then the linking of any prog against that lib will most probably fail... Either you already have a kind of config header file which is included by all other headers or you got to create one. Then place something like this in it :
    Qt Code:
    1. #ifdef _CALINA_LIB_BUILD_
    2. #if defined(QT_DLL) || defined(QT_SHARED)
    3. #define CALINA_EXPORT Q_DECL_EXPORT
    4. #else
    5. #define CALINA_EXPORT
    6. #endif
    7. #else
    8. #define CALINA_EXPORT Q_DECL_IMPORT
    9. #endif
    To copy to clipboard, switch view to plain text mode 
    Then place "DEFINES += CALINA_LIB_BUILD" inside the project file of the dll.
    And finally update all headers of the dll, as suggested by marcel but using CALINA_EXPORT instead of Q_DECL_EXPORT...
    Current Qt projects : QCodeEdit, RotiDeCode

  9. #9
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    It's even simpler, but I skipped this part because I figured he will always build the library alone, so only Q_DECL_EXPORT will be needed.
    Just add this to a header and include it in all the exported classes headers:
    Qt Code:
    1. #ifndef CALINA_GLOBAL_H
    2. #define CALINA_GLOBAL_H
    3.  
    4. #include <Qt/qglobal.h>
    5.  
    6. #ifdef CALINA_LIB
    7. # define CALINA_EXPORT Q_DECL_EXPORT
    8. #else
    9. # define CALINA_EXPORT Q_DECL_IMPORT
    10. #endif
    11.  
    12. #endif // CALINA_GLOBAL_H
    To copy to clipboard, switch view to plain text mode 
    You will have to prepend CALINA_EXPORT instead of Q_DECL_EXPORT.
    Also you have to add CALINA_LIB to the list of preprocessor definitions each time you want to build the lib.

    Regards

  10. #10
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Quote Originally Posted by marcel View Post
    It's even simpler, but I skipped this part because I figured he will always build the library alone, so only Q_DECL_EXPORT will be needed.
    Just add this to a header and include it in all the exported classes headers:
    I don't recommend making it that simple because in case someone wants to embed the lib in another program (not link) then he will face weird linking errors (either he put the CALINA_BUILD and he is supposed to export symbols but how does an app achieve that? or he forget it and the linker search for exported symbols in an import library that of course does not exist...
    Current Qt projects : QCodeEdit, RotiDeCode

  11. #11
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Yes, you have your point too.
    I guess he will use whatever he needs from what we've posted, since everything is pretty much covered.

    Regards

  12. The following user says thank you to marcel for this useful post:

    aMan (25th July 2007)

  13. #12
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Thank you for your answers, I'll try it tomorrow..

    I suppose that macro is only needed on windows and vs, right? I had no problems on Linux or on MinGW. How does this work with the gcc, why vs needs the macros and gcc not?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.