Simple linking test to MKL libraries fails - c++

I wanted to test my MKL installation by compiling a simple program with the library:
#include <iostream>
#include <mkl.h>
int main(void)
{
std::cout << "Hello World\n";
return 0;
}
Now by using the MKL Link Line Advisor, I get the following compilation line:
g++ -DMKL_ILP64 -m64 -I${MKLROOT}/include test.cpp -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl -o test
with using GCC-6.3.0 and MKLROOT set to the correct path. But when compiling, I get
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'fopen'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'fflush'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'free'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_intel_ilp64.so: error: undefined reference to 'exit'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_intel_ilp64.so: error: undefined reference to 'memset'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'strcasecmp'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'fclose'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'syscall'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'strtol'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'malloc'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so: error: undefined reference to 'strcmp'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'calloc'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'getenv'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'fwrite'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to '__ctype_b_loc'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'realloc'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'vfprintf'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'ceil'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'gettimeofday'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'strtoul'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'fopen64'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'strtod'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'stdout'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'sched_yield'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'mmap'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'fread'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'stderr'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'mprotect'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'qsort'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'munmap'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'getuid'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'vsnprintf'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'strchr'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'isspace'
/home/rolandar/local_opt/intel/mkl/lib/intel64/libmkl_core.so: error: undefined reference to 'strdup'
Is my MKL-installation broken? Or did I forget something else?

When removing the option -ldl, it works, but I have no explanation, why.

Could you try this?
-L${MKLROOT}/lib/intel64 Wl,--no-as-needed -lmkl_rt -lpthread -lm -ldl

Related

Android NDK with static library: linker throws 'undefined reference' all the time

First, I want to say that I've tried all other solutions on SO and the rest of the Internet.
My goal is to build dlib for android as a static library and create shared object as a wrap for JNI.
First part is compiling dlib as a static library. Here is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := dlib
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/entropy_encoder/entropy_encoder_kernel_2.cpp
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/entropy_encoder/entropy_encoder_kernel_1.cpp
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/all/source.cpp
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/gui_widgets/drawable.cpp
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/gui_widgets/widgets.cpp
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/gui_widgets/base_widgets.cpp
... cut many src files for simplicity.
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/threads/thread_pool_extension.cpp
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/misc_api/misc_api_kernel_1.cpp
LOCAL_SRC_FILES += $(LOCAL_PATH)/../dlib/misc_api/misc_api_kernel_2.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)
and Application.mk:
NDK_TOOLCHAIN_VERSION := clang
APP_ABI := armeabi-v7a x86
APP_CPPFLAGS := -std=c++11 -frtti -fexceptions -Os
APP_PLATFORM := android-15
APP_STL := c++_static
#APP_CFLAGS+=-DDLIB_NO_GUI_SUPPORT=on
#APP_CFLAGS+=-DDLIB_PNG_SUPPORT=off
APP_CFLAGS+=-DDLIB_JPEG_SUPPORT=on
APP_CFLAGS+=-DDLIB_JPEG_STATIC=on
###
ANDROID_NATIVE_API_LEVEL = 15
ANDROID_NDK_HOST_X64 = true
ANDROID_SDK_TARGET = 15
This works fine. I get my static library (which is 8 times bigger than when compiled with system gcc).
Next I'm trying to create wrap for JNI. My mod.cpp:
#include <jni.h>
#include <string>
#include "dlib/image_processing/frontal_face_detector.h"
extern "C"
JNIEXPORT jstring JNICALL
Java_com_cake_appa_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
std::string hello = "Hello from C++";
dlib::frontal_face_detector detector = dlib::get_frontal_face_detector();
return env->NewStringUTF(hello.c_str());
}
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := dlib
LOCAL_SRC_FILES := $(LOCAL_PATH)/../lib/$(TARGET_ARCH_ABI)/libdlib.a
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mod
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/
LOCAL_C_INCLUDES += /usr/include/
LOCAL_SRC_FILES += $(LOCAL_PATH)/../mod.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_STATIC_LIBRARIES := dlib
LOCAL_STATIC_LIBRARY := dlib
include $(BUILD_SHARED_LIBRARY)
Application.mk:
NDK_TOOLCHAIN_VERSION := clang
APP_ABI := armeabi-v7a x86
APP_CPPFLAGS := -std=c++11 -frtti -fexceptions -Os
APP_PLATFORM := android-15
APP_STL := c++_static
And what I get when I try to build:
cake#cake-hi:/media/storage/tmp/ndk-wrap$ export NDK_PROJECT_PATH=`pwd`
cake#cake-hi:/media/storage/tmp/ndk-wrap$ /storage/android-sdk/ndk-bundle/ndk-build
[armeabi-v7a] Compile++ thumb: mod <= mod.cpp
[armeabi-v7a] SharedLibrary : libmod.so
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1958: error: undefined reference to 'XClearArea'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1959: error: undefined reference to 'XFlush'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1984: error: undefined reference to 'XVaCreateNestedList'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1985: error: undefined reference to 'XSetICValues'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1986: error: undefined reference to 'XFree'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1834: error: undefined reference to 'XAllocSizeHints'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1840: error: undefined reference to 'XSetNormalHints'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1841: error: undefined reference to 'XFree'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1844: error: undefined reference to 'XResizeWindow'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1846: error: undefined reference to 'XFlush'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1760: error: undefined reference to 'XwcTextListToTextProperty'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1761: error: undefined reference to 'XSetWMName'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1762: error: undefined reference to 'XFree'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1763: error: undefined reference to 'XFlush'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1712: error: undefined reference to 'XDestroyWindow'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1893: error: undefined reference to 'XTranslateCoordinates'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1868: error: undefined reference to 'XMoveWindow'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1869: error: undefined reference to 'XFlush'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1593: error: undefined reference to 'XCreateWindow'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1620: error: undefined reference to 'XCreateFontSet'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1623: error: undefined reference to 'XVaCreateNestedList'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1624: error: undefined reference to 'XCreateIC'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1631: error: undefined reference to 'XFree'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1632: error: undefined reference to 'XFreeStringList'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1642: error: undefined reference to 'XGetICValues'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1644: error: undefined reference to 'XSelectInput'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1652: error: undefined reference to 'XSetWMProtocols'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1668: error: undefined reference to 'XAllocSizeHints'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1674: error: undefined reference to 'XSetNormalHints'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1690: error: undefined reference to 'XDestroyIC'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1692: error: undefined reference to 'XFreeFontSet'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1777: error: undefined reference to 'XMapRaised'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1804: error: undefined reference to 'XUnmapWindow'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:639: error: undefined reference to 'XPending'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:649: error: undefined reference to 'XNextEvent'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:653: error: undefined reference to 'XFilterEvent'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:679: error: undefined reference to 'XInternAtom'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:685: error: undefined reference to 'XChangeProperty'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:794: error: undefined reference to 'XwcLookupString'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:797: error: undefined reference to 'XwcLookupString'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:731: error: undefined reference to 'XAllocSizeHints'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:737: error: undefined reference to 'XSetNormalHints'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:745: error: undefined reference to 'XResizeWindow'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:752: error: undefined reference to 'XMoveWindow'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1050: error: undefined reference to 'XCheckIfEvent'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:697: error: undefined reference to 'XChangeProperty'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:717: error: undefined reference to 'XSendEvent'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:804: error: undefined reference to 'XLookupString'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1018: error: undefined reference to 'XDestroyWindow'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1223: error: undefined reference to 'XInitImage'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1225: error: undefined reference to 'XCreateGC'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1227: error: undefined reference to 'XPutImage'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1229: error: undefined reference to 'XFreeGC'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1266: error: undefined reference to 'XGetModifierMapping'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1272: error: undefined reference to 'XkbKeycodeToKeysym'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1294: error: undefined reference to 'XFreeModifiermap'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1365: error: undefined reference to 'XSetSelectionOwner'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1423: error: undefined reference to 'XInternAtom'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1424: error: undefined reference to 'XGetSelectionOwner'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1436: error: undefined reference to 'XConvertSelection'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1441: error: undefined reference to 'XPeekIfEvent'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1444: error: undefined reference to 'XGetWindowProperty'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1461: error: undefined reference to 'XGetWindowProperty'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1468: error: undefined reference to 'XwcTextPropertyToTextList'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1473: error: undefined reference to 'XwcFreeStringList'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1485: error: undefined reference to 'XwcFreeStringList'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:1934: error: undefined reference to 'XScreenNumberOfScreen'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:334: error: undefined reference to 'XOpenDisplay'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:337: error: undefined reference to 'XOpenDisplay'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:369: error: undefined reference to 'XFreeFontSet'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:371: error: undefined reference to 'XCreateFontSet'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:376: error: undefined reference to 'XExtentsOfFontSet'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:379: error: undefined reference to 'XFreeStringList'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:322: error: undefined reference to 'XwcTextExtents'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:388: error: undefined reference to 'XFreeGC'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:389: error: undefined reference to 'XFreePixmap'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:393: error: undefined reference to 'XDefaultDepth'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:393: error: undefined reference to 'XCreatePixmap'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:394: error: undefined reference to 'XCreateGC'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:398: error: undefined reference to 'XSetForeground'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:399: error: undefined reference to 'XSetBackground'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:400: error: undefined reference to 'XFillRectangle'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:401: error: undefined reference to 'XSetForeground'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:328: error: undefined reference to 'XwcDrawString'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:405: error: undefined reference to 'XGetImage'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:313: error: undefined reference to 'XAllocColor'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:435: error: undefined reference to 'XQueryColor'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:449: error: undefined reference to 'XFreeGC'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:450: error: undefined reference to 'XFreeFontSet'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:451: error: undefined reference to 'XFreePixmap'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_widgets/nativefont.h:452: error: undefined reference to 'XCloseDisplay'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:148: error: undefined reference to 'XPutBackEvent'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:153: error: undefined reference to 'XSendEvent'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:160: error: undefined reference to 'XCloseIM'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:163: error: undefined reference to 'XCloseDisplay'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:191: error: undefined reference to 'XInitThreads'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:203: error: undefined reference to 'XOpenDisplay'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:208: error: undefined reference to 'XOpenDisplay'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:225: error: undefined reference to 'XInternAtom'
/media/storage/tmp/ndk-dlib/jni/../dlib/all/../gui_core/gui_core_kernel_2.cpp:272: error: undefined reference to 'XCreateWindow'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
/media/storage/android-sdk/ndk-bundle/build/core/build-binary.mk:677: recipe for target '/media/storage/tmp/ndk-wrap/obj/local/armeabi-v7a/libmod.so' failed
make: *** [/media/storage/tmp/ndk-wrap/obj/local/armeabi-v7a/libmod.so] Error 1
Linker says it can't find X libraries. I guess, my system package libx11-dev:i386 won't do anything. Tried LOCAL_ALLOW_UNDEFINED_SYMBOLS := true which results in endless build which eats all system memory (6 GiB process).
Same thing happens to OpenCV, but undefined references are with something else.
I'm on Debian 9.3 x86_64.
LOCAL_C_INCLUDES += /usr/include/
Don't do this; these header files are not compatible with Android. Android does not use glibc.
I guess, my system package libx11-dev:i386 won't do anything.
No, it won't, but you do need to get your dependency from somewhere. You'll need to build that library for Android and include it (or rewrite your code to not use that library).

How to fix undefined reference to v8 error?

I'm trying to configure and build a sample of node.js addon. The sample was taken from node.js documentation and the source code can be found here
https://github.com/nodejs/node-addon-examples/tree/master/8_passing_wrapped/node_0.12
When I try to compile this in CLion (on Ubuntu 14.04) or when I use node-gyp to build it I've got some errors:
/home/smorzhov/Documents/clion-2016.1/bin/cmake/bin/cmake --build /home/smorzhov/.CLion2016.1/system/cmake/generated/test4-94ee4803/94ee4803/Debug --target all -- -j 4
[ 25%] Linking CXX executable test4
CMakeFiles/test4.dir/myobject.cpp.o: In function `demo::MyObject::Init(v8::Isolate*)':
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:26: undefined reference to `v8::FunctionTemplate::New(v8::Isolate*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&), v8::Local<v8::Value>, v8::Local<v8::Signature>, int)'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:27: undefined reference to `v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:27: undefined reference to `v8::FunctionTemplate::SetClassName(v8::Local<v8::String>)'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:28: undefined reference to `v8::FunctionTemplate::InstanceTemplate()'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:28: undefined reference to `v8::ObjectTemplate::SetInternalFieldCount(int)'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:30: undefined reference to `v8::FunctionTemplate::GetFunction()'
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:30: undefined reference to `demo::MyObject::constructor'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Function>::Reset()':
/usr/include/node/v8.h:7224: undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Function>::New(v8::Isolate*, v8::Function*)':
/usr/include/node/v8.h:7176: undefined reference to `v8::V8::GlobalizeReference(v8::internal::Isolate*, v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `Reset<v8::Function>':
/usr/include/node/v8.h:7235: undefined reference to `demo::MyObject::constructor'
CMakeFiles/test4.dir/myobject.cpp.o: In function `demo::MyObject::New(v8::FunctionCallbackInfo<v8::Value> const&)':
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:38: undefined reference to `v8::Value::NumberValue() const'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Function>::New(v8::Isolate*, v8::PersistentBase<v8::Function> const&)':
/usr/include/node/v8.h:7124: undefined reference to `demo::MyObject::constructor'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Function>::New(v8::Isolate*, v8::Function*)':
/usr/include/node/v8.h:7134: undefined reference to `v8::HandleScope::CreateHandle(v8::internal::Isolate*, v8::internal::Object*)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `demo::MyObject::New(v8::FunctionCallbackInfo<v8::Value> const&)':
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:47: undefined reference to `v8::Function::NewInstance(int, v8::Local<v8::Value>*) const'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Function>::New(v8::Isolate*, v8::PersistentBase<v8::Function> const&)':
/usr/include/node/v8.h:7124: undefined reference to `demo::MyObject::constructor'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Function>::New(v8::Isolate*, v8::Function*)':
/usr/include/node/v8.h:7134: undefined reference to `v8::HandleScope::CreateHandle(v8::internal::Isolate*, v8::internal::Object*)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `demo::MyObject::NewInstance(v8::FunctionCallbackInfo<v8::Value> const&)':
/home/smorzhov/ClionProjects/test4/test4/myobject.cpp:57: undefined reference to `v8::Function::NewInstance(int, v8::Local<v8::Value>*) const'
CMakeFiles/test4.dir/myobject.cpp.o: In function `ClearWeak<void>':
/usr/include/node/v8.h:7298: undefined reference to `v8::V8::ClearWeak(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Object>::Reset()':
/usr/include/node/v8.h:7224: undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `node::ObjectWrap::Wrap(v8::Local<v8::Object>)':
/usr/include/node/node_object_wrap.h:56: undefined reference to `v8::Object::InternalFieldCount()'
/usr/include/node/node_object_wrap.h:57: undefined reference to `v8::Object::SetAlignedPointerInInternalField(int, void*)'
/usr/include/node/node_object_wrap.h:58: undefined reference to `v8::Isolate::GetCurrent()'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Object>::Reset()':
/usr/include/node/v8.h:7224: undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Object>::New(v8::Isolate*, v8::Object*)':
/usr/include/node/v8.h:7176: undefined reference to `v8::V8::GlobalizeReference(v8::internal::Isolate*, v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `SetWeak<v8::Object, node::ObjectWrap>':
/usr/include/node/v8.h:7257: undefined reference to `v8::V8::MakeWeak(v8::internal::Object**, void*, void (*)(v8::WeakCallbackData<v8::Value, void> const&))'
CMakeFiles/test4.dir/myobject.cpp.o: In function `ClearWeak<void>':
/usr/include/node/v8.h:7298: undefined reference to `v8::V8::ClearWeak(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `node::ObjectWrap::WeakCallback(v8::WeakCallbackData<v8::Object, node::ObjectWrap> const&)':
/usr/include/node/node_object_wrap.h:101: undefined reference to `v8::HandleScope::HandleScope(v8::Isolate*)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::Local<v8::Object>::New(v8::Isolate*, v8::Object*)':
/usr/include/node/v8.h:7134: undefined reference to `v8::HandleScope::CreateHandle(v8::internal::Isolate*, v8::internal::Object*)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `v8::PersistentBase<v8::Object>::Reset()':
/usr/include/node/v8.h:7224: undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
CMakeFiles/test4.dir/myobject.cpp.o: In function `node::ObjectWrap::WeakCallback(v8::WeakCallbackData<v8::Object, node::ObjectWrap> const&)':
/usr/include/node/node_object_wrap.h:108: undefined reference to `v8::HandleScope::~HandleScope()'
/usr/include/node/node_object_wrap.h:108: undefined reference to `v8::HandleScope::~HandleScope()'
CMakeFiles/test4.dir/addon.cpp.o: In function `demo::Add(v8::FunctionCallbackInfo<v8::Value> const&)':
/home/smorzhov/ClionProjects/test4/test4/addon.cpp:27: undefined reference to `v8::Number::New(v8::Isolate*, double)'
CMakeFiles/test4.dir/addon.cpp.o: In function `demo::InitAll(v8::Local<v8::Object>)':
/home/smorzhov/ClionProjects/test4/test4/addon.cpp:31: undefined reference to `v8::Object::GetIsolate()'
CMakeFiles/test4.dir/addon.cpp.o: In function `_register_addon':
/home/smorzhov/ClionProjects/test4/test4/addon.cpp:37: undefined reference to `node_module_register'
CMakeFiles/test4.dir/addon.cpp.o: In function `v8::Value::ToObject() const':
/usr/include/node/v8.h:7778: undefined reference to `v8::Isolate::GetCurrent()'
/usr/include/node/v8.h:7778: undefined reference to `v8::Isolate::GetCurrentContext()'
/usr/include/node/v8.h:7779: undefined reference to `v8::Value::ToObject(v8::Local<v8::Context>) const'
CMakeFiles/test4.dir/addon.cpp.o: In function `demo::MyObject* node::ObjectWrap::Unwrap<demo::MyObject>(v8::Local<v8::Object>)':
/usr/include/node/node_object_wrap.h:29: undefined reference to `v8::Object::InternalFieldCount()'
CMakeFiles/test4.dir/addon.cpp.o: In function `v8::Object::GetAlignedPointerFromInternalField(int)':
/usr/include/node/v8.h:7636: undefined reference to `v8::Object::SlowGetAlignedPointerFromInternalField(int)'
CMakeFiles/test4.dir/addon.cpp.o: In function `void node::NODE_SET_METHOD<v8::Local<v8::Object> >(v8::Local<v8::Object> const&, char const*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&))':
/usr/include/node/node.h:239: undefined reference to `v8::Isolate::GetCurrent()'
/usr/include/node/node.h:240: undefined reference to `v8::HandleScope::HandleScope(v8::Isolate*)'
/usr/include/node/node.h:242: undefined reference to `v8::FunctionTemplate::New(v8::Isolate*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&), v8::Local<v8::Value>, v8::Local<v8::Signature>, int)'
/usr/include/node/node.h:243: undefined reference to `v8::FunctionTemplate::GetFunction()'
/usr/include/node/node.h:244: undefined reference to `v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::String::NewStringType, int)'
/usr/include/node/node.h:245: undefined reference to `v8::Function::SetName(v8::Local<v8::String>)'
/usr/include/node/node.h:246: undefined reference to `v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)'
/usr/include/node/node.h:246: undefined reference to `v8::HandleScope::~HandleScope()'
/usr/include/node/node.h:246: undefined reference to `v8::HandleScope::~HandleScope()'
collect2: error: ld returned 1 exit status
make[2]: *** [test4] Error 1
make[1]: *** [CMakeFiles/test4.dir/all] Error 2
make: *** [all] Error 2
Maybe it is important, the IDE don't understand
#include node.h
and I have to change it to #include node/node.h
It seems, that compiler sees only node and v8 headers and cannot find their sources.
Can somebody help me to fix that? How to make compiler to see node and v8 sources?
PS. My CmakeLists.txt file
cmake_minimum_required(VERSION 3.3)
project(test4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES addon.cpp main.cpp myobject.cpp myobject.h)
add_executable(test4 ${SOURCE_FILES})
If you follow the README and use node-gyp with the -v flag, you can see that compilation looks like this:
g++ '-DNODE_GYP_MODULE_NAME=addon' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/home/yannick/.node-gyp/5.9.0/include/node -I/home/yannick/.node-gyp/5.9.0/src -I/home/yannick/.node-gyp/5.9.0/deps/uv/include -I/home/yannick/.node-gyp/5.9.0/deps/v8/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++0x -MMD -MF ./Release/.deps/Release/obj.target/addon/myobject.o.d.raw -c -o Release/obj.target/addon/myobject.o ../myobject.cc
So it's a tad more complex that just specifying a few sources : there are several include dirs to be used, that seems specific to the node version you are running, and include an external dependency (libuv)
Why don't you use the build methods suggested by the README ?

Unresolved symbols linking static libraries

I a m getting some undefined references with the linking of static and dynamic libraries.
My goal is to get an executable with poco and uiohook libraries statically linked. In order to specify the static linking, I provide the direct path to the library, some as path/libName.a.
The following command:
/home/lrleon/LLVM-3.7/bin/clang -o collector -g -O2 -fno-strict-aliasing \
collector.o common-vars.o collector-events.o listeners.o \
active_window.o ../lib/libperfq-common.a \
/home/lrleon/aleph-w/libAleph.a /home/lrleon/poco/lib/libPocoNet.a \
/home/lrleon/poco/lib/libPocoFoundation.a /home/lrleon/uiohook/lib/libuiohook.a \
-lstdc++ -lX11 -lcairo -lgsl -lgslcblas -lpthread -lc
Gives me the following errors:
/home/lrleon/poco/lib/libPocoFoundation.a(DateTime.o):DateTime.cpp:function Poco::DateTime::dayOfWeek() const: error: undefined reference to 'floor'
/home/lrleon/poco/lib/libPocoFoundation.a(DateTime.o):DateTime.cpp:function Poco::DateTime::toJulianDay(int, int, int, int, int, int, int, int): error: undefined reference to 'floor'
/home/lrleon/poco/lib/libPocoFoundation.a(DateTime.o):DateTime.cpp:function Poco::DateTime::toJulianDay(int, int, int, int, int, int, int, int): error: undefined reference to 'floor'
/home/lrleon/poco/lib/libPocoFoundation.a(DateTime.o):DateTime.cpp:function Poco::DateTime::toJulianDay(int, int, int, int, int, int, int, int): error: undefined reference to 'floor'
/home/lrleon/poco/lib/libPocoFoundation.a(NumericString.o):NumericString.cpp:function double_conversion::PowersOfTenCache::GetCachedPowerForBinaryExponentRange(int, int, double_conversion::DiyFp*, int*): error: undefined reference to 'ceil'
/home/lrleon/poco/lib/libPocoFoundation.a(NumericString.o):NumericString.cpp:function double_conversion::BignumDtoa(double, double_conversion::BignumDtoaMode, int, double_conversion::Vector<char>, int*, int*): error: undefined reference to 'ceil'
/home/lrleon/poco/lib/libPocoFoundation.a(NumericString.o):NumericString.cpp:function Poco::floatToStr(std::string&, float, int, int, char, char): error: undefined reference to 'floorf'
src/x11/input_hook.c:673: error: undefined reference to 'XRecordFreeData'
src/x11/input_hook.c:722: error: undefined reference to 'XRecordQueryVersion'
src/x11/input_hook.c:733: error: undefined reference to 'XRecordAllocRange'
src/x11/input_hook.c:745: error: undefined reference to 'XRecordCreateContext'
src/x11/input_hook.c:792: error: undefined reference to 'XRecordEnableContext'
src/x11/input_hook.c:812: error: undefined reference to 'XRecordFreeContext'
src/x11/input_hook.c:883: error: undefined reference to 'XRecordGetContext'
src/x11/input_hook.c:885: error: undefined reference to 'XRecordDisableContext'
src/x11/system_properties.c:134: error: undefined reference to 'XineramaIsActive'
src/x11/system_properties.c:136: error: undefined reference to 'XineramaQueryScreens'
src/x11/system_properties.c:396: error: undefined reference to 'XtGetMultiClickTime'
src/x11/system_properties.c:480: error: undefined reference to 'XtToolkitInitialize'
src/x11/system_properties.c:481: error: undefined reference to 'XtCreateApplicationContext'
src/x11/system_properties.c:485: error: undefined reference to 'XtOpenDisplay'
src/x11/system_properties.c:502: error: undefined reference to 'XtCloseDisplay'
src/x11/system_properties.c:503: error: undefined reference to 'XtDestroyApplicationContext'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I do not understand why some symbols are not found. For example, ceil, floor are referenced by poco libraries, but these symbols would belong to c standard library. As I understand, these symbols should be resoluble because the c library is linked just at the end; that is after the poco libraries. Analogously with the references to X11 symbols which I believe are referenced with libuiohook and the linking order -lX11 is given afterward
Any idea about what am I doing wrong? Thanks in advance
The floor and ceil functions are defined in the Math library and I don't see you linking with libm by using -lm flag

Compile error when linking against two libraries in C++

compile command:
g++ ast01.cpp -o ast01 -lglu -lglut
error:
/usr/bin/ld: error: cannot find -lglu
/tmp/ccjQZPPr.o:ast01.cpp:function displaySpiral(): error: undefined reference to 'glClear'
/tmp/ccjQZPPr.o:ast01.cpp:function displaySpiral(): error: undefined reference to 'glBegin'
/tmp/ccjQZPPr.o:ast01.cpp:function displaySpiral(): error: undefined reference to 'glColor3ub'
/tmp/ccjQZPPr.o:ast01.cpp:function displaySpiral(): error: undefined reference to 'glEnd'
/tmp/ccjQZPPr.o:ast01.cpp:function displaySpiral(): error: undefined reference to 'glFlush'
/tmp/ccjQZPPr.o:ast01.cpp:function openGLinit(int, char**): error: undefined reference to 'glClearColor'
/tmp/ccjQZPPr.o:ast01.cpp:function openGLinit(int, char**): error: undefined reference to 'glMatrixMode'
/tmp/ccjQZPPr.o:ast01.cpp:function openGLinit(int, char**): error: undefined reference to 'glLoadIdentity'
/tmp/ccjQZPPr.o:ast01.cpp:function openGLinit(int, char**): error: undefined reference to 'gluOrtho2D'
/tmp/ccjQZPPr.o:ast01.cpp:function openGLinit(int, char**): error: undefined reference to 'glMatrixMode'
collect2: ld returned 1 exit status

QVision and undefined reference to `vtable for QVCannyEdgeDetector'

I have compiled and installed QVision on Archlinux. The libraries I have choosed to be compiled with QVision were qwt,opencv and cgal.
Now I want to compile this code. But can't compile.
#include <QVApplication>
#include <QVVideoReaderBlock>
#include <QVImageCanvas>
#include <QVCannyEdgeDetector>
#include <QVDefaultGUI>
int main(int argc, char *argv[])
{
QVApplication app(argc, argv,
"Example program for QVision library. Obtains Canny borders from input video frames."
);
QVVideoReaderBlock videoReader("Video reader");
QVCannyEdgeDetector cannyBlock("Canny block");
QVImageCanvas imageDisplayer("Original image");
QVImageCanvas edgesDisplayer("Canny edges");
videoReader.linkProperty(&cannyBlock,"Input image");
cannyBlock.linkProperty("Input image",imageDisplayer);
cannyBlock.linkProperty("Output image",edgesDisplayer);
QVDefaultGUI defaultGUI;
return app.exec();
}
and this is the .pro file I have used for the qt project:
LIBS = -L /opt/QVision/lib/lib*
INCLUDEPATH = /opt/QVision/src
TARGET = canvasInteract
SOURCES += main.cpp
and these are the errors I get:
main.cpp:-1: error: undefined reference to `QVCannyEdgeDetector::QVCannyEdgeDetector(QString)'
main.cpp:-1: error: undefined reference to `vtable for QVCannyEdgeDetector'
main.cpp:-1: error: undefined reference to `vtable for QVCannyEdgeDetector'
main.cpp:-1: error: undefined reference to `vtable for QVCannyEdgeDetector'
main.cpp:-1: error: undefined reference to `vtable for QVCannyEdgeDetector'
main.cpp:-1: error: more undefined reference to `vtable for QVCannyEdgeDetector'
:-1: error: collect2: error: ld returned 1 exit status
How can I solve this problem?