PCL & VTK Object File Errors - c++

I'm using a CamBoard Nano and Point Cloud Library in a C++ program. It uses a couple other libraries and one main C++ function as of right now. Someone else wrote the code for Windows, and I'm porting it over to Linux (Ubuntu 12.04). I've been able to get the C++ file to compile with a Makefile, but now I'm getting a ton of errors from the object file. I'm new to C++, and I don't understand what they all mean. It looks like they all stem from the same issue, hopefully one change will fix everything.
I was able to work out the errors in the C++ file by installing some Libraries (PCL, VTK, Eigen, OpenNI, etc.). I'll post what I can of the errors below, they fill up more than the entire terminal. I did look around on Google, and I found this: Qt 4.7 + VTK 5.6.1 on Mac OS X 10.6: errors linking projects
I downloaded QT 5.3, but when I use cmake on the example program I get the following error:
-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:20 (message):
VTK was not built with Qt
-- Configuring incomplete, errors occurred!
I'm trying to fix this now. I'll post my Makefile and errors below, so if anyone knows how to fix this or has advice, please let me know. Thanks!
Makefile:
CC = g++-4.4
CFLAGS = -I ../include -I ~/../../usr/include/pcl-1.7/ -I ~/../../usr/include/eigen3/Eigen/src -I ~/../../usr/include/vtk-5.8
# first location: pmd header files (include, back one directory)
# second location: your pcl header files
# third location: your eigen header files
# fourth location: your vtk header files
LDFLAGS = -L. -lpmdaccess2 -lc
all: main
main: main.cpp copysdk copyplugins
$(CC) $(CFLAGS) -c -o main.o main.cpp
$(CC) $(LDFLAGS) -o main main.o
copysdk:
cp ../bin/libpmdaccess* ./ # bin folder back one directory
copyplugins:
cp ../bin/camboardnano* ./
clean:
rm main
rm main.o
rm camboardnano*
rm libpmdaccess*
Example of Errors:
main.o: In function `bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0xcc): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x22d): undefined reference to `vtkActor2D::GetProperty()'
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer8addArrowINS_8PointXYZES3_EEbRKT_RKT0_ddddddRKSsi[bool pcl::visualization::PCLVisualizer::addArrow<pcl::PointXYZ, pcl::PointXYZ>(pcl::PointXYZ const&, pcl::PointXYZ const&, double, double, double, double, double, double, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x279): undefined reference to `pcl::visualization::PCLVisualizer::addActorToRenderer(vtkSmartPointer<vtkProp> const&, int)'
main.o: In function `bool pcl::visualization::PCLVisualizer::addPointCloud<pcl::PointXYZ>(pcl::PointCloud<pcl::PointXYZ>::ConstPtr const&, pcl::visualization::PointCloudGeometryHandler<pcl::PointXYZ> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
main.cpp:(.text._ZN3pcl13visualization13PCLVisualizer13addPointCloudINS_8PointXYZEEEbRKNS_10PointCloudIT_E8ConstPtrERKNS0_25PointCloudGeometryHandlerIS5_EERKSsi[bool pcl::visualization::PCLVisualizer::addPointCloud<pcl::PointXYZ>(pcl::PointCloud<pcl::PointXYZ>::ConstPtr const&, pcl::visualization::PointCloudGeometryHandler<pcl::PointXYZ> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)]+0x84): undefined reference to `pcl::console::print(pcl::console::VERBOSITY_LEVEL, char const*, ...)'
main.o: In function `vtkSmartPointer<vtkDataSet>::~vtkSmartPointer()':
These aren't all the errors, but all the errors that would fit in the terminal can be found here:
http://pastebin.com/jgbczK74
One of the things I noticed is that vtkSmartPointer came up a lot. I think that was the first header file that I was notified about when I was trying to compile the C++ code without the VTK library. Don't know if that means anything.

Related

Boost Libraries not linking properly on Windows

I've a large project which was originally built on Macos, that I'm trying to get compiling on Windows. The makefile for the project is as follows:
CC=C:/cygwin64/bin/g++.exe
BASE_FLAGS = -std=c++14
LDFLAGS = -I/usr/local/Cellar/boost/1.69.0/include -I/opt/local/include -I include/
LLIBFLAGS = -L/usr/local/Cellar/boost/1.68.0/lib
LINKFLAGS = -lboost_thread -lboost_system -l boost_filesystem -l boost_regex -ll -lm
FLAGS = $(BASE_FLAGS) $(LLIBFLAGS) $(LDFLAGS) $(LINKFLAGS)
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SRCS := $(call rwildcard,src/,*.cpp) $(call rwildcard,src/,*.c)
mac:
cd src; bison -d parse.y --debug -t; flex lex.l
time ./runscripts.sh
$(CC) $(FLAGS) -o main.out $(SRCS)
BASE_FLAGS_WIN = -std=gnu++11
LDFLAGS_WIN = -I include/ -I C:\Users\elllz\Downloads\boost_1_69_0
LLIBFLAGS_WIN = -LC:\Users\elllz\Downloads\boost_1_69_0\stage\lib
LINKFLAGS_WIN = -lm -lboost_system -lboost_regex -lboost_filesystem -lboost_thread
FLAGS_WIN = $(BASE_FLAGS_WIN) $(LDFLAGS_WIN) $(LLIBFLAGS_WIN) $(LINKFLAGS_WIN)
win:
bison -d .\src\parse.y -t -g
flex .\src\lex.l
.\scripts\ALL_HEADER_TOKENS.bat
cp .\parse.tab.h .\src\parse.tab.h
cp .\parse.tab.c .\src\parse.tab.c
cp .\lex.yy.c .\src\lex.yy.c
rm .\parse.tab.h .\parse.tab.c .\lex.yy.c
$(CC) $(FLAGS_WIN) $(SRCS)
Note that the first second is the (working) macos target, and the later is the Windows target. When trying to link boost on Windows, I keep getting a plethora of undefined reference errors, like such:
/cygdrive/c/Users/elllz/AppData/Local/Temp/cc1jUol1.o:FileVerification.cpp:(.text$_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEE[_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEE]+0x15): undefined reference to `boost::filesystem::path::codecvt()'
/cygdrive/c/Users/elllz/AppData/Local/Temp/cc1jUol1.o:FileVerification.cpp:(.text$_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEE[_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEE]+0x15): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::filesystem::path::codecvt()'
/cygdrive/c/Users/elllz/AppData/Local/Temp/cc1jUol1.o:FileVerification.cpp:(.text$_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEE[_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEE]+0x32): undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, _mbstate_t> const&)'
/cygdrive/c/Users/elllz/AppData/Local/Temp/cc1jUol1.o:FileVerification.cpp:(.text$_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEE[_ZN5boost10filesystem11path_traits7convertEPKcS3_RSbIwSt11char_traitsIwESaIwEE]+0x32): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::filesystem::path_traits::convert(char const*, char const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, _mbstate_t> const&)'
/cygdrive/c/Users/elllz/AppData/Local/Temp/cc1jUol1.o:FileVerification.cpp:(.text$_ZN5boost10filesystem6existsERKNS0_4pathE[_ZN5boost10filesystem6existsERKNS0_4pathE]+0x1e): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/cygdrive/c/Users/elllz/AppData/Local/Temp/cc1jUol1.o:FileVerification.cpp:(.text$_ZN5boost10filesystem6existsERKNS0_4pathE[_ZN5boost10filesystem6existsERKNS0_4pathE]+0x1e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/cygdrive/c/Users/elllz/AppData/Local/Temp/cc1jUol1.o:FileVerification.cpp:(.text$_ZN5boost10filesystem15is_regular_fileERKNS0_4pathE[_ZN5boost10filesystem15is_regular_fileERKNS0_4pathE]+0x1e): undefined reference to `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/cygdrive/c/Users/elllz/AppData/Local/Temp/cc1jUol1.o:FileVerification.cpp:(.text$_ZN5boost10filesystem15is_regular_fileERKNS0_4pathE[_ZN5boost10filesystem15is_regular_fileERKNS0_4pathE]+0x1e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::filesystem::detail::status(boost::filesystem::path const&, boost::system::error_code*)'
/cygdrive/c/Users/elllz/AppData/Local/Temp/ccbzCEFH.o:Token.cpp:(.text$_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE]+0x7e): undefined reference to `boost::re_detail_106900::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::c_regex_traits<char> > >::match()'
/cygdrive/c/Users/elllz/AppData/Local/Temp/ccbzCEFH.o:Token.cpp:(.text$_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE]+0x7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::re_detail_106900::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::c_regex_traits<char>
> >::match()'
/cygdrive/c/Users/elllz/AppData/Local/Temp/ccbzCEFH.o:Token.cpp:(.text$_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEE6assignEPKcS7_j[_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEE6assignEPKcS7_j]+0x31): undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::c_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
/cygdrive/c/Users/elllz/AppData/Local/Temp/ccbzCEFH.o:Token.cpp:(.text$_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEE6assignEPKcS7_j[_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_14c_regex_traitsIcEEEEE6assignEPKcS7_j]+0x31): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `boost::basic_regex<char, boost::regex_traits<char, boost::c_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
That's only a snippet, all the information I can find says it's a boost linking problem, but I can't pin it down for the life of me. I'm compiling boost 1.69.0 with the commands:
.\boostrap.bat
./bjam
./bjam install
In a similar manner to the instructions found here. I've tried jsut about everything I can think of, as well as spent a lot of time recompiling boost, so any help you might be able to offer would be greatly appreciated!
Things I have tried:
Checking the libaries do exist in /stage/lib, they do, as .a and .dll.a files.
Moving the entire boost folder into a relative path of my build folder, in case I was specifying the link / include folders wrong.
Recompiling boost with a host of options, I can't come close to recalling them all.
I suspect that you may have multiple issues...
Your makefile specifies different versions of the boost libraries: 1.69.0 and 1.68.0
LDFLAGS = -I/usr/local/Cellar/boost/1.69.0/include -I/opt/local/include -I include/
LLIBFLAGS = -L/usr/local/Cellar/boost/1.68.0/lib
It could be as simple as that.
However, on a Windows machine, the command:
.\boostrap.bat
normally assumes building the boost libraries using Visual Studio.
So depending upon where you built the boost libraries from, you may have built Visual Studio lib files, not g++ lib files. You can tell from the library file names:
// gcc, actually mingw73: mgw73
libboost_filesystem-mgw73-mt-x64-1_69.dll.a
// msvc 2017: vc141
boost_filesystem-vc141-mt-x64-1_69.lib
It sounds like yours are correct, but you can specify the g++ compiler explicitly when building boost, e.g.:
.\boostrap.bat gcc
Finally, it's difficult to maintain cross platform makefiles, especially with boost.
I recommend using cmake instead.

Connecting c++ to mysql using mysql-c++-connector 8

I want to connect to mysql 8 using mysql-c++-connector8 (xdevapi) and I use .so file for linking but I get errors
here is my main.cpp file
#include <iostream>
#include <mysqlx/xdevapi.h>
using namespace ::mysqlx;
using std::cout;
using std::cin;
using std::endl;
int main(){
Session sess("localhost",3306,"root","mypass");
Schema db = sess.getSchema("university");
Collection myColl = db.getCollection("student");
DocResult myDocs = myColl.find("name like :param").execute();
cout<<myDocs.fetchOne();
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(1)
set(CMAKE_CXX_STANDARD 17)
include_directories(~/mysql-connector-c++/include)
link_directories(~/mysql-connector-c++/lib64)
set(PROJECT_LINK_LIBS libmysqlcppconn8.so)
add_executable(myExe main.cpp)
target_link_libraries(myExe ${PROJECT_LINK_LIBS})
Errors:
[ 50%] Linking CXX executable myExe
/usr/bin/ld: CMakeFiles/myExe.dir/main.cpp.o: in function `mysqlx::string::string(char const*)':
/home/amir/mysql-connector-c++/include/mysqlx/devapi/common.h:100: undefined reference to `mysqlx::string::Impl::from_utf8(mysqlx::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: CMakeFiles/myExe.dir/main.cpp.o: in function `mysqlx::string::string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/amir/mysql-connector-c++/include/mysqlx/devapi/common.h:105: undefined reference to `mysqlx::string::Impl::from_utf8(mysqlx::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: CMakeFiles/myExe.dir/main.cpp.o: in function `mysqlx::string::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >() const':
/home/amir/mysql-connector-c++/include/mysqlx/devapi/common.h:115: undefined reference to `mysqlx::string::Impl::to_utf8[abi:cxx11](mysqlx::string const&)'
/usr/bin/ld: CMakeFiles/myExe.dir/main.cpp.o: in function `void mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::set<true, mysqlx::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mysqlx::SessionOption, unsigned int&, mysqlx::SessionOption, mysqlx::string const&>(mysqlx::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mysqlx::SessionOption&&, unsigned int&, mysqlx::SessionOption&&, mysqlx::string const&)':
/home/amir/mysql-connector-c++/include/mysqlx/devapi/detail/settings.h:67: undefined reference to `mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::common::Value>, std::allocator<std::pair<int, mysqlx::common::Value> > >&&)'
/usr/bin/ld: CMakeFiles/myExe.dir/main.cpp.o: in function `void mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::set<true, mysqlx::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(mysqlx::SessionOption, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&)':
/home/amir/mysql-connector-c++/include/mysqlx/devapi/detail/settings.h:67: undefined reference to `mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::common::Value>, std::allocator<std::pair<int, mysqlx::common::Value> > >&&)'
/usr/bin/ld: CMakeFiles/myExe.dir/main.cpp.o: in function `void mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::set<true, mysqlx::SessionOption, mysqlx::string const&>(mysqlx::SessionOption, mysqlx::string const&)':
/home/amir/mysql-connector-c++/include/mysqlx/devapi/detail/settings.h:67: undefined reference to `mysqlx::internal::Settings_detail<mysqlx::internal::Settings_traits>::do_set(std::__cxx11::list<std::pair<int, mysqlx::common::Value>, std::allocator<std::pair<int, mysqlx::common::Value> > >&&)'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/myExe.dir/build.make:95: myExe] Error 1
make[2]: *** [CMakeFiles/Makefile2:68: CMakeFiles/myExe.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:80: CMakeFiles/myExe.dir/rule] Error 2
make: *** [Makefile:118: myExe] Error 2
I don't want to use legacy connectors as it is not recommended .
TL;DR; You need to use the old GCC ABI by setting the _GLIBCXX_USE_CXX11_ABI to 0. This can be done with cmake by adding the following to your CMakeLists.txt:
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
The issue comes from the "Linux - Generic" of the MySQL connector which have likely been built without the new CXX11 ABI of GCC (introduced in gcc 5.1).
Since your compiler is recent, the default is to use the new ABI, so when you include <mysqlx/xdevapi.h>, you create declarations such as:
mysqlx::string::Impl::from_utf8(
mysqlx::string&,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
...that use the new ABI (see the __cxx11 namespace).
But since the connectors have been built with the old ABI, the libmysqlcppconn8.so contains symbols for functions matching this kind of declaration:
mysqlx::string::Impl::from_utf8(
mysqlx::string&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
You can check this by running readelf -Ws libmysqlcppconn8.so, for the "Linux - Generic" version I get (with a grep from_utf8)1:
1428: 00000000000a0a86 193 FUNC GLOBAL DEFAULT 12 _ZN6mysqlx6string4Impl9from_utf8ERS0_RKSs
9437: 00000000000a0a86 193 FUNC GLOBAL DEFAULT 12 _ZN6mysqlx6string4Impl9from_utf8ERS0_RKSs
But for the Ubuntu 18.10 version I get:
725: 00000000000a23e0 183 FUNC GLOBAL DEFAULT 12 _ZN6mysqlx6string4Impl9from_utf8ERS0_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
10141: 00000000000a23e0 183 FUNC GLOBAL DEFAULT 12 _ZN6mysqlx6string4Impl9from_utf8ERS0_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
The easiest fix is to tell your compiler to use the old ABI, so that the symbol will match. This can be done by setting the _GLIBCXX_USE_CXX11_ABI macro to 0 when compiling:
g++ -D_GLIBCXX_USE_CXX11_ABI=0 main.cpp
...or by adding the following to CMakeLists.txt:
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
If you use multiple external libraries, you have to be careful that those also use the old ABI, otherwise you will likely face the opposite issue, i.e., a library built with the new ABI cannot be used directly to build a program with the old ABI.
1 The "Linux - Generic" version contains reference to the CXX11 ABI, so I do not really know what is going on here. It looks like some parts of the library has been compile with the new ABI.
You may need to download the specific version for current OS instead generic-linux version.
for example rhel8 x86_64 platform, the mysql-connector-c++-8.0.23-1.el8.x86_64.rpm and mysql-connector-c++-devel-8.0.23-1.el8.x86_64.rpm should be downloaded. (https://dev.mysql.com/downloads/connector/cpp/)
Then unarchive that into same folder. (note if you have windows system, please unarchive it in linux since there's some soft link in it)
Then just using it without old CXX11ABI (need NOT to define _GLIBCXX_USE_CXX11_ABI=0)

undefined reference to boost::filesystem::path_traits::convert

I am trying to compile a program using cmake, and am seeing the following linker error:
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so:
undefined reference to
boost::filesystem::path_traits::convert(wchar_t const*, wchar_t
const*, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, std::codecvt<wchar_t, char, __mbstate_t>
const&)' /home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so:
undefined reference to
boost::filesystem::path_traits::dispatch(boost::filesystem::directory_entry
const&, std::__cxx11::basic_string,
std::allocator >&)'
The linker command that ninja generated looks like this:
g++ -pthread -DBOOST_ALL_DYN_LINK
utility/test/CMakeFiles/utilityTest.dir/loadCSVTests.cpp.o
utility/test/CMakeFiles/utilityTest.dir/main.cpp.o
utility/test/CMakeFiles/utilityTest.dir/randomDeviceTests.cpp.o -o
utility/test/utilityTest -rdynamic
/home/quant/bin/boost_1_61_0/stage/lib/libboost_thread.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_program_options.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_serialization.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_unit_test_framework.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_system.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_filesystem.so
utility/lib/libutilityLib.a utility/testLib/libutilityTestLib.a
utility/lib/libutilityLib.a
/home/quant/bin/boost_1_61_0/stage/lib/libboost_thread.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_program_options.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_serialization.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_unit_test_framework.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_system.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_log_setup.so
/home/quant/bin/boost_1_61_0/stage/lib/libboost_filesystem.so
-Wl,-rpath,/home/quant/bin/boost_1_61_0/stage/lib
As you can see, I am linking against boost_filesystem and boost_system, so it's not the same problem as referenced on this SO post (and the many others like it).
I am using boost 1.61, which I compiled with gcc 5.3 (the same compiler as the one I'm compiling my program with).
What am I doing wrong?
I had a similar issue, this could be because of a new ABI which is introduced from gcc 5.1.
https://github.com/openframeworks/openFrameworks/issues/4203
I fixed mine by adding "add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)" to CMakeLists.txt

Linker error. It is not possible [duplicate]

This question already has answers here:
Why does the order in which libraries are linked sometimes cause errors in GCC?
(9 answers)
Closed 6 years ago.
I am trying to use sfm module for opencv. The problem is linking that.
So, let's see the code.
main.cpp:
...
cv::sfm::reconstruct(images_paths, Rs_est, ts_est, K2, points3d_estimated, true)
...
I compiled this code to main.o. And now, I would like to link it with libopencv_core.so and libopencv_sfm.so .
The second one file contains a definition of function 'reconstruct'. Why am I sure? When I type:
nm -D libopencv_sfm.so | grep reconstruct
I got:
00000000000b4ca0 T _ZN2cv3sfm11reconstructERKNS_11_InputArrayERKNS_12_OutputArrayES6_RKNS_17_InputOutputArrayEb
00000000000b4ba0 T _ZN2cv3sfm11reconstructERKNS_11_InputArrayERKNS_12_OutputArrayES6_RKNS_17_InputOutputArrayES6_b
00000000000b2650 T _ZN2cv3sfm11reconstructESt6vectorISsSaISsEERKNS_12_OutputArrayES6_RKNS_17_InputOutputArrayEb
00000000000b2550 T _ZN2cv3sfm11reconstructESt6vectorISsSaISsEERKNS_12_OutputArrayES6_RKNS_17_InputOutputArrayES6_b
I checked signature of reconstruct function in main.o file. And it match to:
_ZN2cv3sfm11reconstructESt6vectorISsSaISsEERKNS_12_OutputArrayES6_RKNS_17_InputOutputArrayES6_b
So the shared library contains definition of reconstruct.
So now, I link:
g++ libopencv_core.so libopencv_sfm.so main.o -o main
and it gives me error:
undefined reference to `cv::sfm::reconstruct(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> > > >, cv::_OutputArray const&, cv::_OutputArray const&, cv::_InputOutputArray const&, cv::_OutputArray const&, bool)'
And I don't understand. After all libopencv_sfm.so contains definition of that function!
And please: don't tell me: use cmake. I tried use cmake and the problem is the same. So I try to understand it on low level.
Thanks in advance.
(gcc version: 5.1.1)
To link a library use -l flag and add dependencies after the objects they depend on them:
g++ -o main main.o -L. -lopencv_sfm -lopencv_core
The -L. will search for libearies in current path. Omit if not needed.

boost regex install from source library not linking - osx

I am using the boost libraries for a project, and I am running into issues with the regex library. I am re-installing the libraries because I have upgraded to osx 10.9 (mavericks).
I am getting 2 undefined references for :
boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > const&)
and
boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)
I am installing the boost libraries from source, specifically because I do not want to be using macports or any outside package installer. The reason is that my program is used in the mathematics and scientific community, and I am trying to keep it so that it can easily compiled from source with the appropriate dependencies (i.e. linking to certain libraries like gmp and mpfr, and, at least for now, boost).
The undefined reference issue is occurring regardless of the compiler I've used. That is, I have installed gcc 4.7.3 with apple's default compiler from the command line developer's tools. So this occurs for both gcc4.7.3 AND the default g++ (apple's clang, version 4.2.1).
This is a parallel application, so I have two versions of mpich3 installed, both compiled with the above 2 compilers and installed and built in separate directories.
When I built boost, I edited the user-config.jam file and added the lines
using gcc : 4.7.3 : "abs\loc\here" ;
and
using mpi ;
Then I ran sudo ./bootstrap.sh ; sudo ./b2 ; sudo ./b2 install (with the sudo being necessary as the installation files are in a /usr/local subdir)
Anyway, the file that is using the boost libraries is called para_aux_funcs.hpp / para_aux_funcs.cpp, and I am compiling with (well, after a Makefile that produces this for me to make all .o files from the .cpp ones ):
/usr/local/mpich3-mac-default/bin/mpic++ -cxx=/usr/local/bin/g++ -I/Users/matthewniemerg/Research/Bertini/Current/BertiniSource_v1.4/include -I/usr/local/boost_1_50_0/include -I../include -Dtimingstep2 -DTIXML_USE_STL -Wall -O3 -funroll-loops -fexpensive-optimizations -fopenmp -c para_aux_funcs.cpp -L/usr/local/boost_1_50_0/lib -lboost_regex -lboost_system -lboost_filesystem -o para_aux_funcs.o
I've also done this with the other mpi installation with the appropriate -cxx flag passed to indicate which compiler was used for the mpi compilation. And, I've also switch the order of where the -L and -l flags go in the above command, but with the same results.
That is, the following command gives me the undefined references indicated above:
/usr/local/mpich3-mac-default/bin/mpic++ -cxx=/usr/local/bin/g++ -I/Users/matthewniemerg/Research/Bertini/Current/BertiniSource_v1.4/include -I/usr/local/boost_1_50_0/include -I../include -Dtimingstep2 -DTIXML_USE_STL -Wall -O3 funroll-loops -fexpensive-optimizations -fopenmp -o paramotopy paramotopy.o point.o datagatherer.o failed_paths.o menu_cases.o master.o slave.o step2readandwrite.o runinfo.o mtrand.o random.o step2_funcs.o step1_funcs.o timing.o tinyxmlerror.o tinyxml.o tinystr.o tinyxmlparser.o xml_preferences.o para_aux_funcs.o ../lib/libbertini_osx9.a -lm -lmpfr -lgmp -L/usr/local/boost_1_50_0/lib -lboost_regex -lboost_system -lboost_filesystem
This looks like a linking error, but I am linking the libraries (i.e. -l flag) and pointing to the appropriate directories for where the library is located (i.e. -L flag) and indicating where the appropriate header files are (i.e. -I flag).
Any thoughts / ideas?