undefined reference to `clock_gettime' for arm arm-linux-gnueabi - linux

I was trying to cross compile a file for ARM architecture using arm-lunux-gnueabi cross compiling tool chain. But I am getting below error : -
undefined reference to `clock_gettime'
Please guide me which header files or libraries should I include and how , to get rid over this error.
I am using following command for cross compiling : -
make ARCH=arm CROSS_COMPILE -C /path/to/source
Help is appreciated.

As the documentation says:
Note
Most systems require the program be linked with the librt library to
use these functions.
So link to the rt library with the -lrt flag.

Related

How can I resolve this error when linking to zlib under Linux in a D application?

I've mainly worked on Windows, so I'm quite unfamiliar with less common issues under Linux.
Here's the error I'm getting when dub tries to link my application:
/usr/bin/ld: .dub/obj/pixelperfectengine_pixelperfecteditor.o: undefined reference to symbol 'inflateEnd'
//lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1
/usr/bin/ldc2 failed with exit code 1.
I've an image handling library as a dependency, which is required for the application, and it (obviously) uses zlib for *.png compression/decompression. I've installed zlib1g-dev for Ubuntu, but did not fix my issues, and the same exact code compiles without any issues under Windows.
You need to link in zlib, as mentioned before.
I would recommend to do so via the "libs" array (see this page: https://dub.pm/package-format-json.html). The advantage of using libs over lflags is that libs will try to use pkg-config, which is a generic way to get linker / compile flags for C[++] libraries on POSIX. It works on Linux and Mac OSX. If pkg-config is not found, dub will just default to do what lflags would do in the first place.
Here's an example from my own project: https://github.com/Geod24/libsodiumd/blob/9b397645e2fc3ca502acb58e1b4631d3faf094e2/dub.json
/lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
This error is telling you that you must add -lz to command line. I don't know what dub is, but somehow you must convince it to add -lz to the link command it constructs.
It's probably enough to add -lz to the lflags in your dub file.

Cross compiling Mesa for arm

I have cross compiled Qt5.9.1 for an arm linux platform. I see that qtwebengine because mesa/libegl1-mesa-dev is missing.
I am relatively new to linux and i have been trying to cross compile mesa12, mesa13 and mesa17. But all failed.
Is libegl1-mesa-dev absolutely necessary to build qtwebengine to work on linuxfb ? If so, can anyone provide me the dependency list for opengl without x11 and some guiding light to how to cross compile it ?
I came to know that QtWebengine can use software renderer such as QtQuick2drenderer in Qt 5.7. What are the possibilities that i can do the same in Qt 5.9.1 ?
Thank you for your time.
Edit :
Mesa version : 12.0.6
cross compiled dependencies : udev-182 and util-linux-2.30 (for libblkid)
This is the error i am getting :
CCLD libgbm.la
../../src/loader/.libs/libloader.a(libxmlconfig_la-xmlconfig.o): In function `__getProgramName':
xmlconfig.c:(.text+0x64): undefined reference to `__progname'
collect2: error: ld returned 1 exit status
configure i have used
./configure CPPFLAGS="-I$INCLUDEPATH -DMESA_EGL_NO_X11_HEADERS" CFLAGS="-I$INCLUDEPATH -DMESA_EGL_NO_X11_HEADERS" LDFLAGS="-L$LIBPATH" --host=$HOST --prefix=$PREFIX --enable-dri3=no --enable-gallium-llvm=no --disable-omx --enable-gallium-tests=no --enable-gallium-osmesa=no -enable-glx=dri --with-gallium-drivers=swrast --with-dri-drivers=swrast --disable-glx --enable-va=no --enable-vdpau=no --with-egl-platforms=drm

Cross Compilation of OpenCV for ARM fails

I am following this site to compile OpenCV for ARM.
It could not find my compiler so i hardcoded it into cmake file
find_program(CMAKE_C_COMPILER NAMES arm-linux-gnueabi-gcc-4.7)
find_program(CMAKE_CXX_COMPILER NAMES arm-linux-gnueabi-g++-4.7)
set(ARM_LINUX_SYSROOT /usr/arm-linux-gnueabi CACHE PATH "ARM cross compilation system root")
It compiles to aproximately 50% and then throws the following error:
Linking CXX shared library ../../lib/libopencv_viz.so
/usr/lib/libvtkCharts.so.5.8.0: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
I am not every experienced in cross compilation (or straight compilation for the matter). How do i fix this?
I think it is a mismatch between libopencv_viz and libvtkCharts. Some of your 3rdparty libs are built for another platform. These libraries themselves must be recompiled from source to match the details (ABI, dynamic system library dependencies, etc) of the system on which they are intended to be used.
Compiling OpenCV 2.4.10 worked for me. I did not have any preferred version. If you want to compile v3.0 see #Kornel's answer, that suggests to leave viz library out of compilation.
Use this command to checkout v2.4.10
git checkout 2.4.10

compiling library for arm architecture

I want to know how i can cross compile a library for ARM architecture. Suppose i have libcurl library for Intel architecture and now i want to run the application in ARM architecture using this library. What are the steps i need to perform for this cross compilation. I am using Ubuntu 32-bit machine.
I have gone through the basic steps like
./configure --host= ...
make
make install
but could not get the complete idea. Please provide some useful link or if anybody can explain the things. Any help would be greatly appreciated.
I know there is a post in SO for this already "http://stackoverflow.com/questions/5832734/cross-compiling-a-library-from-intel-to-arm" , but i did not get the things clarified by this.
Platform : linux , gcc compiler
You need to give toolchain for your architecture the host parameter, for example for arm-1808 which basically has an arm architecture, the host parameter would be arm-none-linux. I used the following configure command for my architecture, and it compiled successfully, and I am able to run the application on my arm board.
0.
If tool chain is not in your PATH, then you can include it with a command like this:
export PATH=/home/user/CodeSourcery/Sourcery_G++_Lite/bin/:$PATH
1.
./configure --host=arm-none-linux-gnueabi --build=i686-linux CFLAGS='-Os' --with-ssl=/usr/bin/openssl --enable-smtp
2.
make
3.
sudo make install
4. Now its time to build your application.
arm-none-linux-gnueabi-gcc -o email smtp-multi.c -I/usr/local/include -L/usr/local/lib -lcurl
Basically you need to give CPP and CF flags while compiling your application, to find out the CF and CPP flags you can use the following commands respectively:
curl-config --cflags
curl-config --libs
If above commands do not work then try:
arm-none-linux-gnueabi-gcc -o email smtp-multi.c -lcurl

linux library problem

Everybody out there,
I'm writing a c code which have a strange problem when I compile it .
The source code is OK.
I compile it with following option:
$ gcc above_sample.c -I/home/hadoop/project/hadoop-0.20.2/src/c++/libhdfs -L/home/hadoop/project/hadoop-0.20.2/c++/Linux-amd64-64/lib -lhdfs -o above_sample.
But it show the out put like that:
/usr/bin/ld: warning: libjvm.so, needed by /home/hadoop/project/hadoop-0.20.2/c++/Linux-amd64-64/lib/libhdfs.so, not found (try using -rpath or -rpath-link) /home/hadoop/project/hadoop-0.20.2/c++/Linux-amd64-64/lib/libhdfs.so: undefined reference to `JNI_CreateJavaVM#SUNWprivate_1.1'
/home/hadoop/project/hadoop-0.20.2/c++/Linux-amd64-64/lib/libhdfs.so: undefined reference to `JNI_GetCreatedJavaVMs#SUNWprivate_1.1'
collect2: ld returned 1 exit status
I searched for libjvm.so i found It in my system in /usr/java/lib.
I made a symbolic link of it but did not work.
i copied the library in to several places like usr/lib check the LD_library_Path
but could not manage to compile the program it showing the same error again and again
Can any one tell me what I'm doing wrong ?
how to link .so file to gcc ?
or how .so files are linked in program?
Try adding:
-L/usr/java/lib
To your linker command, since that's the library your linker is not being able to find: I_GetCreatedJavaVMs#SUNWprivate_1.1.
A little piece of advice: it's not a good idea to mess with LD_LIBRARY_PATH. Just fix your linker command.
Linker gives a warning about not found reference to function JNI_CreateJavaVM#SUNWprivate_1.1
/usr/bin/ld: warning: libhdfs.so: undefined reference to
`JNI_CreateJavaVM#SUNWprivate_1.1'
This function name might be specific for library from Sun/Oracle HotSpot JVM. Other JVMs may have another name. For example, mine OpenJDK had only shorter name such as JNI_CreateJavaVM and linker gave me the same warning.
You may get list of the functions from your libjvm.so by running command:
readelf -s libjvm.so | grep JNI_CreateJavaVM # given that you are in catalog containing libjvm.so
If output does not contain required function, then you might want to install another JDK.
That's what worked for me:
CDH=/opt/cloudera/parcels/CDH
OS_ARCH=amd64
gcc hdfs_example.c -I$CDH/include -L$CDH/lib64 \
-L/usr/java/default/jre/lib/${OS_ARCH}/server \
-ljvm -lhdfs -o hdfs_write_test

Resources