代码之家  ›  专栏  ›  技术社区  ›  Renji

在qmake之后运行make时编译错误

  •  0
  • Renji  · 技术社区  · 6 年前

    我想从Github编译一些东西: https://github.com/com2m/anki-overdrive-goes-iot/

    当运行qmake时,一切似乎都很好,但当运行时,我会得到以下错误:

    g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_BLUETOOTH_LIB -DQT_CORE_LIB -I. -isystem /usr/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtBluetooth -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o main.o src/main.cpp
    In file included from /usr/include/c++/7/bits/stl_algo.h:59:0,
                     from /usr/include/c++/7/algorithm:62,
                     from /usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:109,
                     from /usr/include/x86_64-linux-gnu/qt5/QtCore/qcoreapplication.h:43,
                     from /usr/include/x86_64-linux-gnu/qt5/QtCore/QCoreApplication:1,
                     from src/main.cpp:6:
    /usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
     #include_next <stdlib.h>
                   ^~~~~~~~~~
    compilation terminated.
    Makefile:497: recipe for target 'main.o' failed
    make: *** [main.o] Error 1
    

    运行qmake的文件是包含以下内容的ankidrive.pro文件。

    ######################################################################
    # Automatically generated by qmake (3.0) Thu Sep 29 10:34:51 2016
    ######################################################################
    
    QT += bluetooth
    QT += core
    QT -= gui
    
    CONFIG += c++11
    CONFIG += debug
    
    TEMPLATE = app
    TARGET = build/ankioverdrive
    #INCLUDEPATH += .
    
    LIBS += -lmosquittopp
    
    LIBS += -L/usr/lib
    
    INCLUDEPATH += /usr/include/
    
    # Input
    SOURCES += src/main.cpp \
        src/bluetoothcontroller.cpp \
        src/ankimessage.cpp \
        src/trackpiece.cpp \
        src/track.cpp \
        src/mqttclient.cpp \
        src/json.cpp \
        src/drivemode.cpp \
        src/joystick.cc \
        src/gamepadmanager.cpp \
        src/ankicar.cpp \
        src/racecar.cpp \
        src/tragediyimplementation.cpp
    
    HEADERS += \
        src/headers/bluetoothcontroller.h \
        src/headers/ankimessage.h \
        src/headers/trackpiece.h \
        src/headers/track.h \
        src/headers/mqttclient.h \
        src/headers/json.h \
        src/headers/drivemode.h \
        src/headers/joystick.hh \
        src/headers/gamepadmanager.h \
        src/headers/ankicar.h \
        src/headers/racecar.h \
        src/headers/tragediyimplementation.h
    

    生成的makefile开始如下:

    #############################################################################
    # Makefile for building: build/ankioverdrive
    # Generated by qmake (3.1) (Qt 5.9.5)
    # Project:  ankioverdrive.pro
    # Template: app
    # Command: /usr/lib/qt5/bin/qmake -o Makefile ankioverdrive.pro
    #############################################################################
    
    MAKEFILE      = Makefile
    
    ####### Compiler, tools and options
    
    CC            = gcc
    CXX           = g++
    DEFINES       = -DQT_BLUETOOTH_LIB -DQT_CORE_LIB
    CFLAGS        = -pipe -g -Wall -W -D_REENTRANT -fPIC $(DEFINES)
    CXXFLAGS      = -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
    INCPATH       = -I. -isystem /usr/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtBluetooth -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++
    QMAKE         = /usr/lib/qt5/bin/qmake
    DEL_FILE      = rm -f
    CHK_DIR_EXISTS= test -d
    MKDIR         = mkdir -p
    COPY          = cp -f
    COPY_FILE     = cp -f
    COPY_DIR      = cp -f -R
    INSTALL_FILE  = install -m 644 -p
    INSTALL_PROGRAM = install -m 755 -p
    INSTALL_DIR   = cp -f -R
    QINSTALL      = /usr/lib/qt5/bin/qmake -install qinstall
    QINSTALL_PROGRAM = /usr/lib/qt5/bin/qmake -install qinstall -exe
    DEL_FILE      = rm -f
    SYMLINK       = ln -f -s
    DEL_DIR       = rmdir
    MOVE          = mv -f
    TAR           = tar -cf
    COMPRESS      = gzip -9f
    DISTNAME      = ankioverdrive1.0.0
    DISTDIR = /home/renji/Projects/BachalorArbeit/anki-overdrive-goes-iot/.tmp/ankioverdrive1.0.0
    LINK          = g++
    LFLAGS        = -Wl,-rpath-link,/usr/lib/x86_64-linux-gnu
    LIBS          = $(SUBLIBS) -lmosquittopp -L/usr/lib -lQt5Bluetooth -lQt5Core -lpthread 
    AR            = ar cqs
    RANLIB        = 
    SED           = sed
    STRIP         = strip
    

    我的研究表明,必然存在错误的路径,但我指派的路径是我的C++包含路径。

    stdlib.h可以在以下位置找到:

    /usr/include/c++/7/stdlib.h
    

    我在跑步 库本图18.04 还有图书馆 构建要点

    1 回复  |  直到 6 年前
        1
  •  0
  •   Knud Larsen    6 年前

    /Ur/Copy/C++/7/CSTDLIB:75∶15:致命错误:STDLI.h:没有这样的文件或目录

    sudo apt install g++ g++-5 libmosquittopp-dev libbluetooth-dev qtconnectivity5-dev

    git clone https://github.com/com2m/anki-overdrive-goes-iot.git
    cd anki-overdrive-goes-iot/
    export QT_SELECT=5
    qmake       // the Makefile is generated
                // Edit Makefile line 13 to CC = gcc-5
                // and line 14 to CXX = g++-5
    make
    

    没有错误。

    你的错误:我想这是个错误,因为G++-7的头文件 /usr/include/c++/7/stdlib.h 找不到?(G++-6也有同样的问题。)