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. Problem with including cstdlib library (No such file or directory)
QtWS25 Last Chance

Problem with including cstdlib library (No such file or directory)

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 4 Posters 5.9k 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
    Lyokoheros
    wrote on 18 Nov 2020, 23:28 last edited by
    #1

    I've got problem with stdlib.h library in Qt Creator(QT version 5.12.8) on Linux(Ubuntu 20.04). I use some library for interval arithmetic(interval.h), which use quite a bunch of other libraries (as boost/lexical_cast.hpp and mpfr.h) therefore it take some to make it work... or at least it seems so.
    I fixed problem with this additional libraries I had to install by adding apropriate entry in my .pro file ("/usr/local/boost/boost_1_55_0" and "/usr/include" in INCLUDEPATH and corresponding entries in LIBS).
    But then I get the error "stdlib.h: No such file or directory", I tried to change "#include <stdlib.h>" into "#include <cstdlib>" (similar as I previously have to do with floats.h, so I thought it'll help) but it didn't change it. I still get the same error (and QT creator point to cstlib library itself since that).
    I've read here about deleting "/usr/include" from INCLUDEPATH, but this would undo my fix for mpfr(I needed it to eliminate compilation error connected to mpfr's function), so it's not an option.
    There is any other way to solve that?
    (Here is my entire project if that would help)

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Nov 2020, 18:59 last edited by
      #2

      Hi and welcome to devnet,

      Why not install the boost development packages from your distribution ?

      Your LIBS line is wrong, it should point to the path where the libraries can be found.

      I do not know whether you are using only header only stuff from boost but you are not linking to any of its libraries ?

      That said, which development packages did you install on your system ?

      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 19 Nov 2020, 23:47
      1
      • S SGaist
        19 Nov 2020, 18:59

        Hi and welcome to devnet,

        Why not install the boost development packages from your distribution ?

        Your LIBS line is wrong, it should point to the path where the libraries can be found.

        I do not know whether you are using only header only stuff from boost but you are not linking to any of its libraries ?

        That said, which development packages did you install on your system ?

        L Offline
        L Offline
        Lyokoheros
        wrote on 19 Nov 2020, 23:47 last edited by Lyokoheros
        #3

        @SGaist what do You mean by installing packages from my distribution?
        I Installed both boost libraries and mpfr according to that guide. I use mpfr.h, which as far as I know isn't header only (or it seems so to me as I have to pre compile it, but maybe I get something wrong about this, I'm not a big expert in regard of how compilers work on the inside; but this one isn't from boost) and header only library "lexical_cast.hpp" from boost. Both in interval.h library.
        called lexical_cast.hpp. And as I checked in my filesystem "/usr/local" is where the mpfr.h file is located, and "/usr/local/boost/boost_1_55_0" is where "lexical_cast.hpp"(or more precisely "where boost/lexical_cast.hpp") is located. So how my LIBS line is wrong? As I found out when checking how to linking libraries in Qt on Linux the way to do it is adding -L"[location of the library]" in to the LIBS variable... if that isn't the correct way then what is the correct way?

        Also - the error I was getting was not (at least visibly) connected to boost libraries, but it was about stdlib.h in cstdlib.

        J 1 Reply Last reply 20 Nov 2020, 05:53
        0
        • L Lyokoheros
          19 Nov 2020, 23:47

          @SGaist what do You mean by installing packages from my distribution?
          I Installed both boost libraries and mpfr according to that guide. I use mpfr.h, which as far as I know isn't header only (or it seems so to me as I have to pre compile it, but maybe I get something wrong about this, I'm not a big expert in regard of how compilers work on the inside; but this one isn't from boost) and header only library "lexical_cast.hpp" from boost. Both in interval.h library.
          called lexical_cast.hpp. And as I checked in my filesystem "/usr/local" is where the mpfr.h file is located, and "/usr/local/boost/boost_1_55_0" is where "lexical_cast.hpp"(or more precisely "where boost/lexical_cast.hpp") is located. So how my LIBS line is wrong? As I found out when checking how to linking libraries in Qt on Linux the way to do it is adding -L"[location of the library]" in to the LIBS variable... if that isn't the correct way then what is the correct way?

          Also - the error I was getting was not (at least visibly) connected to boost libraries, but it was about stdlib.h in cstdlib.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 20 Nov 2020, 05:53 last edited by
          #4

          @Lyokoheros said in Problem with including cstdlib library (No such file or directory):

          what do You mean by installing packages from my distribution?

          apt install libboost-all-dev
          

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

          L 1 Reply Last reply 20 Nov 2020, 21:45
          2
          • J jsulm
            20 Nov 2020, 05:53

            @Lyokoheros said in Problem with including cstdlib library (No such file or directory):

            what do You mean by installing packages from my distribution?

            apt install libboost-all-dev
            
            L Offline
            L Offline
            Lyokoheros
            wrote on 20 Nov 2020, 21:45 last edited by
            #5

            @jsulm that didn't change anything. I still get the same error. Which was about stdlib.h, not boost libraries, as I already mentioned.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 21 Nov 2020, 18:25 last edited by
              #6

              @Lyokoheros said in Problem with including cstdlib library (No such file or directory):

              stdlib.h

              Where do you have that file exactly on your system ?

              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 21 Nov 2020, 23:23
              0
              • S SGaist
                21 Nov 2020, 18:25

                @Lyokoheros said in Problem with including cstdlib library (No such file or directory):

                stdlib.h

                Where do you have that file exactly on your system ?

                L Offline
                L Offline
                Lyokoheros
                wrote on 21 Nov 2020, 23:23 last edited by
                #7

                @SGaist i find it in a few differen locations:
                usr/include
                usr/include/c++/8
                usr/include/c++/9
                usr/include/x86_64-linux-gnu/bits
                snap/gnome-3-34-1804/36/usr/include
                usr/include/c++/8/tr1
                usr/include/c++/9/tr1

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 22 Nov 2020, 18:30 last edited by
                  #8

                  Can you share your .pro file ?

                  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 22 Nov 2020, 22:15
                  0
                  • S SGaist
                    22 Nov 2020, 18:30

                    Can you share your .pro file ?

                    L Offline
                    L Offline
                    Lyokoheros
                    wrote on 22 Nov 2020, 22:15 last edited by
                    #9

                    @SGaist I already do it. .pro file is inside the repository i linked at the very beginning.

                    QT += core gui widgets
                    
                    TARGET = BairstowSolver
                    TEMPLATE = app
                    CONFIG += \
                    no_keywords
                    
                    SOURCES += \
                        main.cpp \
                        mywidget.cpp \
                        solver.cpp \
                        solverinterval.cpp
                    
                    HEADERS += \
                        interval.h \
                        mywidget.h \
                        solver.h \
                        solverinterval.h
                    
                    LIBS +=\
                        -L"/usr/local/boost/boost_1_55_0" \
                        -L"/usr/include"
                    
                    
                    INCLUDEPATH +=\
                        /usr/local/boost/boost_1_55_0 \
                        /usr/include
                    

                    And here's direct link to it.

                    J 1 Reply Last reply 23 Nov 2020, 05:20
                    0
                    • L Lyokoheros
                      22 Nov 2020, 22:15

                      @SGaist I already do it. .pro file is inside the repository i linked at the very beginning.

                      QT += core gui widgets
                      
                      TARGET = BairstowSolver
                      TEMPLATE = app
                      CONFIG += \
                      no_keywords
                      
                      SOURCES += \
                          main.cpp \
                          mywidget.cpp \
                          solver.cpp \
                          solverinterval.cpp
                      
                      HEADERS += \
                          interval.h \
                          mywidget.h \
                          solver.h \
                          solverinterval.h
                      
                      LIBS +=\
                          -L"/usr/local/boost/boost_1_55_0" \
                          -L"/usr/include"
                      
                      
                      INCLUDEPATH +=\
                          /usr/local/boost/boost_1_55_0 \
                          /usr/include
                      

                      And here's direct link to it.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 23 Nov 2020, 05:20 last edited by
                      #10

                      @Lyokoheros said in Problem with including cstdlib library (No such file or directory):

                      LIBS +=
                      -L"/usr/local/boost/boost_1_55_0"
                      -L"/usr/include"

                      Why did you add /usr/include to search path for libraries?! Also, it is not needed to add it to include paths (INCLUDEPATH) as it is searched by default.

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

                      L 1 Reply Last reply 23 Nov 2020, 18:27
                      1
                      • J jsulm
                        23 Nov 2020, 05:20

                        @Lyokoheros said in Problem with including cstdlib library (No such file or directory):

                        LIBS +=
                        -L"/usr/local/boost/boost_1_55_0"
                        -L"/usr/include"

                        Why did you add /usr/include to search path for libraries?! Also, it is not needed to add it to include paths (INCLUDEPATH) as it is searched by default.

                        L Offline
                        L Offline
                        Lyokoheros
                        wrote on 23 Nov 2020, 18:27 last edited by
                        #11

                        @jsulm I hade to add it to solve problem with Qt Creator not finding the mpfr.h library (I getttti error "undefined refference to 'mpfr_init2'")

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 23 Nov 2020, 18:52 last edited by
                          #12

                          mpfr.h is a header which are usually found in an include subdir.

                          "-L" is used to add paths to search for the linker to find additional libraries. Adding include path to it is usually wrong because if there are library files in there, then your system has an installation issue.

                          Can you build a default project using that header ?

                          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 23 Nov 2020, 20:56
                          1
                          • S SGaist
                            23 Nov 2020, 18:52

                            mpfr.h is a header which are usually found in an include subdir.

                            "-L" is used to add paths to search for the linker to find additional libraries. Adding include path to it is usually wrong because if there are library files in there, then your system has an installation issue.

                            Can you build a default project using that header ?

                            L Offline
                            L Offline
                            Lyokoheros
                            wrote on 23 Nov 2020, 20:56 last edited by
                            #13

                            @SGaist well it was exaclty in that folder, not in any of subfolders.
                            But well actually when I create new qt widget application it could be easily build with just -L"/usr/include" or just reffering to mpfr.h (simply by including it in class header) all was fine but when I tried to build it with both (-L"/usr/include" in LIBS and including mpfr.h) i got the same error: stdlib.h no such file or directory.
                            Well at least that's what I saw at the beginning now when I tried to repeat this tests it seems random... sometimes with both it work well, sometimes without this addition to LIBS, sometimes only with it (and not including mpfr.h), other time it's not working just with addition to LIBS(without including mpfr.h)... i don't get it...

                            But maybe the correct aproach to it would be solving the error, which appear when I don't add "-L"/usr/include"" to LIBS. And this is the said error:

                            error: main.o: in function `interval_arithmetic::Interval<long double>::IntRead(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
                            /home/ubuntu/Desktop/MetodaBairstowa/interval.h:264: error: undefined reference to `mpfr_init2'
                            error: /home/ubuntu/Desktop/build-Bairstow-Desktop-Debug/../MetodaBairstowa/interval.h:265: undefined reference to `mpfr_set_str'
                            error: /home/ubuntu/Desktop/build-Bairstow-Desktop-Debug/../MetodaBairstowa/interval.h:268: undefined reference to `mpfr_get_ld'
                            error: /home/ubuntu/Desktop/build-Bairstow-Desktop-Debug/../MetodaBairstowa/interval.h:271: undefined reference to `mpfr_get_d'
                            [and a little bit of similar lines]
                            
                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 23 Nov 2020, 21:54 last edited by
                              #14

                              Where is the .so file of that library located ?

                              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 25 Nov 2020, 04:48
                              0
                              • S SGaist
                                23 Nov 2020, 21:54

                                Where is the .so file of that library located ?

                                L Offline
                                L Offline
                                Lyokoheros
                                wrote on 25 Nov 2020, 04:48 last edited by
                                #15

                                @SGaist .so file of what library? (I know this may seem a stupid question, but before I didn't work much with additional external libraries in c++)

                                J 1 Reply Last reply 25 Nov 2020, 07:03
                                0
                                • L Lyokoheros
                                  25 Nov 2020, 04:48

                                  @SGaist .so file of what library? (I know this may seem a stupid question, but before I didn't work much with additional external libraries in c++)

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 25 Nov 2020, 07:03 last edited by
                                  #16

                                  @Lyokoheros said in Problem with including cstdlib library (No such file or directory):

                                  so file of what library?

                                  The library which defines the undefined references. I guess libmpfr.so or something like that...

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

                                  L 1 Reply Last reply 26 Nov 2020, 03:55
                                  1
                                  • J jsulm
                                    25 Nov 2020, 07:03

                                    @Lyokoheros said in Problem with including cstdlib library (No such file or directory):

                                    so file of what library?

                                    The library which defines the undefined references. I guess libmpfr.so or something like that...

                                    L Offline
                                    L Offline
                                    Lyokoheros
                                    wrote on 26 Nov 2020, 03:55 last edited by
                                    #17

                                    @jsulm I find it in usr/lib/x86_64-linux-gnu, but there is also one in home/ubunutu/anaconda3/lib and a few instances with something like ".6" or ".6.0.2" after the ".so" extension (I know linux technically doesn't have extensions, but I don't know how to call it other way)

                                    J 1 Reply Last reply 26 Nov 2020, 05:44
                                    0
                                    • L Lyokoheros
                                      26 Nov 2020, 03:55

                                      @jsulm I find it in usr/lib/x86_64-linux-gnu, but there is also one in home/ubunutu/anaconda3/lib and a few instances with something like ".6" or ".6.0.2" after the ".so" extension (I know linux technically doesn't have extensions, but I don't know how to call it other way)

                                      J Offline
                                      J Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on 26 Nov 2020, 05:44 last edited by
                                      #18

                                      @Lyokoheros

                                      LIBS += -lmpfr
                                      

                                      in PRO file should be enough

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

                                      L 1 Reply Last reply 27 Nov 2020, 16:27
                                      1
                                      • J jsulm
                                        26 Nov 2020, 05:44

                                        @Lyokoheros

                                        LIBS += -lmpfr
                                        

                                        in PRO file should be enough

                                        L Offline
                                        L Offline
                                        Lyokoheros
                                        wrote on 27 Nov 2020, 16:27 last edited by
                                        #19

                                        @jsulm apparently it wasn't enough.
                                        And actually it turned out I forget implement the interval version of one function, which of course give me some errors after adding -lmpfr to LIBS, but after adding the mentioned implementation I again get just "stdlib.h: No such file or directory" - which point to cstdlib in /usr/include/c++/9/

                                        The .pro file is now like this:

                                        QT += core gui widgets
                                        
                                        TARGET = BairstowSolver
                                        TEMPLATE = app
                                        CONFIG += \
                                        no_keywords
                                        
                                        SOURCES += \
                                            main.cpp \
                                            mywidget.cpp \
                                            solver.cpp \
                                            solverinterval.cpp
                                        
                                        HEADERS += \
                                            interval.h \
                                            mywidget.h \
                                            solver.h \
                                            solverinterval.h
                                        
                                        LIBS +=\
                                            -L"/usr/local/boost/boost_1_55_0" \
                                            -lmpfr
                                        
                                        
                                        INCLUDEPATH +=\
                                            /usr/local/boost/boost_1_55_0 \
                                            /usr/include
                                        

                                        For changes in intervalsolver.cpp you can look here

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on 27 Nov 2020, 20:21 last edited by
                                          #20

                                          Nothing stands out...

                                          Do you have the same issue if you use a default project ?

                                          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

                                          8/22

                                          22 Nov 2020, 18:30

                                          topic:navigator.unread, 14
                                          • Login

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