How to avoid having version numbers in .so file name - linux

I'm trying to build a dynamic library on Linux using qmake. Here is my .pro file:
TEMPLATE = lib
TARGET = sqxUiBase
QT += core gui
CONFIG += dll
INCLUDEPATH += ../../public/include
DEPENDPATH += .
UI_DIR += ../GeneratedFiles
RCC_DIR += ../GeneratedFiles
CONFIG(release, debug|release) {
DESTDIR = ../lib/release
LIBS += -L"../lib/release"
MOC_DIR += ../GeneratedFiles/release
OBJECTS_DIR += release
} else {
DESTDIR = ../lib/debug
LIBS += -L"../lib/debug"
MOC_DIR += ../GeneratedFiles/debug
OBJECTS_DIR += debug
}
include(sqxUiBase.pri)
The sqxUiBase.pri file contains the list of files that need to be built.
Now, the problem is that whatever I do, the resulting file is always named sqxUiBase.so.1.0.0, with a bunch of symlinks (sqxUiBase.so, sqxUiBase.so.1 and sqxUiBase.so.1.0) pointing to it. How can I make it so that there's only a sqxUiBase.so file and no links?

What you are looking for is making a plugin.
Add CONFIG += plugin to your project file, and qmake will generate a Makefile that builds a libFoo.so file, without the numbered links

After looking at the qmake source I found CONFIG += unversioned_libname for nix and CONFIG += skip_target_version_ext for windows.

Related

Application crash with TERMINATED

I have one application made in QT, and sometimes when I start it, occurre an inexpected TERMINATED error.
But If I retry sometimes, the application open normally.
ebonomo#ICCSW-044681NB /usr/local/app/bin$ ./myapp
Terminado
ebonomo#ICCSW-044681NB /usr/local/app/bin$ ./myapp
Terminado
ebonomo#ICCSW-044681NB /usr/local/app/bin$ ./myapp
"Iniciando ...
.....
I created a lib folder in app/lib with all libs detected in lddtree. I changed too in .bashrc to set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/app/lib/
But I can't get why this error. Could you help me? How can I get the cause? Is there any command to check it?
I already tried remove all in main method keeping only a debug message, and the error occurred yet.
I don't know more what can I do. :(
My environment is:
Ubuntu 20.04
Qt 5.15.2
Qt Creator 7.0.1
Based on Qt 6.2.3 (GCC 10.3.1 20210422 (Red Hat 10.3.1-1), 64 bit)
Built on Apr 26 2022 01:18:11
From revision da16d778d5
OBS: I can reproduce the error with this code:
int main(int argc, char *argv[])
{
qFatal("Starting application");
}
My .pro is it:
#-------------------------------------------------
#
# Project created by QtCreator 2020-09-24T10:15:43
#
#-------------------------------------------------
QT += core gui network svg
QT += multimedia
QT += multimediawidgets
QT += 3drender
QT += printsupport
CONFIG += ccache use_gold_linker precompile_header # Improve Build Speed
PRECOMPILED_HEADER = precompiled_header.h
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets quick
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH = $$PWD/ui/imports
TARGET = myapp
TEMPLATE = app
INCLUDEPATH += $$PWD/libs
INCLUDEPATH += $$PWD/libs/qtmqtt
INCLUDEPATH += /usr/include/opencv4
INCLUDEPATH += $$PWD/imagerender/src
INCLUDEPATH += $$PWD/libs/fingerprint/Futronic/header
#Include static lib QT MQTT
equals(QT_VERSION, "5.15.2") {
#message("Loading lib libQt5Mqtt for 5.15.2")
LIBS += -L$$PWD/libs/qtmqtt/5.15.2 -lQt5Mqtt
QMAKE_LFLAGS += -Wl,--rpath=$$PWD/libs/qtmqtt/5.15.2
}
equals(QT_VERSION, "5.15.1") {
#message("Loading lib libQt5Mqtt for 5.15.1")
LIBS += -L$$PWD/libs/qtmqtt/5.15.1 -lQt5Mqtt
QMAKE_LFLAGS += -Wl,--rpath=$$PWD/libs/qtmqtt/5.15.1
}
LIBS += -L$$PWD/libs/fingerprint/Futronic -lScanAPI
QMAKE_LFLAGS += -Wl,--rpath=$$PWD/libs/fingerprint/Futronic
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
LIBS += -lopencv_core
LIBS += -lopencv_highgui
LIBS += -lopencv_imgproc
LIBS += -lopencv_features2d
LIBS += -lopencv_calib3d
LIBS += -lopencv_videoio
LIBS += -lopencv_imgcodecs
LIBS += -lrt
SOURCES += \
main.cpp
# a lot of .cpp here
HEADERS += \
constants.h
# a lot of .h here
FORMS +=
DISTFILES += \
settings.ini
RESOURCES += \
resources.qrc \
images/logos/logo.png
TRANSLATIONS += i18n/en.ts \
i18n/es.ts \
i18n/pt.ts
# From here https://stackoverflow.com/a/36438618
copydata.commands = $(COPY_DIR) $$PWD/settings.ini $$OUT_PWD
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_CXXFLAGS += -Wno-unknown-pragmas # Ignore pragma region warnings
QMAKE_EXTRA_TARGETS += first copydata

How can I run qmake tool on target with yocto?

My team is using Petalinux 18.02 which uses Yocto ver.rocko and meta-qt5.
I added IMAGE_INSTALL_append = " packagegroup-qt5-toolchain-target " in local.conf but it did not integrate qmake to target image. Then I modified local.conf one more time and added IMAGE_INSTALL_append = " qtbase-tools " and it did that! So I finally integrated qmake tool on target system.
However, it does not work well...
Its configuration looks invalid and it can't find features, test functions.
I'll add a detail below.
# Environment variables
export QTDIR="/usr/bin/qt5";
export QTINC="/usr/include/qt5";
export QTLIB="/usr/lib/qt5";
export QMAKESPEC="/usr/lib/qt5/mkspecs/linux-oe-g++";
export QMAKEFEATURES="/usr/lib/qt5/mkspecs/features";
export PATH="${QTDIR}:${PATH}"
root#petalinux18.02:~# /usr/bin/qt5/qmake -query
QT_SYSROOT:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-linuxt
QT_INSTALL_PREFIX:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinr
QT_INSTALL_PREFIX/raw:/usr
QT_INSTALL_ARCHDATA:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xil5
QT_INSTALL_ARCHDATA/raw:/usr/lib/qt5
QT_INSTALL_DATA:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-5
QT_INSTALL_DATA/raw:/usr/share/qt5
QT_INSTALL_DOCS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-5
QT_INSTALL_DOCS/raw:/usr/share/doc/qt5
QT_INSTALL_HEADERS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xili5
QT_INSTALL_HEADERS/raw:/usr/include/qt5
QT_INSTALL_LIBS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-b
QT_INSTALL_LIBS/raw:/usr/lib
QT_INSTALL_LIBEXECS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilc
QT_INSTALL_LIBEXECS/raw:/usr/lib/qt5/libexec
QT_INSTALL_BINS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-5
QT_INSTALL_BINS/raw:/usr/bin/qt5
QT_INSTALL_TESTS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinxs
QT_INSTALL_TESTS/raw:/usr/share/qt5/tests
QT_INSTALL_PLUGINS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilis
QT_INSTALL_PLUGINS/raw:/usr/lib/qt5/plugins
QT_INSTALL_IMPORTS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilis
QT_INSTALL_IMPORTS/raw:/usr/lib/qt5/imports
QT_INSTALL_QML:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-ll
QT_INSTALL_QML/raw:/usr/lib/qt5/qml
QT_INSTALL_TRANSLATIONS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64s
QT_INSTALL_TRANSLATIONS/raw:/usr/share/qt5/translations
QT_INSTALL_CONFIGURATION:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch65
QT_INSTALL_CONFIGURATION/raw:/etc/qt5
QT_INSTALL_EXAMPLES:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xils
QT_INSTALL_EXAMPLES/raw:/usr/share/qt5/examples
QT_INSTALL_DEMOS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinxs
QT_INSTALL_DEMOS/raw:/usr/share/qt5/examples
QT_HOST_PREFIX:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-le
QT_HOST_DATA:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-lin5
QT_HOST_BINS:/usr/bin/qt5
QT_HOST_LIBS:/scratch/petalinux-yocto/yocto_downloads_2018.2_zynqmp-generic/build_zynqmp-generic/tmp/work/aarch64-xilinx-linb
QMAKE_SPEC:linux-oe-g++
QMAKE_XSPEC:linux-oe-g++
QMAKE_VERSION:3.1
QT_VERSION:5.9.4
# test.pro
TEMPLATE = app
TARGET = test_qmake
DEPENDPATH += .
INCLUDEPATH += .
INCLUDEPATH += /usr/include/qt5
# Input
HEADERS += test_qmake.hpp
SOURCES += test_qmake.cpp
root#petalinux18.02:~# ls
test.pro
root#petalinux18.02:~# /usr/bin/qt5/qmake
/usr/lib/qt5/mkspecs/features/resolve_config.prf:25: 'addExclusiveBuilds' is not a recognized test function.
/usr/lib/qt5/mkspecs/features/resolve_config.prf:37: 'addExclusiveBuilds' is not a recognized test function.
Project ERROR: Could not find feature force_asserts.
I know running qmake on target not host is not normal. But our client wants it then I have to do it.
I have been searching a solution in google but I found out nothing...
Is there anyone else has a solution?

New Yocto Recipe Builds but Work Directory is Deleted after Compilation

I am trying to update the recipe for zbar from 0.10.0 to 0.20.1. Here is the original recipe:
https://github.com/openembedded/meta-openembedded/blob/master/meta-oe/recipes-support/zbar/zbar_0.10.bb
My modified recipe is at the bottom of this question. The package does compile, but the problem is that something happens during the "packaging" step and the "work" directory is wiped out except for the "temp" directory inside the "work" directory. During compilation, if I list the files in the work directory, everything I expect is present, but after compilation succeeds, something cleans the files up. What am I doing wrong?
During compilation:
user#ubuntu:~/rpi/build/tmp/work/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/zbar/0.20.1-r0$ cd ../0.20.1-r0/ ; ls
build image pkgdata sysroot-destdir
configure.sstate license-destdir pseudo temp
debugsources.list package recipe-sysroot
git packages-split recipe-sysroot-native
After Compilation:
user#ubuntu:~/rpi/build/tmp/work/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/zbar/0.20.1-r0$ cd ../0.20.1-r0/ ; ls
temp
Yocto Recipe:
DESRIPTION = "2D barcode scanner toolkit."
SECTION = "graphics"
LICENSE = "LGPL-2.1"
DEPENDS = "pkgconfig intltool-native libpng jpeg"
LIC_FILES_CHKSUM = "file://LICENSE;md5=243b725d71bb5df4a1e5920b344b86ad"
S = "${WORKDIR}/git"
SRCREV = "edcf08b49e0a5fe71c18fa9d4b8ed83ed8fc9082"
SRC_URI = "git://github.com/mchehab/zbar.git"
inherit autotools pkgconfig
EXTRA_OECONF = " --without-x --without-imagemagick --without-qt --without-python2 --disable-video --without-gtk"
FILES_${PN} += "${bindir}"
FILES_${PN} += "${libdir}"
do_install_append() {
echo "done..."
}
This is because of the rm_work class. You can remove,
INHERIT += "rm_work"
this from local.conf or in according image recipe file. Or you can disable the rm_work only for your recipe using,
RM_WORK_EXCLUDE += "zbar"
in conf/local.conf.

qmake: make uninstall tries to remove system folders containing files installed with INSTALLS

This is my .pro file:
TEMPLATE = app
TARGET = myapp
INCLUDEPATH += .
win32 {
RC_FILE = win32/myapp.rc
}
unix {
target.path = /usr/share/myapp/
shortcutfiles.files += unix/myapp.desktop
shortcutfiles.path = /usr/share/applications/
data.files += unix/myapp.png
data.path = /usr/share/pixmaps/
INSTALLS += target
INSTALLS += shortcutfiles
INSTALLS += data
}
SOURCES += myapp.cpp
QT += webkitwidgets
RESOURCES += \
myapp.qrc
Under linux, the make uninstall command, while removing the actual installed files and folder, tries to remove the /usr/share/applications/ and /usr/share/pixmaps/ folders (with rmdir); and because they are not empty folders it fails with error code 1 (ignored actually).
How to modify my .pro file to prevent make uninstall from trying to remove those system folders?
Thanks.

debug_and_release option didn't work for linux

I'm trying to build my qt-plugin in both debug and release modes under Linux OS (Ubuntu 13.10), but it seems to me qmake ignores CONFIG += debug_and_release option. I also tried to use CONFIG += build_all, but it didn't work to. When I use the same options on Windows Qt generated two output files (for example plugin.a and plugind.a), but on Linux i get just one of them. When I force QtCreator to build my project in opposite mode (debug instead of relesae) it overrides already generated target file with the one that has the same name. Where did I go wrong?
Maybe the problem is that in your .pro file you should have set different target directories or different target file names. I do not know why but it looks like on Windows the target file names generated into your Makefiles are different and on Linux they are not different. You can try to change either your target directory or your target file name for debug build.
Try either
CONFIG(release, debug|release) {
TARGET = plugin
} else {
TARGET = plugind
}
or
CONFIG(release, debug|release) {
DESTDIR = release
OBJECTS_DIR = release/.obj
MOC_DIR = release/.moc
RCC_DIR = release/.rcc
UI_DIR = release/.ui
} else {
DESTDIR = debug
OBJECTS_DIR = debug/.obj
MOC_DIR = debug/.moc
RCC_DIR = debug/.rcc
UI_DIR = debug/.ui
}

Resources