I'm having trouble integrating protobuf (3.20.4) into UE4 as a static library and packaging for linux.
The packaging fails with these errors :
undefined symbol: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::resize(unsigned long, char)
Error PackagingResults undefined symbol: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve(unsigned long)
Error PackagingResults undefined symbol: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)
I'm assuming it's because I compiled them against libstdc++ rather than libc++ but I can't work out how to compile them using cmake with libc++.
Related
I'm trying to compile a machine learning code written in c++ and connecting it to NodeJS using n-api, I have written the NAPI function in one of the files, and defined additional dependencies in CMake.
Installed
'node-addon-api': '^3.0.0'
'cmake-js':'^6.1.0'
error
> cmake-js compile
[
'/usr/bin/node',
'/home/nishant/Documents/demo/node_modules/.bin/cmake-js',
'compile'
]
info TOOL Using Unix Makefiles generator.
info CMD BUILD
info RUN cmake --build "/home/nishant/Documents/demo/build" --config Release
Consolidate compiler generated dependencies of target mobilenetknn
[ 60%] Built target mobilenetknn
Consolidate compiler generated dependencies of target program
[ 80%] Linking CXX executable program
CMakeFiles/program.dir/src/program.cpp.o: In function `Init(Napi::Env, Napi::Object)':
program.cpp:(.text+0x6b): undefined reference to `napi_create_function'
program.cpp:(.text+0xb8): undefined reference to `napi_create_symbol'
program.cpp:(.text+0xd3): undefined reference to `napi_create_external'
program.cpp:(.text+0x10f): undefined reference to `napi_define_properties'
program.cpp:(.text+0x133): undefined reference to `napi_create_string_utf8'
program.cpp:(.text+0x14a): undefined reference to `napi_set_property'
CMakeFiles/program.dir/src/program.cpp.o: In function `classAddTrainModel(Napi::CallbackInfo const&)':
program.cpp:(.text+0x268): undefined reference to `napi_coerce_to_number'
program.cpp:(.text+0x287): undefined reference to `napi_get_value_int32'
program.cpp:(.text+0x33a): undefined reference to `napi_get_element'
program.cpp:(.text+0x35d): undefined reference to `napi_get_element'
program.cpp:(.text+0x380): undefined reference to `napi_get_value_string_utf8'
program.cpp:(.text+0x3f7): undefined reference to `napi_get_value_string_utf8'
program.cpp:(.text+0x415): undefined reference to `napi_get_value_string_utf8'
program.cpp:(.text+0x48c): undefined reference to `napi_get_value_string_utf8'
program.cpp:(.text+0x8b8): undefined reference to `napi_create_double'
program.cpp:(.text+0xb55): undefined reference to `napi_get_undefined'
program.cpp:(.text+0xb7e): undefined reference to `napi_get_undefined'
program.cpp:(.text+0xbae): undefined reference to `napi_get_undefined'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::Error::~Error()':
program.cpp:(.text._ZN4Napi5ErrorD2Ev[_ZN4Napi5ErrorD5Ev]+0x46): undefined reference to `napi_delete_reference'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::AsyncContext::~AsyncContext()':
program.cpp:(.text._ZN4Napi12AsyncContextD2Ev[_ZN4Napi12AsyncContextD5Ev]+0x15): undefined reference to `napi_async_destroy'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::AsyncContext::~AsyncContext()':
program.cpp:(.text._ZN4Napi12AsyncContextD0Ev[_ZN4Napi12AsyncContextD5Ev]+0x19): undefined reference to `napi_async_destroy'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::Error::~Error()':
program.cpp:(.text._ZN4Napi5ErrorD0Ev[_ZN4Napi5ErrorD5Ev]+0x39): undefined reference to `napi_delete_reference'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::Error::Fatal(char const*, char const*)':
program.cpp:(.text._ZN4Napi5Error5FatalEPKcS2_[_ZN4Napi5Error5FatalEPKcS2_]+0x12): undefined reference to `napi_fatal_error'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::CallbackScope::~CallbackScope()':
program.cpp:(.text._ZN4Napi13CallbackScopeD2Ev[_ZN4Napi13CallbackScopeD5Ev]+0x14): undefined reference to `napi_close_callback_scope'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::CallbackScope::~CallbackScope()':
program.cpp:(.text._ZN4Napi13CallbackScopeD0Ev[_ZN4Napi13CallbackScopeD5Ev]+0x14): undefined reference to `napi_close_callback_scope'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::Error::New(napi_env__*)':
program.cpp:(.text._ZN4Napi5Error3NewEP10napi_env__[_ZN4Napi5Error3NewEP10napi_env__]+0x30): undefined reference to `napi_get_last_error_info'
program.cpp:(.text._ZN4Napi5Error3NewEP10napi_env__[_ZN4Napi5Error3NewEP10napi_env__]+0x45): undefined reference to `napi_is_exception_pending'
program.cpp:(.text._ZN4Napi5Error3NewEP10napi_env__[_ZN4Napi5Error3NewEP10napi_env__]+0x84): undefined reference to `napi_create_string_utf8'
program.cpp:(.text._ZN4Napi5Error3NewEP10napi_env__[_ZN4Napi5Error3NewEP10napi_env__]+0xbd): undefined reference to `napi_create_error'
program.cpp:(.text._ZN4Napi5Error3NewEP10napi_env__[_ZN4Napi5Error3NewEP10napi_env__]+0x10b): undefined reference to `napi_create_reference'
program.cpp:(.text._ZN4Napi5Error3NewEP10napi_env__[_ZN4Napi5Error3NewEP10napi_env__]+0x141): undefined reference to `napi_get_and_clear_last_exception'
program.cpp:(.text._ZN4Napi5Error3NewEP10napi_env__[_ZN4Napi5Error3NewEP10napi_env__]+0x170): undefined reference to `napi_create_type_error'
program.cpp:(.text._ZN4Napi5Error3NewEP10napi_env__[_ZN4Napi5Error3NewEP10napi_env__]+0x1ef): undefined reference to `napi_delete_reference'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::HandleScope::~HandleScope()':
program.cpp:(.text._ZN4Napi11HandleScopeD2Ev[_ZN4Napi11HandleScopeD5Ev]+0xc): undefined reference to `napi_close_handle_scope'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::Error::ThrowAsJavaScriptException() const':
program.cpp:(.text._ZNK4Napi5Error26ThrowAsJavaScriptExceptionEv[_ZNK4Napi5Error26ThrowAsJavaScriptExceptionEv]+0x28): undefined reference to `napi_open_handle_scope'
program.cpp:(.text._ZNK4Napi5Error26ThrowAsJavaScriptExceptionEv[_ZNK4Napi5Error26ThrowAsJavaScriptExceptionEv]+0x43): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZNK4Napi5Error26ThrowAsJavaScriptExceptionEv[_ZNK4Napi5Error26ThrowAsJavaScriptExceptionEv]+0x59): undefined reference to `napi_throw'
program.cpp:(.text._ZNK4Napi5Error26ThrowAsJavaScriptExceptionEv[_ZNK4Napi5Error26ThrowAsJavaScriptExceptionEv]+0x6c): undefined reference to `napi_close_handle_scope'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::details::CallbackData<Napi::Number (*)(Napi::CallbackInfo const&), Napi::Number>::Wrapper(napi_env__*, napi_callback_info__*)':
program.cpp:(.text._ZN4Napi7details12CallbackDataIPFNS_6NumberERKNS_12CallbackInfoEES2_E7WrapperEP10napi_env__P20napi_callback_info__[_ZN4Napi7details12CallbackDataIPFNS_6NumberERKNS_12CallbackInfoEES2_E7WrapperEP10napi_env__P20napi_callback_info__]+0x65): undefined reference to `napi_get_cb_info'
program.cpp:(.text._ZN4Napi7details12CallbackDataIPFNS_6NumberERKNS_12CallbackInfoEES2_E7WrapperEP10napi_env__P20napi_callback_info__[_ZN4Napi7details12CallbackDataIPFNS_6NumberERKNS_12CallbackInfoEES2_E7WrapperEP10napi_env__P20napi_callback_info__]+0xb7): undefined reference to `napi_get_cb_info'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::EscapableHandleScope::~EscapableHandleScope()':
program.cpp:(.text._ZN4Napi20EscapableHandleScopeD2Ev[_ZN4Napi20EscapableHandleScopeD5Ev]+0xc): undefined reference to `napi_close_escapable_handle_scope'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::AsyncWorker::OnError(Napi::Error const&)':
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0x46): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0x71): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0x90): undefined reference to `napi_open_escapable_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0xb3): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0xde): undefined reference to `napi_call_function'
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0xfa): undefined reference to `napi_is_exception_pending'
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0x11c): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0x163): undefined reference to `napi_escape_handle'
program.cpp:(.text._ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE[_ZN4Napi11AsyncWorker7OnErrorERKNS_5ErrorE]+0x17a): undefined reference to `napi_close_escapable_handle_scope'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::AsyncWorker::OnOK()':
program.cpp:(.text._ZN4Napi11AsyncWorker4OnOKEv[_ZN4Napi11AsyncWorker4OnOKEv]+0x6f): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker4OnOKEv[_ZN4Napi11AsyncWorker4OnOKEv]+0x93): undefined reference to `napi_open_escapable_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker4OnOKEv[_ZN4Napi11AsyncWorker4OnOKEv]+0xb6): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker4OnOKEv[_ZN4Napi11AsyncWorker4OnOKEv]+0xe8): undefined reference to `napi_call_function'
program.cpp:(.text._ZN4Napi11AsyncWorker4OnOKEv[_ZN4Napi11AsyncWorker4OnOKEv]+0x104): undefined reference to `napi_is_exception_pending'
program.cpp:(.text._ZN4Napi11AsyncWorker4OnOKEv[_ZN4Napi11AsyncWorker4OnOKEv]+0x126): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker4OnOKEv[_ZN4Napi11AsyncWorker4OnOKEv]+0x13d): undefined reference to `napi_close_escapable_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker4OnOKEv[_ZN4Napi11AsyncWorker4OnOKEv]+0x18b): undefined reference to `napi_escape_handle'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::Error::what() const':
program.cpp:(.text._ZNK4Napi5Error4whatEv[_ZNK4Napi5Error4whatEv]+0x42): undefined reference to `napi_open_escapable_handle_scope'
program.cpp:(.text._ZNK4Napi5Error4whatEv[_ZNK4Napi5Error4whatEv]+0x5f): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZNK4Napi5Error4whatEv[_ZNK4Napi5Error4whatEv]+0x81): undefined reference to `napi_get_named_property'
program.cpp:(.text._ZNK4Napi5Error4whatEv[_ZNK4Napi5Error4whatEv]+0xa2): undefined reference to `napi_escape_handle'
program.cpp:(.text._ZNK4Napi5Error4whatEv[_ZNK4Napi5Error4whatEv]+0xc1): undefined reference to `napi_close_escapable_handle_scope'
program.cpp:(.text._ZNK4Napi5Error4whatEv[_ZNK4Napi5Error4whatEv]+0xdd): undefined reference to `napi_get_value_string_utf8'
program.cpp:(.text._ZNK4Napi5Error4whatEv[_ZNK4Napi5Error4whatEv]+0x147): undefined reference to `napi_get_value_string_utf8'
CMakeFiles/program.dir/src/program.cpp.o: In function `Napi::AsyncWorker::OnWorkComplete(Napi::Env, napi_status)':
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x3b): undefined reference to `napi_open_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x6c): undefined reference to `napi_create_string_utf8'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x88): undefined reference to `napi_create_error'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0xff): undefined reference to `napi_create_reference'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x142): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x172): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x19c): undefined reference to `napi_open_escapable_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x1bf): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x1ed): undefined reference to `napi_call_function'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x20c): undefined reference to `napi_is_exception_pending'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x231): undefined reference to `napi_escape_handle'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x24e): undefined reference to `napi_close_escapable_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x2b3): undefined reference to `napi_close_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x377): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x3a1): undefined reference to `napi_open_escapable_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x3c4): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x3fc): undefined reference to `napi_call_function'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x41b): undefined reference to `napi_is_exception_pending'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x440): undefined reference to `napi_escape_handle'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x45d): undefined reference to `napi_close_escapable_handle_scope'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x491): undefined reference to `napi_delete_reference'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x4c2): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x532): undefined reference to `napi_get_reference_value'
program.cpp:(.text._ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status[_ZN4Napi11AsyncWorker14OnWorkCompleteENS_3EnvE11napi_status]+0x778): undefined reference to `napi_delete_reference'
CMakeFiles/program.dir/src/program.cpp.o: In function `_register_mobilenetknn':
program.cpp:(.text.startup+0x6): undefined reference to `napi_module_register'
collect2: error: ld returned 1 exit status
CMakeFiles/program.dir/build.make:161: recipe for target 'program' failed
make[2]: *** [program] Error 1
CMakeFiles/Makefile2:110: recipe for target 'CMakeFiles/program.dir/all' failed
make[1]: *** [CMakeFiles/program.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
ERR! OMG Process terminated: 2
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! demo#1.0.0 install: `cmake-js compile`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the demo#1.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/nishant/.npm/_logs/2021-05-25T19_38_32_738Z-debug.log
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(mobilenetknn)
set(CMAKE_CXX_STANDARD 11)
SET(Caffe_DIR /home/nishant/caffe/distribute)
include_directories(${CMAKE_JS_INC})
include_directories(${Caffe_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/node_modules/node-addon-api)
file(GLOB_RECURSE SOURCE_O ${CMAKE_CURRENT_SOURCE_DIR}/lib/*.o GLOB SOURCE_FILES "src/*.cpp" "src/*.hpp")
# file(GLOB SOURCE_FILES "src/*.cpp" "src/*.hpp")
add_library(${PROJECT_NAME}
STATIC ${SRC}
${SOURCE_O} ${CMAKE_JS_SRC})
# add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
# add_library(SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
add_definitions(-DCPU_ONLY)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_JS_LIB} ${Caffe_DIR}/lib/libcaffe.a)
SET(EXAMPLES
program
)
# License source files
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
find_package( OpenCV REQUIRED)
set(CMAKE_BUILD_TYPE release)
set(CMAKE_CXX_STANDARD 11)
add_definitions(-DCPU_ONLY)
find_package(HDF5 COMPONENTS HL REQUIRED)
include_directories(SYSTEM ${HDF5_INCLUDE_DIRS} ${HDF5_HL_INCLUDE_DIR})
list(APPEND Caffe_LINKER_LIBS ${HDF5_LIBRARIES})
list(APPEND Caffe_LINKER_LIBS ${HDF5_HL_LIBRARIES})
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR} ${CAMKE_JS_INC})
# target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/node_modules/node-addon-api")
# target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_JS_LIB})
add_definitions(-DNAPI_VERSION=3)
include_directories(${OpenCV_DIR}/include)
foreach (example ${EXAMPLES})
add_executable(${example} src/${example}.cpp)
TARGET_LINK_LIBRARIES(${example} ${OpenCV_LIBS} ${CMAKE_CURRENT_LIST_DIR}/build/libmobilenetknn.a ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} -lopenblas -lprotobuf -lboost_system -lglog -lgflags -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_imgcodecs -lopencv_videoio -lboost_system -lboost_regex -lboost_filesystem -lboost_thread -lboost_log)
endforeach()
main file(program.cpp)
I commented some of the functions, the same problem was with other functions also.
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/ml.hpp>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
// #include "napi.h"
#include <napi.h>
// #include <node_modules/node-addon-api/napi.h>
using namespace std;
using namespace cv;
using namespace cv::ml;
// using namespace Napi;
struct classInfo{
int classid;
std::string classname;
std::string imageset_location;
};
class Classify{ // declaration of class classify
public:
Classify(); //constructor
~Classify(); //destructor
std::vector<classInfo>cls;
int counter=0;
Ptr<KNearest> trainedModel;
std::string infer(std::string data_path);
void loadModel(string knn_path="train.knn");
std::string exportTrainedModel();
void trainModel(vector<classInfo>cls);
void listClasses(vector<classInfo>n);
vector<classInfo> addClass(std::string classname, std::string imageset_location);
};
Classify ic;
Napi::Number classAddTrainModel(const Napi::CallbackInfo& info){
Napi::Env env = info.Env();
// number of classes
int n = info[0].ToNumber();
Napi::Array classn = info[1].As<Napi::Array>();
Napi::Array iloc = info[2].As<Napi::Array>();
vector<classInfo> classinfo;
for(int i = 0; i < n; i++){
Napi::Value x = classn[i];
Napi::Value y = iloc[i];
string className = (string)x.As<Napi::String>();
string loc = (string)y.As<Napi::String>();
// cout << className << endl << loc << endl;
classinfo = ic.addClass(className, loc);
}
// Train Model
ic.trainModel(classinfo);
return Napi::Number::New(env, 1);
}
// Napi::String modelExport(const Napi::CallbackInfo& info){
// Napi::Env env = info.Env();
// std::string path = ic.exportTrainedModel();
// return Napi::String::New(env, ic.exportTrainedModel());
// }
// Napi::String modelLoad(const Napi::CallbackInfo& info){
// Napi::Env env = info.Env();
// std::string modelPath = info[0].ToString();
// std::string imgPath = info[1].ToString();
// ic.loadModel(modelPath);
// std::string label = ic.infer(imgPath);
// return Napi::String::New(env, label);
// }
Napi::Object Init(Napi::Env env, Napi::Object exports){
// set a key on exports object
exports.Set(
Napi::String::New(env, "classAddTrainModel"),
Napi::Function::New(env, classAddTrainModel)
);
// exports.Set(
// Napi::String::New(env, "modelExport"),
// Napi::Function::New(env, modelExport)
// );
// exports.Set(
// Napi::String::New(env, "modelLoad"),
// Napi::Function::New(env, modelLoad)
// );
// return 'exports' object (always)
return exports;
}
// register 'greet' module which calls Init method
NODE_API_MODULE(mobilenetknn, Init);
int main(){
return 0;
}
I have one static library, when I'm trying to create object of class from the static library in servicemain I'm getting crash on service startup.
When I disable the call static library classes, Service works fine.
I'm using Poco library for Service Handler, in crash dump we get callstack of Poco library only and not a single trace of our static library so not able to find out the root cause. Code is working fine on Ubuntu 16 and 14.
Below is the stack trace.
#0 __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007f799927f801 in __GI_abort () at abort.c:79
#2 0x00007f799e7cc755 in Poco::SignalHandler::handleSignal(int) ()
from /lib/libPocoFoundation.so.60
#3 <signal handler called>
#4 0x00007f799bb09b40 in std::string::clear() () from /lib/libstdc++.so.6
#5 0x0000563554610794 in Poco::Path::clear (this=0x7fffabfdd3e0) at src/Path.cpp:597
#6 0x00007f799e7bc5e1 in Poco::Path::parseUnix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /lib/libPocoFoundation.so.60
#7 0x00007f799e7bc889 in Poco::Path::assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /lib/libPocoFoundation.so.60
#8 0x00007f799e7bc916 in Poco::Path::Path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /lib/libPocoFoundation.so.60
#9 0x00007f799e483e56 in Poco::Util::Application::getApplicationPath(Poco::Path&) const ()
from /lib/libPocoUtil.so.60
#10 0x00007f799e48565c in Poco::Util::Application::init() () from /lib/libPocoUtil.so.60
#11 0x00007f799e49708c in Poco::Util::ServerApplication::run(int, char**) ()
from /lib/libPocoUtil.so.60
#12 0x0000563554107544 in main (argc=2, argv=0x7fffabfdd958) at ../../../src/servicemain/main.cpp:22
(gdb)
Please suggest.
not a single trace of our static library
Your stack trace is suspicious: why does (almost) every frame except frame #5 come from /lib/libPocoUtil.so.60, while frame #5 comes from src/Path.cpp:597 compiled into the main executable?
I suspect that your static library for some reason provides a definition of Poco::Path::clear(), and that definition:
Is incompatible with libPocoUtil.so.60 and
Wins over the definition provided in libPocoUtil.so.60.
You'll need to figure out how src/Path.cpp ended up in your binary, and removing that will fix your crash.
Update:
There are references of Path.hpp of boost in my static library. Could that be reason ?
There could be any number of reasons. You need to investigate why src/Path.cpp is linked into the main executable (is it your code, or is it part of Poco?), and why it defines the Poco::Path::clear() method.
For a start, edit your question and show code around line 597 in src/Path.cpp.
I tried to compile "controllgallery2.nim" , but ..
Error: execution of an external compiler program 'gcc.exe -c -w -mno-ms-bitfields -IC:\Users(User name)\Documents\Language\Nim\nim-0.18.0\lib -o G:\Nim \nimcache\win_debug.cpp.obj C:\Users(User name).nimble\pkgs\ui-0.9.2\ui./libui/windows\debug.cpp' failed with exit code: 1 C:\Users\terur.nimble\pkgs\ui-0.9.2\ui./libui/windows\debug.cpp: In function 'void realbug(const char*, const char*, const char*, const char*, con st char*, va_list)': C:\Users(User name).nimble\pkgs\ui-0.9.2\ui./libui/windows\debug.cpp:76:31: error: 'vsprintf_s' was not declared in this scope vsprintf_s(msg, n, format, ap); ^
What I should do to fix that error?
I am trying to execute the following script:
import Foundation
class TestURLSession{
var session: NSURLSession!
func run(){
session = NSURLSession.sharedSession()
let url = NSURL(string: "http://www.veenex.de/tmp/json")
let request = NSMutableURLRequest(URL: url!)
request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.HTTPMethod = "GET"
let getDataTask = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in
// HTTP Response contains an error
if let httpResponse = response as? NSHTTPURLResponse {
if httpResponse.statusCode != 200 {
print("response was not 200: \(response)")
return
}
}
// Error submitting Request
if error != nil {
print("error submitting request: \(error)")
return
}
// print data
if data != nil{
do {
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSArray
for entry in json {
print(entry)
}
} catch {
print("Error printing data")
}
}
});
getDataTask.resume()
}
}
let testURLSession = TestURLSession()
testURLSession.run()
But I receive the error message: "Error running code: unknown error code 132.".
Executing the code in the Xcode Playground it works.
A pure Swift implementation of NSURLSession has not been written yet. Check out the NSURLSession.swift file on Apple's GitHub repo for Foundation.
Every method is NSUnimplemented(), which means, well, it hasn't been implemented yet. Until this class is finished, it will not be available for use on Linux and IBM's Swift Sandbox.
I dug into the error and this is the message that wasn't being sent for some reason:
fatal error: sharedSession() is not yet implemented: file Foundation/NSURLSession.swift, line 87
0 swift 0x0000000002f4abf8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x0000000002f493f6 llvm::sys::RunSignalHandlers() + 54
2 swift 0x0000000002f4b726
3 libpthread.so.0 0x00007fd9dae43d10
4 libswiftCore.so 0x00007fd9d0e5eac3 _TTSf4s_s_s_n___TFs16_assertionFailedFTVs12StaticStringSSS_Su_T_ + 147
5 libFoundation.so 0x00007fd9d3a5c21f
6 libFoundation.so 0x00007fd9d3b178de
7 libFoundation.so 0x00007fd9dbce10c7
8 libFoundation.so 0x00007fd9dbce1079
9 swift 0x0000000000d0da24 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 996
10 swift 0x0000000000d1102f llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) + 1263
11 swift 0x0000000000bebdf8 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) + 2312
12 swift 0x000000000076656e
13 swift 0x0000000000761dfe frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2590
14 swift 0x000000000075d513 main + 2835
15 libc.so.6 0x00007fd9da1e8a40 __libc_start_main + 240
16 swift 0x000000000075c8f9 _start + 41
Stack dump:
0. Program arguments: /usr/bin/swift -frontend -interpret /swift-execution/code-tmp.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -lFoundation -lETSocket
/usr/bin/doit.sh: line 19: 10 Illegal instruction timeout 5 swift -lFoundation -lETSocket -v /swift-execution/$fileroot
So yea, we have something that's not yet implemented in Swift. I will improve the error messaging in our next patch to the Sandbox.
The program crashes before main. Heres the gdb output
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff3732abb in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) () from /opt/example/libstdc++.so.6
Missing separate debuginfos, use: debuginfo-install LynxService-0.10-10.x86_64 LynxService-0.6-6.x86_64 glibc-2.17-55.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.11.3-49.el7.x86_64 libcom_err-1.42.9-4.el7.x86_64 libselinux-2.2.2-6.el7.x86_64 pcre-8.32-12.el7.x86_64 xz-libs-5.1.2-8alpha.el7.x86_64 zlib-1.2.7-13.el7.x86_64
(gdb) bt
#0 0x00007ffff3732abb in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) () from /opt/example/libstdc++.so.6
#1 0x00007ffff4214f15 in ?? () from /opt/example/libNetwork.so
#2 0x00007ffff4215ef4 in ?? () from /opt/example/libNetwork.so
#3 0x00007ffff7deb503 in ?? () from /opt/example/ld-linux-x86-64.so.2
#4 0x00007ffff7ddd45a in ?? () from /opt/example/ld-linux-x86-64.so.2
#5 0x0000000000000001 in ?? ()
#6 0x00007fffffffe139 in ?? ()
#7 0x0000000000000000 in ?? ()
On multiple instance of gdb invocation the address of the stack frames (i.e 0x00007ffff4215ef4) remains same.
The output of ** objdump -TC libNetwork.so** does not contain text 0x00007ffff4215ef4.
The program has linked to many dependencies and it is very hard to remove the library linking one by one and test it.
Since the stack frame address is same always, it looks like this should be debuggable, but does not know how.