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. [Solved] Can run project from qtcreator but not from commandline: lib not found
QtWS25 Last Chance

[Solved] Can run project from qtcreator but not from commandline: lib not found

Scheduled Pinned Locked Moved Installation and Deployment
6 Posts 2 Posters 1.8k 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.
  • G Offline
    G Offline
    gbonnema
    wrote on last edited by
    #1

    I use QtCreator to develop a project with several subdirectories that each produce a library, and some subdirectories that each produce an executable. From QtCreator I can run each of the executables fine.

    From the commandline however, I get link errors: the system cannot find my own libraries. If I run ldd I get "not found" on my own library.

    The weird thing is that everything runs from Qtcreator, so apparantly the .pro files are ok. But why can't I run the executables from the commandline?

    Can anyone point me in the right direction? Of course if you need more info (like the pro files) I would happily provide them.

    Kind regards, Guus.

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

      Hi,

      Qt Creator setup the environment for you so you are sure to use the correct version of Qt. Since you are running it outside you either need to take the same steps as you would for deploying your application or modify your current shell environment (don't do it system wide) in order to find the Qt libraries (LD_LIBRARY_PATH)

      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
      • G Offline
        G Offline
        gbonnema
        wrote on last edited by
        #3

        It can find the Qt libraries fine, that's not the problem. It finds all system libraries ok.

        The problem is my own libraries. The one that are part of my project. It can't find those.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gbonnema
          wrote on last edited by
          #4

          I think I understand at least partially what is going on. My personal libraries are not in the system library path, so either I have to install them in /usr/lib64 or /usr/local/lib64 or I need to add the subdir that contains my libs to the library path.

          edit: will just have to add my subdirs to the LD_LIBRARY_PATH, even if temporarily. The way I do it now is to locally export the variable and subsequently use it. When the shell ends, the variable is unset.

          $> export LD_LIBRARY_PATH=../test:../model
          $> ./<executable-name>
          

          provided of course that the libraries are in ../test and ../model and the executable is in the current directory. If you use a script, you might want to use absolute paths. Alternatively do:

          $> LD_LIBRARY_PATH=../test:../model; ./<executable-name>
          

          @@

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

            Modify LD_LIBRARY_PATH, never pollute your system. If you want to run it from the command line you can use e.g. a bash script that setup the environment and call your application so you don't do any nasty stuff to your OS

            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
            • G Offline
              G Offline
              gbonnema
              wrote on last edited by
              #6

              SGaist: thanks for the answers. I changed the post to solved. On retrospect using LD_LIBRARY_PATH made it fairly easy to solve.

              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