Compile error when linking against two libraries in C++ - 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

Related

g++ not linking wayland methods

I was trying to create a Wayland window, and I keep getting these strange linkers errors.
Header:
#include <wayland-client.h>
#include <wayland-client-protocol.h>
#include <stdlib.h>
#include <stdio.h>
namespace dmaf
{
class WINDOW
{
private:
bool Init();
public:
void Run();
WINDOW();
~WINDOW();
};
WINDOW::WINDOW()
{
}
WINDOW::~WINDOW()
{
}
bool WINDOW::Init()
{
return 1;
}
void WINDOW::Run()
{
if (Init())
{
wl_display* display = wl_display_connect(0);
if (display)
printf("h\n");
else
printf("g\n");
if (!display)
return;
wl_display_disconnect(display);
}
}
}
Main:
#include "WAYDMAF.h"
using namespace dmaf;
int main()
{
WINDOW window;
window.Run();
}
Errors:
Package wayland-client-protocol was not found in the pkg-config search path.
Perhaps you should add the directory containing `wayland-client-protocol.pc'
to the PKG_CONFIG_PATH environment variable
No package 'wayland-client-protocol' found
/usr/bin/ld: /tmp/ccImUDBz.o: in function `dmaf::WINDOW::Run()':
dmaf_program.cxx:(.text+0x5a): undefined reference to `wl_display_connect'
/usr/bin/ld: dmaf_program.cxx:(.text+0x92): undefined reference to `wl_display_disconnect'
collect2: error: ld returned 1 exit status
Hello Wayland (more below)
#pop-os: gcc hello_wayland.c helpers.c helpers.h $(pkg-config --cflags --libs=lwayland-client) -o hello_wayland
Must specify package names on the command line
/usr/bin/ld: /tmp/ccx8fSIO.o: warning: relocation against `wl_surface_interface' in read-only section `.text'
/usr/bin/ld: /tmp/ccVVuR6n.o: in function `main':
hello_wayland.c:(.text+0xe4): undefined reference to `wl_display_dispatch'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_display_get_registry':
helpers.c:(.text+0x18): undefined reference to `wl_registry_interface'
/usr/bin/ld: helpers.c:(.text+0x2a): undefined reference to `wl_proxy_marshal_constructor'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_registry_add_listener':
helpers.c:(.text+0x5f): undefined reference to `wl_proxy_add_listener'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_registry_destroy':
helpers.c:(.text+0x79): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_registry_bind':
helpers.c:(.text+0xc5): undefined reference to `wl_proxy_marshal_constructor_versioned'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_compositor_destroy':
helpers.c:(.text+0xeb): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_compositor_create_surface':
helpers.c:(.text+0x10a): undefined reference to `wl_surface_interface'
/usr/bin/ld: helpers.c:(.text+0x11c): undefined reference to `wl_proxy_marshal_constructor'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shm_pool_set_user_data':
helpers.c:(.text+0x149): undefined reference to `wl_proxy_set_user_data'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shm_pool_get_user_data':
helpers.c:(.text+0x164): undefined reference to `wl_proxy_get_user_data'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shm_pool_create_buffer':
helpers.c:(.text+0x1af): undefined reference to `wl_buffer_interface'
/usr/bin/ld: helpers.c:(.text+0x1c1): undefined reference to `wl_proxy_marshal_constructor'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shm_pool_destroy':
helpers.c:(.text+0x1f1): undefined reference to `wl_proxy_marshal'
/usr/bin/ld: helpers.c:(.text+0x1fd): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shm_destroy':
helpers.c:(.text+0x218): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shm_create_pool':
helpers.c:(.text+0x249): undefined reference to `wl_shm_pool_interface'
/usr/bin/ld: helpers.c:(.text+0x25b): undefined reference to `wl_proxy_marshal_constructor'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_buffer_destroy':
helpers.c:(.text+0x287): undefined reference to `wl_proxy_marshal'
/usr/bin/ld: helpers.c:(.text+0x293): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shell_destroy':
helpers.c:(.text+0x2ae): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shell_get_shell_surface':
helpers.c:(.text+0x2d8): undefined reference to `wl_shell_surface_interface'
/usr/bin/ld: helpers.c:(.text+0x2ea): undefined reference to `wl_proxy_marshal_constructor'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shell_surface_add_listener':
helpers.c:(.text+0x31f): undefined reference to `wl_proxy_add_listener'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shell_surface_set_user_data':
helpers.c:(.text+0x344): undefined reference to `wl_proxy_set_user_data'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shell_surface_get_user_data':
helpers.c:(.text+0x35f): undefined reference to `wl_proxy_get_user_data'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shell_surface_destroy':
helpers.c:(.text+0x379): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shell_surface_pong':
helpers.c:(.text+0x3a4): undefined reference to `wl_proxy_marshal'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_shell_surface_set_toplevel':
helpers.c:(.text+0x3c9): undefined reference to `wl_proxy_marshal'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_surface_set_user_data':
helpers.c:(.text+0x3ef): undefined reference to `wl_proxy_set_user_data'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_surface_get_user_data':
helpers.c:(.text+0x40a): undefined reference to `wl_proxy_get_user_data'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_surface_destroy':
helpers.c:(.text+0x42e): undefined reference to `wl_proxy_marshal'
/usr/bin/ld: helpers.c:(.text+0x43a): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_surface_attach':
helpers.c:(.text+0x476): undefined reference to `wl_proxy_marshal'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_surface_commit':
helpers.c:(.text+0x49b): undefined reference to `wl_proxy_marshal'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_seat_destroy':
helpers.c:(.text+0x4b6): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_seat_get_pointer':
helpers.c:(.text+0x4d5): undefined reference to `wl_pointer_interface'
/usr/bin/ld: helpers.c:(.text+0x4e7): undefined reference to `wl_proxy_marshal_constructor'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_pointer_add_listener':
helpers.c:(.text+0x51c): undefined reference to `wl_proxy_add_listener'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_pointer_set_user_data':
helpers.c:(.text+0x541): undefined reference to `wl_proxy_set_user_data'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_pointer_get_user_data':
helpers.c:(.text+0x55c): undefined reference to `wl_proxy_get_user_data'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_pointer_destroy':
helpers.c:(.text+0x576): undefined reference to `wl_proxy_destroy'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `wl_pointer_set_cursor':
helpers.c:(.text+0x5bc): undefined reference to `wl_proxy_marshal'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `hello_setup_wayland':
helpers.c:(.text+0x5d5): undefined reference to `wl_display_connect'
/usr/bin/ld: helpers.c:(.text+0x638): undefined reference to `wl_display_roundtrip'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `hello_cleanup_wayland':
helpers.c:(.text+0x6a9): undefined reference to `wl_display_disconnect'
/usr/bin/ld: /tmp/ccx8fSIO.o: in function `registry_global':
helpers.c:(.text+0x6d2): undefined reference to `wl_compositor_interface'
/usr/bin/ld: helpers.c:(.text+0x704): undefined reference to `wl_compositor_interface'
/usr/bin/ld: helpers.c:(.text+0x71f): undefined reference to `wl_shm_interface'
/usr/bin/ld: helpers.c:(.text+0x74c): undefined reference to `wl_shm_interface'
/usr/bin/ld: helpers.c:(.text+0x767): undefined reference to `wl_shell_interface'
/usr/bin/ld: helpers.c:(.text+0x794): undefined reference to `wl_shell_interface'
/usr/bin/ld: helpers.c:(.text+0x7ac): undefined reference to `wl_seat_interface'
/usr/bin/ld: helpers.c:(.text+0x7de): undefined reference to `wl_seat_interface'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
^there may be some errors as I didn't try to add all necessary headers^
I've tried a few g++ settings, but nothing.
g++:
g++ program.cxx $(pkg-config --cflags wayland-client-protocol) -o program
g++ program.cxx $(pkg-config --cflags wayland-client) -o program
usr/include:
wayland-egl
wayland-server-protocol
wayland-client
wayland-server-core
wayland-util
wayland-version
wayland-egl-core
wayland-cursor
wayland-client-protocol
wayland-server
wayland-client-core
I've also tried compiling Hello-Wayland, but I got a mountain of the same errors. I'm using Pop!_os, and I don't remember having any problems with X when I was on Ubuntu (Haven't tried X on Pop,and I don't remember using Wayland on Ubuntu).
It seems to only do this to wl_display_connect, wl_display_disconnect, and wl_display_connect_to_fd, so I checked in all of my header files and none of them had wl_display_connect (didn't try the other methods). Is it possible I need some other header files? If so, what do I need?
-Thanks del
Just a small syntax error in your original g++ command:
pkg-config --cflags --libs=lwayland-client
> pkgconf: option doesn't take an argument -- libs
The correct syntax is the following:
pkg-config --cflags --libs wayland-client
> -lwayland-client
A simple g++ command to compile a file and link against libwayland-client.so would therefore be:
g++ waylandapp.c $(pkg-config --cflags --libs wayland-client) -o waylandapp
which will actually turn into
g++ waylandapp.c -lwayland-client -o waylandapp
-l is a universal c/c++ linker flag, for linking libraries.
To learn more about how to use pkg-config, man pkgconf will help.

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).

Simple linking test to MKL libraries fails

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

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 ?

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?