Ubuntu将可执行文件识别为共享库,并且不会通过单击来运行它 [英] Ubuntu recognizes executable as shared library and won't run it by clicking

查看:546
本文介绍了Ubuntu将可执行文件识别为共享库,并且不会通过单击来运行它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是在全新安装lubuntu 17.04时遇到此问题的.我以前曾经使用过Ubuntu,但以前没有这个问题.

I am first experiencing this issue on my fresh installation of lubuntu 17.04. I have used to use Ubuntu before and I hadn't this issue before.

我编译了我的qt应用程序,并且可以通过发出"./"来通过命令行执行它.但是,我无法通过单击文件管理器来执行它(PCManFM,Nautilus都没有.)两者都将其识别为共享库文件类型.

I compiled my qt application and I can execute it through command line by issuing with "./". However, I can't execute it by clicking on file manager (neither PCManFM, Nautilus...) Both recognizes it as shared library file type.

如何通过直接单击文件来运行它?

How can I run it by clicking directly on the file?

这是我通过文件管理器双击可执行文件时发生的情况:

this is what happens when I double-click the executable through file manager:

构建日志:

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

推荐答案

我通过在QT中项目的.pro文件上添加以下行来解决此问题:

I have fixed this behavior by adding the following line on my project's .pro file in QT:

QMAKE_LFLAGS += -no-pie

之所以出现此现象,是因为较新的ubuntu发行版设置了GCC默认链接标志-pie,该标志在二进制文件上将e_type标记为ET_DYN.因此,操作系统将其识别为共享库.

The behavior is occurring because newer ubuntu distros set GCC default link flag -pie, which marks e_type as ET_DYN on the binary file. Consequently, the Operating System recognizes as Shared Library.

要解决此问题,可能需要在编译器选项上添加-no-pie.

To work around it, it may be necessary to add -no-pie on compiler option.

这篇关于Ubuntu将可执行文件识别为共享库,并且不会通过单击来运行它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆