Results 1 to 4 of 4

Thread: Static Linking Issue WinXp MingW 4.5.1 Qt 4.7.1(static compiled)

  1. #1
    Join Date
    May 2009
    Posts
    56
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Post Static Linking Issue WinXp MingW 4.5.1 Qt 4.7.1(static compiled)

    Hi there,

    Has anybody experience problem while developing static libraries, with this setup?

    It seems that i have linking problem when i used a function within a library class "lib1" that use a function funLib2 within another library "lib2"(something like a wrapper library). if i called the lib1 fuction directly from the exe it is ok, but if called thru lib2 the linker says undefined reference.
    Qt Code:
    1. class lib1
    2. {
    3. public:
    4. void func1()
    5. {
    6. }
    7. }
    8. class lib2
    9. {
    10. public:
    11. void func2()
    12. {
    13. func1();
    14. }
    15. }
    16. class exeClassWorking
    17. {
    18. exeClass()
    19. {
    20. func1();
    21. }
    22. }
    23.  
    24. class exeClassWorking2
    25. {
    26. exeClass()
    27. {
    28. func1();
    29. func2();
    30. }
    31. }
    32. class exeClass_NOT_Working
    33. {
    34. exeClass()
    35. {
    36. func2();
    37. }
    38. }
    To copy to clipboard, switch view to plain text mode 

    I hope i could be clear, anyway i will be glad to detailed more in case needed.

    in all cases both lib have been include in the pro file.

    Any of this approach works when i compiled as shared.

  2. #2
    Join Date
    May 2011
    Posts
    23
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Static Linking Issue WinXp MingW 4.5.1 Qt 4.7.1(static compiled)

    It's very clear.

    How do your classes see each other's function objects ?

    Basically, be a bit more detailed.... maybe we can see what's missing?

  3. #3
    Join Date
    May 2009
    Posts
    56
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Static Linking Issue WinXp MingW 4.5.1 Qt 4.7.1(static compiled)

    sorry i forgot to specified that the function are static(s)

  4. #4
    Join Date
    May 2011
    Posts
    23
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Post Re: Static Linking Issue WinXp MingW 4.5.1 Qt 4.7.1(static compiled)

    OK well from what you've just said: This problem has nothing to do with Qt.
    It's a C++ problem.
    You need to understand that you cannot call a static function from your second library.
    Static functions are only accessible from within modules where they are declared and defined NOT accross library boundaries. That's why your exe can see it but your lib2 can't.
    IF you want to access this function from your second lib, you need to export it.

    I suggest you go read about how to export C++ functions/classes (if you haven't already done so).

    Alternatively, ask your question in any C++ forum, but it's not for here (No pun intended)

    Best of luck.

    Jean

  5. The following user says thank you to jeanremi for this useful post:

    cafu1007 (9th June 2011)

Similar Threads

  1. VC static linking lib with another lib
    By Mookie in forum General Programming
    Replies: 4
    Last Post: 23rd November 2010, 08:10
  2. Static linking with Qt
    By prykHetQuo in forum Qt Programming
    Replies: 3
    Last Post: 3rd June 2009, 20:56
  3. Replies: 3
    Last Post: 6th March 2008, 11:55
  4. static linking issue
    By ashwini in forum Qt Programming
    Replies: 2
    Last Post: 29th May 2006, 12:40
  5. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52

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.