Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Can't find library
Forum Updated to NodeBB v4.3 + New Features

Can't find library

Scheduled Pinned Locked Moved Installation and Deployment
7 Posts 3 Posters 45.8k Views 1 Watching
  • 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.
  • E Offline
    E Offline
    excaliberx18
    wrote on last edited by
    #1

    Hello everyone, I'm getting errors while trying to run a program in Qt that I believe is a linker problem:

    1. cannot find -lfuzzylite
    2. collect2: ld returned 1 exit status

    I've seen some thread on this already but I'm not very fluent in terms of C++ so it's hard for me to abstractly derive a solution from their problems. Here is the compiler output I'm getting:

    c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lfuzzylite
    collect2: ld returned 1 exit status
    mingw32-make.exe[1]: *** [debug\dist\gui.exe] Error 1
    mingw32-make.exe: *** [debug] Error 2
    21:42:33: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project gui (target: Desktop)
    When executing build step 'Make'

    I need to run this GUI for a research project so any help would be much appreciated. Thanks.

    Edit: Sorry I accidently posted this w/o finishing so I added the rest

    1 Reply Last reply
    0
    • U Offline
      U Offline
      uranusjr
      wrote on last edited by
      #2

      The error occurs because linker is unable to find the library. You need to explicitly instruct the linker where the library lies if it is not in the default search path.

      If you use qmake, you should add the following line in your .pro file:
      @
      INCLUDEPATH+=/path/to/libfuzzylite
      @
      in which "/path/to/libfuzzylite" stands for the directory where libfuzzylite.so lies.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        excaliberx18
        wrote on last edited by
        #3

        Thanks for the response. I have a a few questions however:

        First of all, what exactly is qmake?

        Secondly, what type of file extension would a library file have...I'm guessing .lib? I understand that this GUI code is trying to reference the actual source code that defines the fuzzy controller that I have in Visual Studio. If there is no library file, would I have to change the code I have in Visual Studio to a static library?

        Once again thanks a lot. I really appreciate the help. And sorry if my questions sound dumb. I'm kinda new to programming in general (esp. C++)

        1 Reply Last reply
        0
        • U Offline
          U Offline
          uranusjr
          wrote on last edited by
          #4

          (1) qmake is the tool used by Qt to assist you with the compiling. Typically, it reads the content from your .pro file, and generate compile parameters for the compiler. If you use an IDE (Qt Creator, Visual Studio, etc.), qmake is run behind the scenes when Creator thinks it's necessary. There are some "write-up":http://qt-project.org/doc/qt-4.8/qmake-manual.html in documentation about building a Qt application without assistance from IDE, which can make you familiar with those under-the-hood processing.

          (2) This really depends. On Windows, possible extensions are .lib, .dll, .a, and .so. Linking requires extensive writing to be explained, and is out of the scope of this forum. I would suggest reading books or tutorials about this, rather than a discussion here. "This":http://stackoverflow.com/questions/3364736/c-c-linking-tutorial seems like a good start. (Keeping in mind that MinGW is basically a Windows port of GCC, so the ideas are quite the same between them.)

          1 Reply Last reply
          0
          • E Offline
            E Offline
            excaliberx18
            wrote on last edited by
            #5

            Thanks a lot for the quick replies...I'm going to try what you mentioned earlier soon and see if it works. Thanks again.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

              You will need to set
              @LIBS += -L/path/to/libfuzzylite/library -lfuzzylite@
              as well as
              @INCLUDEPATH+=/path/to/libfuzzylite/headers@
              where "library" is the directory containing your the .dll, .so, .a and/or .lib files and "headers" the directory containing the .h files that come with fuzzylite.

              My guess based on your output is that both LIBS and INCLUDEPATH are set, but that the -L part is missing in LIBS.

              You might also have set everything set up correctly but with a version of fuzzylite built with a MSVC compiler. I am not a windows user myself, but IIRC msvc uses .lib/.dll while mingw uses .so/.a, so that might also be a problem. You need to build everything (your code, Qt and all other libraries you use) with the same (kind of) compiler on windows. Mixing mingw with MSVC binaries is not possible, neither is mixing binaries build with different versions of MSVC.

              1 Reply Last reply
              0
              • E Offline
                E Offline
                excaliberx18
                wrote on last edited by
                #7

                I tried adding the library with the LIBS += and INCUDEPATH+= with no apparent success. I'm thinking the problem may be specific to windows so I am going to try using the GUI in Ubuntu through Virtual Box.

                Thanks for repsonses, will update soon!

                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