Results 1 to 10 of 10

Thread: MS Visual C++ Linker warnings

  1. #1
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default MS Visual C++ Linker warnings

    Hello, All !

    I develop class library for linux and windows. Here is headers files
    searchengine.h
    Qt Code:
    1. #ifdef WIN32
    2. #define SEARCH_EXPORT __declspec(dllexport)
    3. #else
    4. #define SEARCH_EXPORT
    5. #endif
    6.  
    7. class SearchForm;
    8.  
    9. class SEARCH_EXPORT SearchEngine : public QObject
    10. {
    11. public:
    12. SearchEngine (QObject *parent=0);
    13. ...
    14. static SearchEngine* GUISetParams (QWidget *parent=0, Qt::WFlags f=0);
    15. ...
    16. private:
    17. SearchForm *sForm;
    18. ...
    19. private:
    20. Q_OBJECT
    21. };
    To copy to clipboard, switch view to plain text mode 
    searchform.h
    Qt Code:
    1. class SearchEngine;
    2.  
    3. class SearchForm : public QDialog
    4. {
    5. public:
    6. SearchForm (SearchEngine *se, QWidget *parent=0, Qt::WFlags f=0);
    7. ...
    8. private:
    9. SearchEngine *sEngine;
    10. ...
    11. private:
    12. Q_OBJECT
    13. };
    To copy to clipboard, switch view to plain text mode 
    Sources files are
    searchengine.cpp
    Qt Code:
    1. #include "searchengine.h"
    2. #include "searchform.h"
    3.  
    4. SEARCH_EXPORT SearchEngine * SearchEngine::self=0;
    5.  
    6. SearchEngine::SearchEngine (QObject *parent)
    7. : QObject (parent)
    8. {
    9. };
    10. ...
    11. SearchEngine* SearchEngine::GUISetParams (QWidget *parent, Qt::WFlags f)
    12. {
    13. SearchEngine *se = new SearchEngine ();
    14. se->sForm = new SearchForm (se);
    15. se->sForm->show ();
    16. return se;
    17. }
    To copy to clipboard, switch view to plain text mode 
    searchform.cpp
    Qt Code:
    1. SearchForm (SearchEngine *se, QWidget *parent, Qt::WFlags f) :
    2. QDialog (parent,f ),
    3. sEngine (se)
    4. {
    5. ...
    6. }
    7. ...
    To copy to clipboard, switch view to plain text mode 
    When I try to build project under Linux, all works fine, but if I try to do it under Windows, I receive some linkage warnings such this
    searchform.obj : warning LNK4217: locally defined symbol ?setTimeRange@SearchEngine@@QAEXABVQDateTime@@0@Z (public: void __thiscall SearchEngine::setTimeRange(class QDateTime const &,class QDateTime const &)) imported in function "private: void __thiscall SearchForm::Search(void)" (?Search@SearchForm@@AAEXXZ)
    ...
    function SearchEngine::setTimeRange (const QDateTime&, const QDateTime&) and others are defined in searchengine.cpp. Where is the troubles and which way I have to solve this problem ?

    Thanks in advance.
    Best regards,
    Yuriy Rusinov.

  2. #2
    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: MS Visual C++ Linker warnings


  3. #3
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: MS Visual C++ Linker warnings

    I try to do this, but nothing changes, when I try to
    Qt Code:
    1. #define SEARCH_EXPORT
    To copy to clipboard, switch view to plain text mode 
    I receive the same warnings.
    Best regards,
    Yuriy Rusinov.

  4. #4
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MS Visual C++ Linker warnings

    Maybe SearchEngine::setTimeRange() is inlined in your project - but to few code ...

  5. #5
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: MS Visual C++ Linker warnings

    No, this warnings are related to all functions of class SearchEngine, both inlined and calls.
    Best regards,
    Yuriy Rusinov.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: MS Visual C++ Linker warnings

    Is the problem about building the library which contains SearchEngine or a project which links to that library? It's just that the export macro definition looks insufficient to me. You should export when building the lib and import when using the lib. Try searching the forums for "Q_DECL_EXPORT" and "Q_DECL_IMPORT".
    J-P Nurmi

  7. #7
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MS Visual C++ Linker warnings

    This means that you link both, searchengine.cpp and searchform.cpp into one library/application. If this is the case there's no need for the import/export macros - just remove them.

  8. #8
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: MS Visual C++ Linker warnings

    I try to remove all these macro and receive the same warnings and 4 unresolved externals, search error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall SearchEngine::setTimeRange(class QDateTime const &,class QDateTime const &)" (__imp_?setTimeRange@SearchEngine@@QAEXABVQDateTim e@@0@Z) referenced in function "private: void __thiscall SearchForm::Search(void)" (?Search@SearchForm@@AAEXXZ). SearchForm
    has to be member of class SearchEngine and has to contains pointer onto SearchEngine object, if I build library without GUI therefore without any graphical forms, all built ok.
    Best regards,
    Yuriy Rusinov.

  9. #9
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MS Visual C++ Linker warnings

    You really should read what I write

    either you build a lib where searchengine.cpp is and leave the export macro like it is [b] or you don't build a lib, put searchengine.cpp into your app and remove the macro. What you currently do is that you have the export macro but also link searchengine.cpp to your app. Look into your pro-File (or whatever buildsystem you use) and you'll see!

  10. The following user says thank you to ChristianEhrlicher for this useful post:

    YuriyRusinov (6th December 2007)

  11. #10
    Join Date
    Apr 2006
    Location
    Saint-Petersburg, Russia
    Posts
    63
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: MS Visual C++ Linker warnings

    OK, thanks, I try to research this on examples, because this problem does not arise before despite of linkage with other libraries take place.
    Best regards,
    Yuriy Rusinov.

Similar Threads

  1. Qt configure with msvc.net
    By jivanr in forum Installation and Deployment
    Replies: 1
    Last Post: 11th June 2007, 08:17
  2. Compile App using OpenGL and Visual Studios 2003
    By Rayven in forum General Programming
    Replies: 3
    Last Post: 26th April 2007, 15:43
  3. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  4. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.