ubuntu 下用qt5.12编译出的程序无法使用鼠标双击运行

环境:ubuntu18.04
qt version:qt5.12

  1. 问题:编译出的程序无法使用鼠标双击运行,但可以在终端下执行,与运行库是否缺失无关
    mimetype 程序见结果为’application/x-sharedlib’,查看了下正常能用鼠标执行的为‘application/x-executable’(直接右键单击程序属性可查看类型)

    搜索回答如下:

    gcc doesn’t set the mime type. mimetype guesses the appropriate mime type based on the contents of the file. For ELF files (most compiled binaries and shared libraries), the header contains a field e_type which identifies its type. If it is ET_DYN, then mimetype will treat it as a shared library.

    By default, gcc/ld will produce binaries which set e_type to ET_EXEC, which get detected as application/x-executable. When the command-line option -pie is used, a position-independent executable is created, which may, like shared libraries, be loaded at different addresses and still work. Because this works so much like a shared library, to avoid too many changes to the loader, such binaries get marked as ET_DYN, even though they can be executed directly.

    Some Linux distributions, yours included, have set -pie as the default. It’s still possible to override this with -no-pie, but the fact that the mime type is misdetected should not be seen as a bug, and unless you know what you’re doing, you shouldn’t override it. -pie allows for some extra security protections that are fundamentally incompatible with -no-pie.

    所以解决方法在pro中加入下面的编译连接选项重新构建即可

    QMAKE_LFLAGS += -no-pie
    
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值