Compiling: undefined reference "clock_gettime and memcpy" for Qt project - qt

I try to compile Qt project with CentOS.
This question describe what I have done in detail and
I want to do with another glibc libraries /users/my/lib64/ (I can't update /lib64/) by referring to this.
This is the compile out put:
g++ ./main.o ./moc_widget.o ./widget.o \
-o ./test -Wl,--rpath=/users/my/lib64 \
-Wl,--rpath=/users/my/Qt/5.9.1/gcc_64/lib \
-Wl,--dynamic-linker=/users/my/lib64/libc.so.6 \
-Wl,--dynamic-linker=/users/my/lib64/libz.so.1 \
-L/users/my/Qt/5.9.1/gcc_64/lib -lQt5Widgets \
-lQt5Gui -lQt5Core -lGL -lpthread -lglib-2.0 -lrt -lX11 \
-I/users/my/test/2 \
-I/users/my/Qt/5.9.1/gcc_64/include \
-I/users/my/Qt/5.9.1/gcc_64/include/QtWidgets \
-I/users/my/Qt/5.9.1/gcc_64/include/QtCore \
-I/users/my/Qt/5.9.1/gcc_64/include/QtGui
.pro file :
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += qt
SOURCES += \
main.cpp \
widget.cpp
HEADERS += \
widget.h
FORMS += \
widget.ui
gcc version : 6.1.0
But the error:
/users/my/Qt/5.9.1/gcc_64/lib/libQt5Core.so: undefined reference to `clock_gettime#GLIBC_2.17'
/users/my/Qt/5.9.1/gcc_64/lib/libQt5Widgets.so: undefined reference to `memcpy#GLIBC_2.14'
collect2 ld returned exit 1 status
How to solve it ?

g++ ./main.o ./moc_widget.o ./widget.o \
-o ./test -Wl,--rpath=/users/my/lib64 \
-Wl,--rpath=/users/my/Qt/5.9.1/gcc_64/lib \
-Wl,--dynamic-linker=/users/my/lib64/libc.so.6 \
-Wl,--dynamic-linker=/users/my/lib64/libz.so.1 \
-L/users/my/Qt/5.9.1/gcc_64/lib -lQt5Widgets \
-lQt5Gui -lQt5Core -lGL -lpthread -lglib-2.0 -lrt -lX11 \
-I...
This command line is completely bogus (you didn't understand previous answer): there can only be one dynamic linker, and it should be /users/my/lib64/ld-linux-x86-64.so.2, and not libz.so.1. By using multiple --dynamic-linker=... flags, you are simply replacing previous (incorrect) setting with a new (also incorrect) one.
It's also bogus because specifying -I... flags on the link line without any sources is pointless.
If this command succeeded, you'd end up with an executable that would simply crash immediately, because libz.so.1 is not a dynamic linker.
Now, your link fails because you are performing the link on the wrong system. You need to link on the original system (the one where you successfully linked your binary earlier, and the one which has GLIBC 2.17 or later). And then move the linked executable to your target system.
On the original system, your link command should look something like this:
g++ main.o moc_widget.o widget.o -o test \
-Wl,-rpath=/users/my/lib64 \
-Wl,--dynamic-linker=/users/my/lib64/ld-linux-x86-64.so.2 \
-L...
The two lines I indented above should be the only change from your original successful link command.

Related

Can I completely customize the flags for ./configure in a SPEC file?

My rpmbuild log tells me all the flags used when calling configure:
./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu \
--program-prefix= \
--disable-dependency-tracking \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--includedir=/usr/include \
--libdir=/usr/lib64 \
--libexecdir=/usr/libexec \
--localstatedir=/var \
--sharedstatedir=/var/lib \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--prefix=/opt/custom/SENSOR/Qt-5.15.2 \
--confirm-license \
--opensource
My problem is that the 'build' and 'host' flags (plus several others) are unknown commands for this particular configure script. How can I take complete control of the call to configure in my SPEC file? It's obviously not enough to add new flags to the %configure scriptlet, I need to remove flags that rpmbuild is adding by default.
It looks like the answer is to call configure directly instead of using the scriptlet. I.e., replace %configure with:
./configure --prefix=/opt/custom/SENSOR -confirm-license -opensource

Can't run Qt application o 32-bit Yocto build with eglfs

I have built a Yocto image with the following configuration
# Architecture of the host machine
SDKMACHINE ?= "x86_64"
# Extra image configuration defaults
EXTRA_IMAGE_FEATURES = "debug-tweaks ssh-server-openssh"
CORE_IMAGE_EXTRA_INSTALL += "openssh-sftp openssh-sftp-server"
INIT_MANAGER = "systemd"
INHERIT += "rm_work"
# Extra packages
LICENSE_FLAGS_WHITELIST = "commercial"
DISTRO_FEATURES:remove = " \
x11 \
directfb \
vulkan \
wayland \
"
DISTRO_FEATURES:append = " \
alsa \
opengl \
gles2 \
"
IMAGE_INSTALL:append = " \
coreutils \
qtbase-plugins \
qtbase-tools \
qtdeclarative \
qtdeclarative-plugins \
qtdeclarative-qmlplugins \
qtdeclarative-tools \
qtimageformats-plugins \
qtmultimedia \
qtmultimedia-plugins \
qtmultimedia-qmlplugins \
qtquickcontrols2 \
qtquicktimeline \
qtscript \
qtsvg \
qtsvg-plugins \
qtsystems \
qtsystems-qmlplugins \
qtsystems-tools \
rsync \
"
PACKAGECONFIG:append:pn-qtbase = " \
eglfs \
fontconfig \
gles2 \
libpng \
jpeg \
libs \
widgets \
"
# Image file system types to package
IMAGE_FSTYPES = "rpi-sdimg"
# Package management configuration
PACKAGE_CLASSES = "package_ipk"
MACHINE ??= "raspberrypi4"
DISTRO ??= "poky"
BBMULTICONFIG ?= ""
I could successfully build and generate and SDK. I can build the Qt app and deploy it to the device.
I set
QT_QPA_PLATFORM=eglfs
DISPLAY=:0
but I get the error
EGL library doesn't support Emulator extensions
Aborted
The error looks similar to
QT Creator can not remote run and debugging on i.Mx6 (buildroot)
but since the Pi doesn't have a Vivante driver, I wouldn't know what to pass. I tried to search for integrations
$ find / -name "*egl*"
/usr/lib/plugins/video/videonode/libeglvideonode.so
/usr/lib/plugins/videoeglvideonode
/usr/lib/plugins/egldeviceintegrations
/usr/lib/plugins/egldeviceintegrations/libqeglfs-emu-integration.so
/usr/lib/plugins/egldeviceintegrations/libqeglfs-kms-integration.so
/usr/lib/plugins/egldeviceintegrations/libqeglfs-kms-egldevice-integration.so
/usr/lib/plugins/platforms/libqminimalegl.so
/usr/lib/plugins/platforms/libqeglfs.so
but eglfs-kms or all other combinations I have tried, don't work.
If I try
QT_QPA_EGLFS_INTEGRATION=none
I get
Unable to query physical screen size, defaulting to 100 dpi.
To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
Cannot find EGLConfig, returning null config
EGL Error : Could not create the egl surface: error = 0x300b

Compile libgnat to a single LLVM bitcode file

How can I compile libgnat to a single LLVM bitcode file? The latest dragonegg release is very old, so I provide a dockerfile to make testing more easy. My end goal is to run Ada in LLVM IR bitcode interpreters.
Dockerfile for the latest official dragonegg release
FROM ubuntu:trusty
COPY . /usr/src/workdir
WORKDIR /usr/src/workdir
RUN apt-get update \
&& apt-get -y install build-essential gnat-4.6 libgmp-dev libmpfr-dev libmpc-dev libz-dev gcc-4.6-plugin-dev
# libz-dev for ld when compiling dragonegg 3.3
# gcc-4.6-plugin-dev needed when compiling dragonegg 3.3
RUN tar -xzf gcc-4.6.4.tar.gz \
&& cd gcc-4.6.4 \
&& mkdir build \
&& cd build \
&& CC=gcc-4.6 ../configure --disable-multilib --enable-languages=ada,c,c++ --prefix=/opt/gcc-4.6.4 \
&& make -j4 \
&& make install
RUN tar -xzf clang+llvm-3.3-amd64-Ubuntu-12.04.2.tar.gz \
&& mv clang+llvm-3.3-amd64-Ubuntu-12.04.2 /opt/llvm-3.3
ENV PATH="/opt/llvm-3.3/bin:/opt/gcc-4.6.4/bin:${PATH}"
RUN tar -xzf dragonegg-3.3.src.tar.gz \
&& mv dragonegg-3.3.src dragonegg-3.3 \
&& cd dragonegg-3.3 \
&& GCC=/opt/gcc-4.6.4/bin/gcc make \
&& cp dragonegg.so /opt/dragonegg.so
download gcc-4.6.4.tar.gz
download clang+llvm-3.3-amd64-Ubuntu-12.04.2.tar.gz
download dragonegg-3.3.src.tar.gz
hello.adb
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello world from Ada (dragonegg)!");
end Hello;
Run gcc hello.adb -S -O1 -o hello.ll -fplugin=/opt/dragonegg.so -fplugin-arg-dragonegg-emit-ir to compile the hello.adb file. When I try to build the binary with llc -filetype=obj hello.ll and gcc hello.o, I get the following error:
/usr/lib/x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
hello.o: In function `_ada_hello':
hello.ll:(.text+0xb): undefined reference to `ada__text_io__put_line__2'
collect2: ld returned 1 exit status
The error message indicates that the Ada runtime library is missing. Currently, I have no idea, how I can compile the libgnat to a single LLVM bitcode file, so I can link it with the program.
Why are you using DragonEgg? That's well and truly dead! See https://github.com/AdaCore/gnat-llvm instead.

QML module not found

I copied a project to another directory (forked it) and now I always get QML module not found (QtQuick.Controls). , and similar.
The original project does not show any errors. I cleaned and rebuilt everything but that didn't solve it. The project compiles and runs perfectly, so QtCreator is somehow fooled that there is some problem.
What could be the reason for this? I am using Qt 5.11, QtCreator 4.7.1
See attached picture
Project file:
QT += quick network
QT += quickcontrols2
QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked 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
SOURCES += \
blockchainaccount.cpp \
blockies.cpp \
error.cpp \
ethkey.cpp \
hqx.cpp \
hqx2.cpp \
hqx3.cpp \
hqx4.cpp \
identicon.cpp \
walletaccount.cpp \
main.cpp \
aewm.cpp \
acctlist.cpp \
block.cpp \
blocklist.cpp \
txlist.cpp \
vtlist.cpp \
transaction.cpp \
valuetransfer.cpp \
acctcatlist.cpp \
ftokens.cpp \
token.cpp \
txparam.cpp \
ftokops.cpp \
nftokens.cpp \
simres.cpp \
ftapprovals.cpp \
ftholders.cpp \
mainstats.cpp \
prefs.cpp \
blockheader.cpp \
addresslist.cpp \
acctcat.cpp \
balance.cpp \
big.cpp \
tokop.cpp \
ftholder.cpp \
ftapproval.cpp \
utils.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES +=
HEADERS += \
blockchainaccount.h \
blockies.h \
error.h \
ethkey.h \
hqx.h \
hqx2.h \
hqx3.h \
hqx4.h \
identicon.h \
walletaccount.h \
aewm.h \
acctlist.h \
block.h \
blocklist.h \
txlist.h \
vtlist.h \
transaction.h \
valuetransfer.h \
acctcatlist.h \
ftokens.h \
token.h \
txparam.h \
ftokops.h \
nftokens.h \
simres.h \
ftapprovals.h \
ftholders.h \
mainstats.h \
prefs.h \
blockheader.h \
addresslist.h \
acctcat.h \
balance.h \
big.h \
tokop.h \
ftholder.h \
ftapproval.h \
utils.h \
config.h
I too had this problem and was able to resolve it, mostly by just following the instructions in the warning message. A rough approximation of that warning message said, "please add /usr/lib64/qt/qml to your QML_IMPORT_PATH variable."
A quick search in my project found just one instance of QML_IMPORT_PATH in the project's .pro file. I added the suggested path to that line in the .pro file and the problem was resolved.
YMMV

Troubles compiling in GPS (Ada IDE) with glib.h

i'm having some troubles when trying to compile Ada code in GPS. GPS says is missing when I include it on a package. I tried installing with apt-get, and it does, but the error is still there. What can I do next? I'm running GPS on a x64 Ubuntu 12.04.
Here's the error message I got:
gprbuild -d -P/media/LUISMUNYOZ/QUINTO/str/pendulum/pendulum_portatil/pendulum.gpr
-XEXTRA=True -XOPENGL=True -XGNOME=True -XBUILD=Production
print_barrier_sync.adb contrib.gpr:1:09: warning: no compiler specified for language "Xml",
ignoring all its sources x86_64-pc-linux-gnu-gcc -c lw.c In file included from
/media/LUISMUNYOZ/QUINTO/str/pendulum/pendulum_portatil/gtkada/testgtk/opengl/lw.c:20:0:
/media/LUISMUNYOZ/QUINTO/str/pendulum/pendulum_portatil/gtkada/testgtk/opengl/lw.h:23:18:
fatal error: glib.h: No such file or directory compilation terminated.
gprbuild:* compilation phase failed
[2012-11-21 13:24:47] process exited with status 4 (elapsed time: 02.06s) [2012-11-21 13:24:56]
Could not locate executable on path: svn SVN error:
[…]
The error triggers at this point:
#ifndef LW_H
#define LW_H
#include <glib.h> <------------------------------------------
#include <GL/gl.h>
#define LW_MAX_POINTS 200
#define LW_MAX_NAME_LEN 500
The file is lw.h, which is defined in the package GtkAda. I downloaded it from GPS page.
I'd pursue #Simon's approach, but a work-around based on 2.4.2. Using the command line might be a temporary alternative while you sort out the underlying problem.
As you are using linux, here's a Makefile for the basic Interaction demo.
# Make shared, static or debug targets.
OS := $(shell uname)
OBJ = obj
TARGET = interaction
GNATMAKE = gnatmake -D $(OBJ)
CARGS = -cargs -O3 -gnatp -gnatwu -gnatf
BARGS = -bargs
LARGS = -largs
.PHONEY: clean cleaner cleanest
all:
#echo ""
#echo "Build targets:"
#echo ""
#echo " shared Use the shared Ada libraries."
#echo " static Link the Ada libraries statically."
#echo " debug Enable debugging."
#echo ""
#echo "Support targets:"
#echo ""
#echo " clean Remove *.ali *.o b~.*"
#echo " cleaner Remove target, too."
#echo " cleanest Remove build directory, too."
#echo ""
shared: $(OBJ)
shared: INCLUDE = $(shell gtkada-config --cflags)
shared: BARGS += -shared
shared: LARGS += $(shell gtkada-config --libs)
shared: LARGS += -dead_strip
shared: *.ad[sb]
#echo "building with shared libraries:"
$(GNATMAKE) $(TARGET) $(INCLUDE) $(CARGS) $(BARGS) $(LARGS)
static: $(OBJ)
static: INCLUDE = $(shell gtkada-config --static --cflags)
static: BARGS += -static
static: LARGS += $(shell gtkada-config --static --libs)
static: LARGS += -dead_strip
static: *.ad[sb]
$(GNATMAKE) $(TARGET) $(INCLUDE) $(CARGS) $(BARGS) $(LARGS)
debug: $(OBJ)
debug: INCLUDE = $(shell gtkada-config --static --cflags)
debug: BARGS += -static
debug: LARGS += $(shell gtkada-config --static --libs)
debug: *.ad[sb]
$(GNATMAKE) -g $(TARGET) $(INCLUDE) $(LARGS)
$(OBJ):
mkdir $(OBJ)
clean:
${RM} $(OBJ)/* b~*
cleaner: clean
${RM} $(TARGET)
cleanest: cleaner
${RM} -r $(OBJ)
For reference, these packages were installed on Ubuntu 12.04:
$ dpkg --get-selections | egrep "gnat|gtkada"
gnat install
gnat-4.6 install
gnat-4.6-base install
gnat-gps install
gnat-gps-common install
gnat-gps-doc install
libgnat-4.6 install
libgnatprj4.6 install
libgnatvsn4.6 install
libgtkada-bin install
libgtkada2.24.1 install
libgtkada2.24.1-dev install
I've never used GtkAda. However ... I googled glib.h and got many hits, suggesting that for plain C builds one should use - for example, from this StackOverflow question -
# Sample Makefile
CFLAGS := $(shell pkg-config --cflags glib-2.0 gtk+-2.0)
LDFLAGS := $(shell pkg-config --libs glib-2.0 gtk+-2.0)
foo: foo.c
$(CC) $(CFLAGS) $< -o $# $(LDFLAGS)
However, we're talking gprbuild here, so perhaps the GtkAda documentation is relevant? It says you need to include with "gtkada"; in your GNAT Project file, and include the location of gtkada.gpr on your ADA_PROJECT_PATH if it isn't there already (see the output of gnatls -v).
If you've already done that, please show us the GPR file.

Resources