Introduction
I am trying to connect and interact with a mysql db running on my local, in a c++ project. I am also using cmake to compile my project.
Preparation
I installed mysqlconnector cpp by using mysql-connector-odbc-8.0.25-macos11-x86-64bit.dmg from their community downloads. I have the include and lib files available at /usr/local/mysql-connector-c+
CmakeLists.txt
Part of my CMakeLists.txt which deals with mysqlconnector is referenced below:
cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 11)
set(FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR "/usr/local/mysql-connector-c++")
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include)
link_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/lib64)
add_executable(runservice main.cpp)
target_link_libraries(runservice mysqlcppconn)
The cmake command runs fine.
Build Error
When I try to build using '''make``` command, I get the following error :
Undefined symbols for architecture x86_64:
"mysqlx::abi2::r0::common::Value::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const", referenced from:
mysqlx::abi2::r0::Value::print(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const in main.cpp.o
construction vtable for mysqlx::abi2::r0::common::Value-in-mysqlx::abi2::r0::Value in main.cpp.o
"typeinfo for mysqlx::abi2::r0::common::Value", referenced from:
construction vtable for mysqlx::abi2::r0::common::Value-in-mysqlx::abi2::r0::Value in main.cpp.o
typeinfo for mysqlx::abi2::r0::Value in main.cpp.o
"vtable for mysqlx::abi2::r0::DbDoc", referenced from:
mysqlx::abi2::r0::Value::~Value() in main.cpp.o
__GLOBAL__sub_I_main.cpp in main.cpp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [runservice] Error 1
make[1]: *** [CMakeFiles/runservice.dir/all] Error 2
make: *** [all] Error 2
I can't understand this error or how to go about solving this.
Thank you for your precious time
I'm trying to use GRANSAC(Generic RANSAC) from this github repository. https://github.com/drsrinathsridhar/GRANSAC
When I build with cmake, this error happens and I don't know how to solve it.
Undefined symbols for architecture x86_64: "_omp_get_max_threads",
referenced from:
GRANSAC::RANSAC::Estimate(std::__1::vector,
std::__1::allocator >
const&) in LineFittingSample.cpp.o
GRANSAC::RANSAC::RANSAC() in LineFittingSample.cpp.o "_omp_get_thread_num", referenced from:
GRANSAC::RANSAC::Estimate(std::__1::vector,
std::__1::allocator >
const&) in LineFittingSample.cpp.o "_omp_set_dynamic", referenced from:
GRANSAC::RANSAC::Estimate(std::__1::vector,
std::__1::allocator >
const&) in LineFittingSample.cpp.o "_omp_set_num_threads", referenced from:
GRANSAC::RANSAC::Estimate(std::__1::vector,
std::__1::allocator >
const&) in LineFittingSample.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code
1 (use -v to see invocation) make[2]: * [LineFittingSample] Error 1
make[1]: * [CMakeFiles/LineFittingSample.dir/all] Error 2 make: ***
[all]
Error 2
Environment: MacOS Mojave ver 10.14.16
I am trying to create a simple Fix client-server using QuickFix and I have tried to implement QuickFix.Application interface.
During the building I have faced this problem : "Undefined symbols for architecture x86_64" and despite I have already read all the relative answers to this question and trying everything suggested I have still the above issue.
I am using Netbeans and C++, and this is the error I got
g++ -o dist/Debug/GNU-MacOSX/fix_engine_server build/Debug/GNU-MacOSX/Application.o build/Debug/GNU-MacOSX/main.o -lstdc++
Undefined symbols for architecture x86_64:
"FIX::Message::toString(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, int, int, int) const", referenced from:
FIX::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, FIX::Message const&) in Application.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dist/Debug/GNU-MacOSX/fix_engine_server] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
On Netbeans->preferences->C/C++->C++_Compiler : /usr/bin/g++
On Property->Linker->Additional_Options : -lstdc++
On Property->Linker->Tool : g++
Any suggestion ?
Subtitle: Undefined symbols for architecture x86_64: Building OpenCV and dlib with SCons on Mac OSX El Captain x86_64
I've been trying to make my app build in cross platform.
I have an SCons script that currently builds fine on windows, but it fails to build so in Mac.
I believe it is caused by some clashes with newer versions of XCode, because some of the previous versions of my code and scons worked nicely (before being refactored).
The following is the error message, and I believe it is quite common, but I seem to fail to find a way to remedy it.
In OpenCV2-highgui, cap_avfoundation.mm
Undefined symbols for architecture x86_64:
"_AVCaptureSessionPresetMedium", referenced from:
CvCaptureCAM::startCaptureDevice(int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeAppleM4V", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeMPEG4", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVFileTypeQuickTimeMovie", referenced from:
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
"_AVMediaTypeVideo", referenced from:
CvCaptureCAM::startCaptureDevice(int) in libOpencvHighgui.a(cap_avfoundation.o)
CvCaptureFile::CvCaptureFile(char const*) in libOpencvHighgui.a(cap_avfoundation.o)
CvVideoWriter_AVFoundation::CvVideoWriter_AVFoundation(char const*, int, double, CvSize, int) in libOpencvHighgui.a(cap_avfoundation.o)
...
...
...
In OpenCV2-highgui, window_cocoa.mm
"_OBJC_CLASS_$_NSSlider", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSString", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
objc-class-ref in libOpencvHighgui.a(cap_avfoundation.o)
"_OBJC_CLASS_$_NSTextField", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSThread", referenced from:
objc-class-ref in libOpencvHighgui.a(window_cocoa.o)
"_OBJC_CLASS_$_NSURL", referenced from:
...
...
...
In addition to building OpenCV, same error occurred in dlib_18_14, source.cpp
"_XAllocColor", referenced from:
void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libThirdPartyDlib_18_14.a(source.o)
"_XAllocSizeHints", referenced from:
dlib::base_window::set_size(int, int) in libThirdPartyDlib_18_14.a(source.o)
dlib::base_window::base_window(bool, bool) in libThirdPartyDlib_18_14.a(source.o)
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XChangeProperty", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XCheckIfEvent", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::event_handler() in libThirdPartyDlib_18_14.a(source.o)
"_XClearArea", referenced from:
dlib::base_window::invalidate_rectangle(dlib::rectangle const&) in libThirdPartyDlib_18_14.a(source.o)
"_XCloseDisplay", referenced from:
nativefont::font_renderer::font_renderer::vals_internal::~vals_internal() in libThirdPartyDlib_18_14.a(source.o)
dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libThirdPartyDlib_18_14.a(source.o)
"_XCloseIM", referenced from:
dlib::gui_core_kernel_2_globals::event_handler_thread::~event_handler_thread() in libThirdPartyDlib_18_14.a(source.o)
"_XConvertSelection", referenced from:
dlib::get_from_clipboard(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) in libThirdPartyDlib_18_14.a(source.o)
"_XCreateFontSet", referenced from:
dlib::base_window::base_window(bool, bool) in libThirdPartyDlib_18_14.a(source.o)
void nativefont::font_renderer::font_renderer::vals_internal::create<unsigned int>(unsigned int*, int, bool, bool, bool, nativefont::font_renderer::font_renderer::rgb_type, nativefont::font_renderer::font_renderer::rgb_type) in libThirdPartyDlib_18_14.a(source.o)
...
...
...
And the error is summed up as the following:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [out/darwin/x86_64/release/1.0.0/bin/libAPI3dfi_api_v1.dylib] Error 1
scons: building terminated because of errors.
I cannot expose the entire source code nor the scons build scripts here, so please mind that.
This is the sample snippet of how my scons script looks like to build a shared library (building static libraries are having no problems, just the shared libs):
Import('env')
# Add third party libraries
lib_env = env.Clone()
module_lib_env = lib_env.Clone()
target_os = env.get('TARGET_OS')
target_arch = env.get('TARGET_ARCH')
######################################################################
# Runtime Dependencies
######################################################################
pthread_path = env.get('PTHREAD_PATH') + '/lib'
intraface_path = env.get('INTRAFACE_PATH') + '/lib'
######################################################################
# General flags
######################################################################
module_lib_env.AppendUnique(CPPPATH = ['inc', 'src'])
######################################################################
# Libraries
######################################################################
module_lib_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')+'/bin',env.get('BUILD_DIR')+'/lib', pthread_path, intraface_path])
if target_os == 'windows':
module_lib_env.AppendUnique(LIBS = [
'libOpencvCore',
'libOpencvHighgui',
'libOpencvImgproc',
'libOpencvObjdetect',
'libOpencvFlann',
'libOpencvFeature2d',
'libOpencvVideo',
'libOpencvCalib3d',
'libOpencvMl',
'libFreeimage',
'libFreeimageOpenEXR',
'libFreeimageLibTIFF',
#'libFreeimageLibRawLite',
'libFreeimageLibPNG',
'libFreeimageLibOpenJPEG',
'libFreeimageLibJPEG',
'libFreeimageLibMNG',
'libFreeimageZLib',
'libThirdPartyDlib_18_14',
'pthread',
'IntraFaceDLL'])
else:
module_lib_env.AppendUnique(LIBS = [
'libOpencvCore',
'libOpencvHighgui',
'libOpencvImgproc',
'libOpencvObjdetect',
'libOpencvFlann',
'libOpencvFeature2d',
'libOpencvVideo',
'libOpencvCalib3d',
'libOpencvMl',
'libFreeimage',
'libFreeimageOpenEXR',
'libFreeimageLibTIFF',
#'libFreeimageLibRawLite',
'libFreeimageLibPNG',
'libFreeimageLibOpenJPEG',
'libFreeimageLibJPEG',
'libFreeimageLibMNG',
'libFreeimageZLib',
'libThirdPartyDlib_18_14',
'pthread'
# ,'IntraFaceDLL'
])
######################################################################
# Preprocessor flags
######################################################################
if not target_os == 'windows':
#allow error to be concidered as warning
module_lib_env.AppendUnique(CCFLAGS = ['-fpermissive'])
#disable warning
module_lib_env.AppendUnique(CCFLAGS = ['-Wno-sign-compare'])
module_lib_env.AppendUnique(CCFLAGS = ['-Wno-write-strings'])
module_lib_env.AppendUnique(CCFLAGS = ['-Wno-unused-variable'])
if target_os in ['darwin', 'ios']:
module_lib_env.AppendUnique(CPPDEFINES = ['_LIBCPP_HAS_NO_VARIADICS'])
######################################################################
# Source files and Targets
######################################################################
lib_src = env.Glob('src/*.cpp')
######################################################################
# Targets
######################################################################
module_lib_env.InstallTargetShared('libOpenCV', lib_src )
Here is the Full error log.
Here is how InstallTargetShared looks like:
def __install_shared(ienv, name, srcs):
ienv.SharedLibrary(target = os.path.join(env.get('BUILD_DIR') +'/bin/', name), source = srcs)
env.AppendUnique(TS = [name])
env.AddMethod(__install_shared, 'InstallTargetShared')
Any help or advices of what to do in this matter will be much appreciated!!
Looking at your full build log, I think you need to link against several OSX frameworks to resolve your issues. I don't see any in your linking command line:
g++ -o out/darwin/x86_64/release/1.0.0/bin/libAPI3dfi_api_v1.dylib -ldl -lpthread -mmacosx-version-min=10.11 -DWITH_OPENEXR=OFF -dynamiclib out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Api.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Manager.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Params.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_App_Retry.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Device_Heartbeat.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Device_Init.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Frame_Stats.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Manager.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_Assign.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_End.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/NV3DFI_Event_Session_Start.os out/darwin/x86_64/release/1.0.0/src/api/3dfi_api_v1/src/SHA1Hash.os -L/usr/local/lib -L/opt/local/lib -Ldeps/darwin/lib/x86_64 -Lout/darwin/x86_64/release/1.0.0 -L. -Lout/darwin/x86_64/release/1.0.0/bin -Lbin -Lout/darwin/x86_64/release/1.0.0/lib -Llib -L/Users/tllewellynn/Desktop/dev/build_scons/runtime/darwin/xcode/x86_64/pthread/lib -L/Users/tllewellynn/Desktop/dev/build_scons/runtime/darwin/xcode/x86_64/intraface/lib -lSDK3dfi_detect -lSDK3dfi_algo -lSDK3dfi_au -lSDK3dfi_align -lSDK3dfi_proc -lSDK3dfi_cluster -lSDK3dfi_attr -lSDK3dfi_type -lOpencvCore -lOpencvHighgui -lOpencvImgproc -lOpencvObjdetect -lOpencvFlann -lOpencvFeature2d -lOpencvVideo -lOpencvCalib3d -lOpencvMl -lFreeimage -lFreeimageOpenEXR -lFreeimageLibTIFF -lFreeimageLibPNG -lFreeimageLibOpenJPEG -lFreeimageLibJPEG -lFreeimageLibMNG -lFreeimageZLib -lFrameworkNvaam_base -lFrameworkNvaam_filter -lFrameworkNvaam -lFrameworkProtobuf -lFrameworkLibbff -lFrameworkNvclassifier -lFrameworkNvexpression -lFrameworkTrimesh2 -lFrameworkPolyfit -lFrameworkGClasses -lFrameworkFlandmark -lFrameworkAlglib -lNetMsgpack -lNetJsoncpp -lNetTinyxml2 -lNetTinyxmlparam -lCnnEblearnTools -lCnnEblearnIdx -lCnnEblearn -lThirdPartyDlib_18_14 -lSystemTinycthread -lSystemTinythread -lSystemGlobal -lSystemDebug -lpthread -lTbb -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/
Have you asked on any openCV forums or IRC channels?
Looks like you're missing several key frameworks from your link line.
I've had issues in compiling DisplayImage.cpp, I've followed the tutorial here and to create a cmake file and generate executables, however, when I was compiling the problem with make it displays the following errors:
Undefined symbols for architecture x86_64:
"cv::namedWindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
_main in DisplayImage.cpp.o
"cv::imread(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from:
_main in DisplayImage.cpp.o
"cv::imshow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cv::_InputArray const&)", referenced from:
_main in DisplayImage.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [DisplayImage] Error 1
make[1]: *** [CMakeFiles/DisplayImage.dir/all] Error 2
make: *** [all] Error 2
I am running MacOS could anyone please help!
Thanks
Try adding
#include <opencv2/highgui/highgui_c.h>
to the top of DisplayImage.cpp code. Then compile and execute again.
Hope it works! I just tried and verified it myself now.