我正在尝试编译从Git hub下载的Qt项目。编译期间出现以下错误。
/ bin / sh:1:语法错误:反引号替换中的EOF
make:* [mainwindow.o]错误2
**** 08:33:27:过程" / usr / bin / make"退出代码2.
构建/部署项目FiniteElements时出错(工具包:桌面)
执行步骤'制作' ******
我的.pro文件如下,
QT += core gui opengl widgets
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x000000`
TARGET = FiniteElements
TEMPLATE = app
LIBS += -lqwt
INCLUDEPATH += "/usr/include/qwt/"
SOURCES += main.cpp\
mainwindow.cpp \
FiniteElements.cpp \
graph_plot.cpp
HEADERS += mainwindow.h \
FiniteElements.h \
graph_plot.h
任何人都可以帮助我吗?
答案 0 :(得分:1)
在安装了qt5-default 5.5.1+dfsg-16ubuntu7
和libqwt-qt5-dev 6.1.2-5
的Ubuntu 16.04.1 LTS上测试的说明:
克隆回购:
$ git clone https://github.com/MKrishtop/FiniteElements.git
Cloning into 'FiniteElements'...
remote: Counting objects: 17, done.
remote: Total 17 (delta 0), reused 0 (delta 0), pack-reused 17
Unpacking objects: 100% (17/17), done.
Checking connectivity... done.
从Qt 4到Qt 5的端口:
$ cd FiniteElements/
$ find . -type f -exec sed -i 's/QtGui/QtWidgets/g' {} \;
$ find . -type f -exec sed -i 's/toAscii/toLocal8Bit/g' {} \;
$ sed -i 's/-lqwt/-lqwt-qt5/g' FiniteElements.pro
作为参考,这里是完整的差异:
$ git diff
diff --git a/FiniteElements.pro b/FiniteElements.pro
index a2edb50..610f9f7 100644
--- a/FiniteElements.pro
+++ b/FiniteElements.pro
@@ -8,7 +8,7 @@ QT += core gui opengl
TARGET = FiniteElements
TEMPLATE = app
-LIBS += -lqwt
+LIBS += -lqwt-qt5
INCLUDEPATH += "/usr/include/qwt/"
diff --git a/graph_plot.h b/graph_plot.h
index 551941b..00cf205 100644
--- a/graph_plot.h
+++ b/graph_plot.h
@@ -1,7 +1,7 @@
#ifndef GRAPH_PLOT_H
#define GRAPH_PLOT_H
-#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
#include <QApplication>
#include <QString>
#include <qwt_plot.h>
diff --git a/main.cpp b/main.cpp
index 6bf7836..338bba0 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,4 +1,4 @@
-#include <QtGui/QApplication>
+#include <QtWidgets/QApplication>
#include <qwt_plot.h>
#include "mainwindow.h"
#include "FiniteElements.h"
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 1f0145f..2ecec7d 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1,4 +1,4 @@
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
@@ -25,7 +25,7 @@ void MainWindow::browse()
QString filepath = QFileDialog::getOpenFileName(this,tr("Select input datafile"),QDir::currentPath());
if (!filepath.isEmpty()) {
- std::string str = std::string(filepath.toAscii().data());
+ std::string str = std::string(filepath.toLocal8Bit().data());
const char * stuff = str.c_str();
A->SetFN(stuff);
A->evaluate();
diff --git a/mainwindow.h b/mainwindow.h
index fc8f0fb..4bcf0e1 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -3,7 +3,7 @@
#include <QDialog>
#include <QDir>
-#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
#include <QApplication>
#include <QString>
#include "FiniteElements.h"
构建
$ qmake -v
QMake version 3.0
Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu
$ qmake
$ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qwt -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtOpenGL -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o main.o main.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qwt -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtOpenGL -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o mainwindow.o mainwindow.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qwt -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtOpenGL -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o FiniteElements.o FiniteElements.cpp
FiniteElements.cpp: In member function 'int FiniteElements::local_node()':
FiniteElements.cpp:185:6: warning: unused variable 'kf' [-Wunused-variable]
int kf=0,i=bpn,k=0;
^
FiniteElements.cpp:185:11: warning: unused variable 'i' [-Wunused-variable]
int kf=0,i=bpn,k=0;
^
FiniteElements.cpp:185:17: warning: unused variable 'k' [-Wunused-variable]
int kf=0,i=bpn,k=0;
^
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qwt -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtOpenGL -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o graph_plot.o graph_plot.cpp
/usr/lib/x86_64-linux-gnu/qt5/bin/moc -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I/home/jpnurmi/Temp/FiniteElements -I/usr/include/qwt -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtOpenGL -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/lib/gcc/x86_64-linux-gnu/5/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include mainwindow.h -o moc_mainwindow.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qwt -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtOpenGL -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o moc_mainwindow.o moc_mainwindow.cpp
/usr/lib/x86_64-linux-gnu/qt5/bin/moc -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I/home/jpnurmi/Temp/FiniteElements -I/usr/include/qwt -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtOpenGL -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/include/c++/5 -I/usr/include/x86_64-linux-gnu/c++/5 -I/usr/include/c++/5/backward -I/usr/lib/gcc/x86_64-linux-gnu/5/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include graph_plot.h -o moc_graph_plot.cpp
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /usr/include/qwt -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtOpenGL -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o moc_graph_plot.o moc_graph_plot.cpp
g++ -m64 -Wl,-O1 -o FiniteElements main.o mainwindow.o FiniteElements.o graph_plot.o moc_mainwindow.o moc_graph_plot.o -L/usr/X11R6/lib64 -lqwt-qt5 -lQt5OpenGL -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
$