Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] Trying to link my own static libarry
QtWS25 Last Chance

[solved] Trying to link my own static libarry

Scheduled Pinned Locked Moved General and Desktop
staticlibrarylinking
23 Posts 2 Posters 8.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tapsa
    wrote on last edited by Tapsa
    #1

    Hello guys!
    I've googled this evening converting my projects to Qt Creator.
    So far I managed to compile one static library, but it fails to link with another library I need it in.

    I have added these in my project file:
    INCLUDEPATH += "C:\Users\Tapsa"
    DEPENDPATH += "C:\Users\Tapsa"
    LIBS += "C:\Users\Tapsa\pcrio\release\libpcrio.a"

    I still get undefined reference to that library.
    I googled that those 3 lines, would solve this problem, but no.

    What else I need to do to link another Qt project?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Might be a silly question but did you check that both libraries are for the same architecture ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tapsa
        wrote on last edited by
        #3

        Yes it seems so. Both use same qmake build commands.

        qmake.exe C:\Users\Tapsa\pcrio\pcrio.pro -r -spec win32-g++
        qmake.exe C:\Users\Tapsa\genieutils\genieutils.pro -r -spec win32-g++

        Also whenever I set pcrio as a dependency for genieutils, it unchecks on itself.

        Earlier I accidentally created app from the pcrio lib at first.
        I then created lib project on top of it later. Is that a problem?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I'm not following you here, what did you create in what order ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tapsa
            wrote on last edited by
            #5

            I had used to compile my projects using CMake and MinGW.
            Then I downloaded and installed Qt Creator and compiled boost with zlib.
            I applied "qmake -project" "qmake" in my two libraries.
            I built my pcrio library and noticed that it output an executable.
            Then I created a library project with the same name over the pcrio and it compiled into library fine.
            I added build and library paths into genieutils project file pointing to pcrio and it gives me undefined references to my pcrio library.

            My sources are on GitHub so if somebody wants I can push my progress there to look at.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              If you have a cmake project working why not continue to use cmake ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • T Offline
                T Offline
                Tapsa
                wrote on last edited by
                #7

                Umm there was no option "create project from existing source using CMake".

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Because there's no need for that, just do "Open File or Project" and open your top-level CMakeFile.txt

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • T Offline
                    T Offline
                    Tapsa
                    wrote on last edited by Tapsa
                    #9

                    I did try that, but Qt didn't read any other files in :(
                    There are some errors too. I need to clear them first.

                    CMake Error at cmake/FindCheck.cmake:35 (MESSAGE):
                    Could NOT find CHECK

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Sorry, I meant CMakeLists.txt

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        Tapsa
                        wrote on last edited by Tapsa
                        #11

                        Aye. Thanks.
                        I managed to compile pcrio and zlib using CMakeLists.txt with Qt.
                        Why Qt only shows the CMakeLists.txt and no other files whatsoever?

                        It appears I managed to build both my libraries.
                        I had to manually tell both library files to CMake Wizard -.-

                        -DBoost_IOSTREAMS_LIBRARY_DEBUG:FILEPATH=C:/Boost/lib/libboost_iostreams-mgw49-mt-sd-1_58.a
                        -DBoost_IOSTREAMS_LIBRARY_RELEASE:FILEPATH=C:/Boost/lib/libboost_iostreams-mgw49-mt-s-1_58.a

                        How can it be so stupid that it can't see the files unless I toss them on its face?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          How do you list the files your CMakeLists.txt ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • T Offline
                            T Offline
                            Tapsa
                            wrote on last edited by
                            #13

                            https://github.com/Tapsa/pcrio/blob/master/CMakeLists.txt
                            https://github.com/Tapsa/genieutils/blob/master/CMakeLists.txt

                            For genieutils I passed some arguments to CMake:
                            -DBoost_IOSTREAMS_LIBRARY_DEBUG:FILEPATH=C:/Boost/lib/libboost_iostreams-mgw49-mt-sd-1_58.a
                            -DBoost_IOSTREAMS_LIBRARY_RELEASE:FILEPATH=C:/Boost/lib/libboost_iostreams-mgw49-mt-s-1_58.a
                            -DZLIB_LIBRARY:FILEPATH="C:\Cpp\zlib\libz.a"
                            -DZLIB_INCLUDE_DIR:PATH="C:\Cpp\zlib"
                            -DEXTERN_DIR:PATH="C:\Users\Tapsa"

                            Is there a better way?

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              You could try to use CMake's finder script for boost and zlib

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              1
                              • T Offline
                                T Offline
                                Tapsa
                                wrote on last edited by
                                #15

                                Yeah, but those fail.
                                find_package(Boost 1.58 COMPONENTS iostreams REQUIRED)
                                Even if I give as additional argument the boost library folder, it still fails to find it.
                                It hasn't complained about zlib yet for some reason.

                                Since Qt doesn't save additional arguments anywhere, do I need to put them into the CMakeLists.txt? I used batch scripts to compile my builds before.
                                Other people who compile my code probably have different paths. What is the best way to extract custom paths so that working with github is easy?

                                I have much more questions about Qt designer etc. You seem to be Qt professional. Do you suggest adding new topics as I proceed coding and googling or can you answer some Qt GUI questions?

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  You would have to give cmake additional paths to search for boost, but it's not something that you can really make generic since on Windows, there's no common place like on *nix systems. Using -DCMAKE_PREFIX_PATH can help.

                                  I can answer them however for other questions not directly related to this thread, you should rather open new topics. That will keep the forum easy to use and search for other users.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • T Offline
                                    T Offline
                                    Tapsa
                                    wrote on last edited by Tapsa
                                    #17

                                    LOL are you kidding me :D I had these lines AFTER find boost:

                                    set(Boost_USE_STATIC_LIBS ON)
                                    set(Boost_USE_MULTITHREADED ON)
                                    set(Boost_USE_STATIC_RUNTIME ON)

                                    Normally I don't even use this make file, but instead I use another for the actual program that uses these libraries. I moved those options above find boost and it works like a charm.

                                    Quick question: what is the fastest list box for over 10 000 items? It needs to have multiple selections and just be basic looking list box. Either it is not list view, or it needs to be adjusted a lot to achieve basic list box look.

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      What do you mean by "list box" ?

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      0
                                      • T Offline
                                        T Offline
                                        Tapsa
                                        wrote on last edited by
                                        #19

                                        Like the one in left in this picture:
                                        http://files.heavengames.com/aok/blacksmith/blobs/011002_.jpg
                                        You can see it has bunch of string items (with void pointers to data) and you can select many at once.

                                        It's from this program:
                                        http://aok.heavengames.com/blacksmith/showfile.php?fileid=11002

                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          If you are talking about the widget on the left, it looks like a QListView with extended selection enabled. What makes you think it needs to be adjusted a lot ?

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved