Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to set library path for qtcreator in Ubuntu ?
Forum Update on Monday, May 27th 2025

How to set library path for qtcreator in Ubuntu ?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
9 Posts 5 Posters 9.2k 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.
  • L Offline
    L Offline
    laine
    wrote on last edited by
    #1

    Hi, I develop software with QtCreator 4.10.2 on Ubuntu 18.04.
    It works greatly.

    The project is managed by cmake. and the qt version is 5.9.

    But I encountered problems when I tried to debug the program.

    The message in "Application Output" is error while loading shared libraries: ***.so: cannot open shared object file: No such file or directory

    But

    1. If I started the program from terminal, the program works normally

    2. I tried to clear build-directory of project and delete *.user in source directory, but the problem still exists when I rebuild project from source

    3. I manually add library paths into PATH in Projects->Run->Run Environment, it still doesn't work.

    4. I manually add library paths in to Kit configurations, it still doesn't work.

    5. If manually add LD_LIBRARY_PATH in Projects->Run->Run Environment, it works.


    So, What should I do to let qtcreator load LD_LIBRARY_PATH automatically ?

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

      Hi,

      One way is to start it from the console where you defined that variable.

      However if you defined it system wide, it should be picked up automatically unless you modified the environment.

      Note that PATH has nothing to do with library loading on Linux. It's only for executable discovery.

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

      L 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        One way is to start it from the console where you defined that variable.

        However if you defined it system wide, it should be picked up automatically unless you modified the environment.

        Note that PATH has nothing to do with library loading on Linux. It's only for executable discovery.

        L Offline
        L Offline
        laine
        wrote on last edited by
        #3

        @SGaist Yeah, I set LD_LIBRARY_PATH for target libraries. And I even reboot ubuntu for several times, but the problem still exists.

        I start QtCreator from dock.

        Can this be the reason ?

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

          How did you set that variable ?
          By the way, what is that library ?

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

          L 1 Reply Last reply
          0
          • SGaistS SGaist

            How did you set that variable ?
            By the way, what is that library ?

            L Offline
            L Offline
            laine
            wrote on last edited by
            #5

            @SGaist my project requires some 3rd libraries to run. Such as qt, vtk, and etc.
            First, I set LD_LIBRARY_PATH in ~/.bashrc, which doesnot work, just as I explained before
            Then, I manually add LD_LIBRARY_PATH in (current open project of QtCreator) Projects->Run->Run Environment, it works. Just as step 5 shown.

            I start QtCreator from Ubuntu dock.
            Can this be the reason ?

            jsulmJ 1 Reply Last reply
            0
            • L laine

              @SGaist my project requires some 3rd libraries to run. Such as qt, vtk, and etc.
              First, I set LD_LIBRARY_PATH in ~/.bashrc, which doesnot work, just as I explained before
              Then, I manually add LD_LIBRARY_PATH in (current open project of QtCreator) Projects->Run->Run Environment, it works. Just as step 5 shown.

              I start QtCreator from Ubuntu dock.
              Can this be the reason ?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @laine said in How to set library path for qtcreator in Ubuntu ?:

              I set LD_LIBRARY_PATH in ~/.bashrc

              Can you show how exactly you're doing this?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              L 1 Reply Last reply
              0
              • jsulmJ jsulm

                @laine said in How to set library path for qtcreator in Ubuntu ?:

                I set LD_LIBRARY_PATH in ~/.bashrc

                Can you show how exactly you're doing this?

                L Offline
                L Offline
                laine
                wrote on last edited by laine
                #7

                @jsulm I set with following code in ~/.bashrc

                export PATH=$PATH:~/libraries/qt-5-91/5.9.1/gcc_64/bin
                export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/libraries/qt-5-91/5.9.1/gcc_64/lib
                export QTDIR=~/libraries/qt-5-91/5.9.1/gcc_64
                

                By the way, if I start qtcreator from shell, it works.

                JonBJ 1 Reply Last reply
                0
                • L laine

                  Hi, I develop software with QtCreator 4.10.2 on Ubuntu 18.04.
                  It works greatly.

                  The project is managed by cmake. and the qt version is 5.9.

                  But I encountered problems when I tried to debug the program.

                  The message in "Application Output" is error while loading shared libraries: ***.so: cannot open shared object file: No such file or directory

                  But

                  1. If I started the program from terminal, the program works normally

                  2. I tried to clear build-directory of project and delete *.user in source directory, but the problem still exists when I rebuild project from source

                  3. I manually add library paths into PATH in Projects->Run->Run Environment, it still doesn't work.

                  4. I manually add library paths in to Kit configurations, it still doesn't work.

                  5. If manually add LD_LIBRARY_PATH in Projects->Run->Run Environment, it works.


                  So, What should I do to let qtcreator load LD_LIBRARY_PATH automatically ?

                  P Offline
                  P Offline
                  paulf
                  wrote on last edited by paulf
                  #8

                  @laine

                  Personally I advise against using LD_LIBRARY_PATH in any situation. Here is an example of why you should not do this. At work we use an in house build of GCC that is badly done and relies on LD_LIBRARY_PATH. If I use our standard setup, then I can't execute qtcreator because there is a conflict in the versions of libstdc++ caused by our LD_LIBRARY_PATH. If I unset LD_LIBRARY_PATH, I can run qtcreator fine. But then when I try to build any software, our tools that need their LD_LIBRARY_PATH don't work. In this case I can add the LD_LIBRARY_PATH to the build environment. Alternatively you end up with each app being launched with a wrapper script that sets LD_LIBRARY_PATH.

                  There is a better way. RPATH. See this topic on SO. Effectively this bakes in the correct library search path into your executable.

                  1 Reply Last reply
                  1
                  • L laine

                    @jsulm I set with following code in ~/.bashrc

                    export PATH=$PATH:~/libraries/qt-5-91/5.9.1/gcc_64/bin
                    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/libraries/qt-5-91/5.9.1/gcc_64/lib
                    export QTDIR=~/libraries/qt-5-91/5.9.1/gcc_64
                    

                    By the way, if I start qtcreator from shell, it works.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @laine
                    I don't know if this is your problem/you are already aware, but do you understand that .bashrc is not always read? It's only read in when bash is started interactively (like a terminal shell). Do you need to check if your .profile/.bash_profile is source-ing it?

                    1 Reply Last reply
                    1

                    • Login

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