我第一次在全新安装的lubuntu 17.04上遇到此问题。我之前习惯使用Ubuntu,之前我没有这个问题。
我编译了我的qt应用程序,我可以通过发出“./”来通过命令行执行它。但是,我无法通过单击文件管理器(PCManFM,Nautilus ......)来执行它。两者都将其识别为共享库文件类型。
如何直接点击文件来运行它?
建立日志:
11:20:05: Running steps for project APP_release...
11:20:05: Configuration unchanged, skipping qmake step.
11:20:05: Starting: "/usr/bin/make"
/opt/Qt5.9.0/5.9/gcc_64/bin/uic ../APP_release/mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../APP_release -I. -I/opt/Qt5.9.0/5.9/gcc_64/include -I/opt/Qt5.9.0/5.9/gcc_64/include/QtWidgets -I/opt/Qt5.9.0/5.9/gcc_64/include/QtGui -I/opt/Qt5.9.0/5.9/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I/opt/Qt5.9.0/5.9/gcc_64/mkspecs/linux-g++ -o main.o ../APP_release/main.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../APP_release -I. -I/opt/Qt5.9.0/5.9/gcc_64/include -I/opt/Qt5.9.0/5.9/gcc_64/include/QtWidgets -I/opt/Qt5.9.0/5.9/gcc_64/include/QtGui -I/opt/Qt5.9.0/5.9/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I/opt/Qt5.9.0/5.9/gcc_64/mkspecs/linux-g++ -o mainwindow.o ../APP_release/mainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../APP_release -I. -I/opt/Qt5.9.0/5.9/gcc_64/include -I/opt/Qt5.9.0/5.9/gcc_64/include/QtWidgets -I/opt/Qt5.9.0/5.9/gcc_64/include/QtGui -I/opt/Qt5.9.0/5.9/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I/opt/Qt5.9.0/5.9/gcc_64/mkspecs/linux-g++ -o foldercompressor.o ../APP_release/foldercompressor.cpp
g++ -pipe -O2 -Wall -W -dM -E -o moc_predefs.h /opt/Qt5.9.0/5.9/gcc_64/mkspecs/features/data/dummy.cpp
/opt/Qt5.9.0/5.9/gcc_64/bin/moc -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include ./moc_predefs.h -I/opt/Qt5.9.0/5.9/gcc_64/mkspecs/linux-g++ -I/home/spectrum/trunk/APP_release/APP_release -I/opt/Qt5.9.0/5.9/gcc_64/include -I/opt/Qt5.9.0/5.9/gcc_64/include/QtWidgets -I/opt/Qt5.9.0/5.9/gcc_64/include/QtGui -I/opt/Qt5.9.0/5.9/gcc_64/include/QtCore -I. -I/usr/include/c++/6 -I/usr/include/x86_64-linux-gnu/c++/6 -I/usr/include/c++/6/backward -I/usr/lib/gcc/x86_64-linux-gnu/6/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../APP_release/mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../APP_release -I. -I/opt/Qt5.9.0/5.9/gcc_64/include -I/opt/Qt5.9.0/5.9/gcc_64/include/QtWidgets -I/opt/Qt5.9.0/5.9/gcc_64/include/QtGui -I/opt/Qt5.9.0/5.9/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I/opt/Qt5.9.0/5.9/gcc_64/mkspecs/linux-g++ -o moc_mainwindow.o moc_mainwindow.cpp
/opt/Qt5.9.0/5.9/gcc_64/bin/moc -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include ./moc_predefs.h -I/opt/Qt5.9.0/5.9/gcc_64/mkspecs/linux-g++ -I/home/spectrum/trunk/APP_release/APP_release -I/opt/Qt5.9.0/5.9/gcc_64/include -I/opt/Qt5.9.0/5.9/gcc_64/include/QtWidgets -I/opt/Qt5.9.0/5.9/gcc_64/include/QtGui -I/opt/Qt5.9.0/5.9/gcc_64/include/QtCore -I. -I/usr/include/c++/6 -I/usr/include/x86_64-linux-gnu/c++/6 -I/usr/include/c++/6/backward -I/usr/lib/gcc/x86_64-linux-gnu/6/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../APP_release/foldercompressor.h -o moc_foldercompressor.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../APP_release -I. -I/opt/Qt5.9.0/5.9/gcc_64/include -I/opt/Qt5.9.0/5.9/gcc_64/include/QtWidgets -I/opt/Qt5.9.0/5.9/gcc_64/include/QtGui -I/opt/Qt5.9.0/5.9/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I/opt/Qt5.9.0/5.9/gcc_64/mkspecs/linux-g++ -o moc_foldercompressor.o moc_foldercompressor.cpp
g++ -Wl,-O1 -Wl,-rpath,/opt/Qt5.9.0/5.9/gcc_64/lib -o APP_release main.o mainwindow.o foldercompressor.o moc_mainwindow.o moc_foldercompressor.o -L/opt/Qt5.9.0/5.9/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
11:20:10: The process "/usr/bin/make" exited normally.
11:20:10: Elapsed time: 00:05
答案 0 :(得分:16)
我通过在QT中的项目的.pro文件中添加以下行来修复此行为:
QMAKE_LFLAGS += -no-pie
行为正在发生,因为较新的ubuntu发行版设置了GCC默认链接标志-pie,它将e_type标记为二进制文件上的ET_DYN。因此,操作系统将识别为共享库。
要解决此问题,可能需要在编译器选项上添加-no-pie。
答案 1 :(得分:0)
命令行中的“文件APP_release”是什么意思。 “文件”程序应该说明系统认为文件是什么。可执行文件具有“...... LSB可执行文件”和共享库“...... LSB共享对象”。如果它说它是可执行文件,那么它似乎是Ubuntu中的一个错误。如果它说它是一个共享对象,那么你的make日志表明它是链接器中的一个错误!