debug_and_release option didn't work for linux - 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
}

Related

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?

Scons -u option doesn't work?

Seems -u doesn't work on for me ( I am using scons-2.3.6).
To simplify the context, you can imagine my project structure like,
+root
+project
- bar.vcxproj (generated vs project)
-SConstruct
-bar.c
Inside SConstruct, I have put code like:
env_base = Environment()
...
env_base.StaticLibrary(target = 'bar', source = ['bar.c'])
...
If I execute command "scons" in root folder, everything works perfectly.
But If I execute command "scons -u" in project folder, scons can find my SConstruct up in root folder, but no file get compiled.
BTW : The reason for me to execute "scons -u" in project folder is because I want to put the generated vsproj in projet folder and use BuildCommandLine to compile the project.
I guess I didn't use "-u" correctly, what will be the elegant solution for my situation?
1st edit:
As bdbaddog asked, I have put the SConstruct here:
def BuildConfig(env, config):
env.Append(CCFLAGS = '/W 4')
env.Append(CCFLAGS = '/WX')
if config == "debug":
env.Append(CCFLAGS = '/DEBUG')
#env.Append(CCFLAGS = '-Zi /Fd${TARGET}.pdb')
env.Append(CCFLAGS = '/Z7')
elif config == "release":
pass
env_base = Environment()
lib = env_base.StaticLibrary(target = 'bar', source = ['bar.c'])
opts=Variables()
opts.Add('target', 'Compile Target (debug/release).', "debug")
# there is more in my project....
opts.Update(env_base) # update environment
# here I want to use my own command to build the project, so it can support different build option that is defined by me.
env_base['MSVSBUILDCOM'] = "scons -u target=$(Configuration)"
target = env_base["target"]
BuildConfig(env_base, env_base['target'])
env_base.MSVSProject(target = "project\\bar" + env_base['MSVSPROJECTSUFFIX'],
srcs = ["..\\bar.c"],
incs = [],
localincs = "",
resources = "",
misc = "",
buildtarget = lib,
variant = ['debug'],
auto_build_solution=0)
SCons only builds files under the current directory by default.
If you you wanted to only build files in a certain directory (for which there are rules that build the targets there), you can invoke SCons as follows:
scons the_target_directory_I_want_to_build
Though this may cause sources for targets in that directory to also be built.

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.

How to add global CXX compiler flag to yocto build

It seems something obvious to me, but I couldn't find any solution. Suppose I want to add or change a compiler flag/option which applies to all yocto recipes. It is possible to add a global flag somewhere, without changing the recipes ?
You can add it to the machine configuration file.
The machine configuration file is in the board support layer, under conf/machine. It is named $MACHINE.conf, where MACHINE is defined in your local.conf.
Here are the ones in poky 1.4. Yours might be in a layer outside of poky.
> ls -1 meta-yocto-bsp/conf/machine/
atom-pc.conf
beagleboard.conf
mpc8315e-rdb.conf
routerstationpro.conf
> ls -1 meta/conf/machine/
include
qemuarm.conf
qemumips.conf
qemuppc.conf
qemux86-64.conf
qemux86.conf
Once you identify your board configuration file, add a line to the end to add to your C Flags:
TARGET_CFLAGS += " <my flags> "
You can add global compiler options for Yocto builds in poky/meta/conf/bitbake.conf. After adding options, check the bitbake environment using the command bitbake -e
cat poky/meta/conf/bitbake.conf
...
...
##################################################################
# Build flags and options.
##################################################################
export BUILD_CPPFLAGS = "-isystem${STAGING_INCDIR_NATIVE}"
BUILDSDK_CPPFLAGS = "-isystem${STAGING_INCDIR}"
export CPPFLAGS = "${TARGET_CPPFLAGS}"
export BUILD_CFLAGS = "${BUILD_CPPFLAGS} ${BUILD_OPTIMIZATION}"
BUILDSDK_CFLAGS = "${BUILDSDK_CPPFLAGS} ${BUILD_OPTIMIZATION}"
export CFLAGS = "${TARGET_CFLAGS}"
export TARGET_CFLAGS = "${TARGET_CPPFLAGS} ${SELECTED_OPTIMIZATION}"
export BUILD_CXXFLAGS = "${BUILD_CFLAGS}"
export CXXFLAGS = "${TARGET_CXXFLAGS}"
export TARGET_CXXFLAGS = "${TARGET_CFLAGS}"

How to avoid having version numbers in .so file name

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.

Resources