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. Adding Boost to Creator
Forum Updated to NodeBB v4.3 + New Features

Adding Boost to Creator

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 4 Posters 2.3k 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.
  • JonBJ JonB

    @A123
    There is something we do not understand going on here. In principle given that you have #include<boost/algorithm/string.hpp> it should be picking that up /usr/include/boost/algorithm/string.hpp.

    Please open a terminal somewhere (some other empty directory within your /home area). Create file.cpp containing just:

    #include <boost/algorithm/string.hpp>
    

    (It should make no difference, but I have put a space before the <). Now just type in

    g++ -c file.cpp
    

    What do you get?

    Then try:

    g++ -c -I/usr/include fred.cpp
    

    Now try changing the <..> to "...", i.e. #include "boost/algorithm/string.hpp" with that second command-line again.

    Finally, try #include "/usr/include/boost/algorithm/string.hpp", so the -I... argument is irrelevant.

    Obviously we are only interested in what the compiler has to say about the #include line. I have suggested 4 things to try here. Do any of these work? Which work/fail?

    A Offline
    A Offline
    A123
    wrote on last edited by A123
    #10

    @JonB

    All work to generate file.o except

    g++ -c -I/usr/include fred.cpp which has no such file or directory

    JonBJ 1 Reply Last reply
    0
    • A A123

      @JonB

      All work to generate file.o except

      g++ -c -I/usr/include fred.cpp which has no such file or directory

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

      @A123

      g++ -c -I/usr/include fred.cpp which has no such file or directory

      Well, that somehow looks like the situation you seem to be in from Creator.

      What I really don't get is you are saying

      g++ -c file.cpp
      

      does work, while

      g++ -c -I/usr/include fred.cpp
      

      does not. Please confirm this is indeed exactly the case? It is vital we are 100% clear on this.

      Now that is weird, because the -I... only adds directories to search. Since you say it worked OK without this I cannot understand how adding could prevent the file being found.

      Next test:

      g++ -c -I/rubbish file.cpp    # then does this work or fail??
      

      I also asked you to try changing the #include from <...> to "...". Did you do that? I am only interested if that made it behave differently in any case?

      A 1 Reply Last reply
      0
      • JonBJ JonB

        @A123

        g++ -c -I/usr/include fred.cpp which has no such file or directory

        Well, that somehow looks like the situation you seem to be in from Creator.

        What I really don't get is you are saying

        g++ -c file.cpp
        

        does work, while

        g++ -c -I/usr/include fred.cpp
        

        does not. Please confirm this is indeed exactly the case? It is vital we are 100% clear on this.

        Now that is weird, because the -I... only adds directories to search. Since you say it worked OK without this I cannot understand how adding could prevent the file being found.

        Next test:

        g++ -c -I/rubbish file.cpp    # then does this work or fail??
        

        I also asked you to try changing the #include from <...> to "...". Did you do that? I am only interested if that made it behave differently in any case?

        A Offline
        A Offline
        A123
        wrote on last edited by A123
        #12

        @JonB

        I have file.cpp in sampleproject in the home directory. There is no fred.cpp file.

        g++ -c -I/usr/include fred.cpp
        

        gives me

        cc1plus: fatal error: fred.cpp: No such file or directory
        compilation terminated.
        
        g++ -c file.cpp
        

        works to generate file.o

        g++ -c -I/rubbish file.cpp
        

        works

        changing from <> to "" surrounding the include works.

        I tried to start a new project in QT creator with file.cpp and the boost include was still not picked up.
        In addition there is no usr/include in the system PATH variable when I

        echo $PATH
        

        Not sure if that matters

        This is Linux Mint 21 BTW

        JonBJ 1 Reply Last reply
        0
        • A A123

          @JonB

          I have file.cpp in sampleproject in the home directory. There is no fred.cpp file.

          g++ -c -I/usr/include fred.cpp
          

          gives me

          cc1plus: fatal error: fred.cpp: No such file or directory
          compilation terminated.
          
          g++ -c file.cpp
          

          works to generate file.o

          g++ -c -I/rubbish file.cpp
          

          works

          changing from <> to "" surrounding the include works.

          I tried to start a new project in QT creator with file.cpp and the boost include was still not picked up.
          In addition there is no usr/include in the system PATH variable when I

          echo $PATH
          

          Not sure if that matters

          This is Linux Mint 21 BTW

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

          @A123
          OK, I'm tired. Whenever I wrote file.cpp or fred.cpp they were supposed to be the same thing. I will try to stick to file.cpp.

          There are 4 combinations to try

          g++ -c -I/usr/include file.cpp  # where file.cpp contains <...>
          g++ -c -I/rubbish file.cpp  # where file.cpp contains <...>
          g++ -c -I/usr/include file.cpp  # where file.cpp contains "..."
          g++ -c -I/rubbish file.cpp  # where file.cpp contains "..."
          

          Can you clearly & unequivocally state which of these work and which fail?

          Now that you say plain g++ -c file.cpp works then why did you ever start adding things to INCLUDEPATH, that means it should have worked from the very start with nothing added?

          A 1 Reply Last reply
          1
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #14

            I'm really beginning to sense a corrupted g++ compiler instance here. The stuff being described just shouldn't happen!

            1 Reply Last reply
            0
            • JonBJ JonB

              @A123
              OK, I'm tired. Whenever I wrote file.cpp or fred.cpp they were supposed to be the same thing. I will try to stick to file.cpp.

              There are 4 combinations to try

              g++ -c -I/usr/include file.cpp  # where file.cpp contains <...>
              g++ -c -I/rubbish file.cpp  # where file.cpp contains <...>
              g++ -c -I/usr/include file.cpp  # where file.cpp contains "..."
              g++ -c -I/rubbish file.cpp  # where file.cpp contains "..."
              

              Can you clearly & unequivocally state which of these work and which fail?

              Now that you say plain g++ -c file.cpp works then why did you ever start adding things to INCLUDEPATH, that means it should have worked from the very start with nothing added?

              A Offline
              A Offline
              A123
              wrote on last edited by
              #15

              @JonB

              There are 4 combinations to try

              All 4 generate file.o

              Now that you say plain g++ -c file.cpp works then why did you ever start adding things to INCLUDEPATH, that means it should have worked from the very start with nothing added?

              I was trying to get things to work from the QT creator IDE which still doesn't work. When I tried things out through terminal like you suggested it is able to find the boost library for the simple example. So I think the problem is some setting within QT creator itself.

              For reference I am using QT creator 8.0.1, QT 6.3.1, and the QT6 Kit

              JonBJ 1 Reply Last reply
              0
              • A A123

                @JonB

                There are 4 combinations to try

                All 4 generate file.o

                Now that you say plain g++ -c file.cpp works then why did you ever start adding things to INCLUDEPATH, that means it should have worked from the very start with nothing added?

                I was trying to get things to work from the QT creator IDE which still doesn't work. When I tried things out through terminal like you suggested it is able to find the boost library for the simple example. So I think the problem is some setting within QT creator itself.

                For reference I am using QT creator 8.0.1, QT 6.3.1, and the QT6 Kit

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

                @A123 said in Adding Boost to Creator:

                All 4 generate file.o

                OK. Not sure that was the impression I got previously, but I get it now. That ought to be a good start!

                So I think the problem is some setting within QT creator itself.

                Creator does not do compiling itself. It is an IDE which calls on external tools (e.g. g++) to do compilations.

                Let's start by being 100.000% clear. Your screenshot shows errors. Do you indeed get these when you COMPILE ? If you only get these when looking at your source code in the IDE, not when you actually compile, now is the time to say so! That would be a totally different situation.... So please make this crystal clear?

                Assuming you get them when you allow Creator to invoke the compiler. Then in principle there are really/mostly only two things in Creator which affect this:

                • Show the actual command-line being issued to compile the file. You can find this in Creator on the Compiler Output pane.

                • There is a Build Environment setting. That allows environment variables to be passed to the compiler which we do not see on its command-line. Do you have anything of interest there?

                You could show these two.

                One other random thought: you do not have a sub-directory named boost in, say, your source directory, or perhaps one level above it, do you??

                You might also try the following from a terminal:

                find / -name boost -type d -print
                

                Does it only report one directory named boost? Just in /usr/include, nowhere else, right?

                Last thing: you might try setting up a brand new project in a brand new directory as a Qt project. Add only the file.cpp containing just the #include line. Try to compile. Success or failure?

                A 1 Reply Last reply
                1
                • JonBJ JonB

                  @A123 said in Adding Boost to Creator:

                  All 4 generate file.o

                  OK. Not sure that was the impression I got previously, but I get it now. That ought to be a good start!

                  So I think the problem is some setting within QT creator itself.

                  Creator does not do compiling itself. It is an IDE which calls on external tools (e.g. g++) to do compilations.

                  Let's start by being 100.000% clear. Your screenshot shows errors. Do you indeed get these when you COMPILE ? If you only get these when looking at your source code in the IDE, not when you actually compile, now is the time to say so! That would be a totally different situation.... So please make this crystal clear?

                  Assuming you get them when you allow Creator to invoke the compiler. Then in principle there are really/mostly only two things in Creator which affect this:

                  • Show the actual command-line being issued to compile the file. You can find this in Creator on the Compiler Output pane.

                  • There is a Build Environment setting. That allows environment variables to be passed to the compiler which we do not see on its command-line. Do you have anything of interest there?

                  You could show these two.

                  One other random thought: you do not have a sub-directory named boost in, say, your source directory, or perhaps one level above it, do you??

                  You might also try the following from a terminal:

                  find / -name boost -type d -print
                  

                  Does it only report one directory named boost? Just in /usr/include, nowhere else, right?

                  Last thing: you might try setting up a brand new project in a brand new directory as a Qt project. Add only the file.cpp containing just the #include line. Try to compile. Success or failure?

                  A Offline
                  A Offline
                  A123
                  wrote on last edited by A123
                  #17

                  @JonB

                  Let's start by being 100.000% clear. Your screenshot shows errors. Do you indeed get these when you COMPILE ? If you only get these when looking at your source code in the IDE, not when you actually compile, now is the time to say so! That would be a totally different situation.... So please make this crystal clear?

                  The line is labeled with a 'no such file or directory' error as soon as I paste it into the Creator code edit window. It pops up again in compile output when I attempt to build the project.

                  Assuming you get them when you allow Creator to invoke the compiler. Then in principle there are really/mostly only two things in Creator which affect this:

                  I put an empty file with the include in a sample project.

                  15:02:39: Running steps for project sampleproj2...
                  15:02:39: Starting: "/app/bin/qmake" /home/samp/sampleproj2/sampleproj2.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
                  15:02:39: The process "/app/bin/qmake" exited normally.
                  15:02:39: Starting: "/usr/bin/make" -f /home/samp/build-sampleproj2-Qt6-Debug/Makefile qmake_all
                  make: Nothing to be done for 'qmake_all'.
                  15:02:39: The process "/usr/bin/make" exited normally.
                  15:02:39: Starting: "/usr/bin/make" -j16
                  g++ -c -pipe -g -std=gnu++1z -Wall -Wextra -fPIC -DQT_QML_DEBUG -I../sampleproj2 -I. -I/app/mkspecs/linux-g++ -o file.o ../sampleproj2/file.cpp
                  ../sampleproj2/file.cpp:1:10: fatal error: boost/algorithm/string.hpp: No such file or directory
                      1 | #include <boost/algorithm/string.hpp>
                        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  compilation terminated.
                  make: *** [Makefile:875: file.o] Error 1
                  15:02:39: The process "/usr/bin/make" exited with code 2.
                  Error while building/deploying project sampleproj2 (kit: Qt6)
                  When executing step "Make"
                  15:02:39: Elapsed time: 00:00.
                  

                  There is a Build Environment setting. That allows environment variables to be passed to the compiler which we do not see on its command-line. Do you have anything of interest there?
                  be3.png be2.png be1.png

                  One other random thought: you do not have a sub-directory named boost in, say, your source directory, or perhaps one level above it, do you??

                  nope

                  Does it only report one directory named boost? Just in /usr/include, nowhere else, right?

                  sudo find / -name boost -type d -print
                  find: ‘/run/user/1000/doc’: Permission denied
                  find: ‘/run/user/1000/gvfs’: Permission denied
                  /usr/lib/python3/dist-packages/boost
                  /usr/lib/llvm-14/include/clang-tidy/boost
                  /usr/include/boost
                  /usr/include/boost/hana/ext/boost
                  /usr/include/boost/chrono/typeof/boost
                  

                  Last thing: you might try setting up a brand new project in a brand new directory as a Qt project. Add only the file.cpp containing just the #include line. Try to compile. Success or failure?

                  Failure as shown above.

                  JonBJ 1 Reply Last reply
                  0
                  • A A123

                    @JonB

                    Let's start by being 100.000% clear. Your screenshot shows errors. Do you indeed get these when you COMPILE ? If you only get these when looking at your source code in the IDE, not when you actually compile, now is the time to say so! That would be a totally different situation.... So please make this crystal clear?

                    The line is labeled with a 'no such file or directory' error as soon as I paste it into the Creator code edit window. It pops up again in compile output when I attempt to build the project.

                    Assuming you get them when you allow Creator to invoke the compiler. Then in principle there are really/mostly only two things in Creator which affect this:

                    I put an empty file with the include in a sample project.

                    15:02:39: Running steps for project sampleproj2...
                    15:02:39: Starting: "/app/bin/qmake" /home/samp/sampleproj2/sampleproj2.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
                    15:02:39: The process "/app/bin/qmake" exited normally.
                    15:02:39: Starting: "/usr/bin/make" -f /home/samp/build-sampleproj2-Qt6-Debug/Makefile qmake_all
                    make: Nothing to be done for 'qmake_all'.
                    15:02:39: The process "/usr/bin/make" exited normally.
                    15:02:39: Starting: "/usr/bin/make" -j16
                    g++ -c -pipe -g -std=gnu++1z -Wall -Wextra -fPIC -DQT_QML_DEBUG -I../sampleproj2 -I. -I/app/mkspecs/linux-g++ -o file.o ../sampleproj2/file.cpp
                    ../sampleproj2/file.cpp:1:10: fatal error: boost/algorithm/string.hpp: No such file or directory
                        1 | #include <boost/algorithm/string.hpp>
                          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    compilation terminated.
                    make: *** [Makefile:875: file.o] Error 1
                    15:02:39: The process "/usr/bin/make" exited with code 2.
                    Error while building/deploying project sampleproj2 (kit: Qt6)
                    When executing step "Make"
                    15:02:39: Elapsed time: 00:00.
                    

                    There is a Build Environment setting. That allows environment variables to be passed to the compiler which we do not see on its command-line. Do you have anything of interest there?
                    be3.png be2.png be1.png

                    One other random thought: you do not have a sub-directory named boost in, say, your source directory, or perhaps one level above it, do you??

                    nope

                    Does it only report one directory named boost? Just in /usr/include, nowhere else, right?

                    sudo find / -name boost -type d -print
                    find: ‘/run/user/1000/doc’: Permission denied
                    find: ‘/run/user/1000/gvfs’: Permission denied
                    /usr/lib/python3/dist-packages/boost
                    /usr/lib/llvm-14/include/clang-tidy/boost
                    /usr/include/boost
                    /usr/include/boost/hana/ext/boost
                    /usr/include/boost/chrono/typeof/boost
                    

                    Last thing: you might try setting up a brand new project in a brand new directory as a Qt project. Add only the file.cpp containing just the #include line. Try to compile. Success or failure?

                    Failure as shown above.

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

                    @A123
                    You have answered all my questions, but I'm sorry I just cannot spot what is wrong. You have shown:

                    • The file /usr/include/boost/algorithm/string.hpp really does exist.
                    • Sample programs with #include <boost/algorithm/string.hpp> compiled outside of Qt Creator work fine.
                    • Programs, including a standalone one-liner project, with that line compiled inside Creator complain "no such file".
                    • From Creator I cannot see anything significant in the command-line or the environment passed to g++ which would change the include search path behaviour.

                    You might just verify one thing. So far you have used #include <boost/algorithm/string.hpp> which ought find /usr/include/boost/algorithm/string.hpp. Go look just in directory /usr/include/boost/ and pick some other .hpp or .h file which lives at that level. I don't know what is there. Say there is a boostfile.hpp. Then try #include <boost/boostfile.hpp>. I presume that fails equally? Otherwise if that succeeds there is something about the particular string.hpp file/path.

                    Whatever the issue it should be something really simple! If I had your machine in front of me I would be confident of diagnosing whatever it is. But as it stands I am out of ideas. You will need someone else to look through with a fresh pair of eyes to see if they can spot what it might be.

                    A 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @A123
                      You have answered all my questions, but I'm sorry I just cannot spot what is wrong. You have shown:

                      • The file /usr/include/boost/algorithm/string.hpp really does exist.
                      • Sample programs with #include <boost/algorithm/string.hpp> compiled outside of Qt Creator work fine.
                      • Programs, including a standalone one-liner project, with that line compiled inside Creator complain "no such file".
                      • From Creator I cannot see anything significant in the command-line or the environment passed to g++ which would change the include search path behaviour.

                      You might just verify one thing. So far you have used #include <boost/algorithm/string.hpp> which ought find /usr/include/boost/algorithm/string.hpp. Go look just in directory /usr/include/boost/ and pick some other .hpp or .h file which lives at that level. I don't know what is there. Say there is a boostfile.hpp. Then try #include <boost/boostfile.hpp>. I presume that fails equally? Otherwise if that succeeds there is something about the particular string.hpp file/path.

                      Whatever the issue it should be something really simple! If I had your machine in front of me I would be confident of diagnosing whatever it is. But as it stands I am out of ideas. You will need someone else to look through with a fresh pair of eyes to see if they can spot what it might be.

                      A Offline
                      A Offline
                      A123
                      wrote on last edited by
                      #19

                      @JonB it also fails with other files. As a workaround I finally just moved boost to the Documents folder and it picked it up. It might be due to my system folders being on a separate partition which is standard practice in linux installs.

                      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