Caffe convert_imageset: symbol lookup error - c++

I used caffe to train my CNN.When I transfered my data to the lmdb format using the tool 'convert_imageset', it report an error:
/convert_imageset: symbol lookup error: ../../build/tools/convert_imageset: undefined symbol: _ZN5caffe16ReadImageToDatumERKSsiiiiibS1_PNS_5DatumE
How could I solve it??

The symbol you are missing is the function:
caffe::ReadImageToDatum(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, int, int, int, bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, caffe::Datum*)
(You can use c++filt shell utility to recover this from the symbol you got in your error message)
The missing function is declared in io.hpp file, but its implementation in io.cpp is conditioned on USE_OPENCV directive (see BVLC/caffe issue #5329).
Re-build your caffe with USE_OPENCV := 1 in 'Makefile.config'.

Related

Running a C++ project with makefile but getting linking errors for source files in subdirectories

I've been trying to get a c++ project to build using this makefile:
https://pastebin.com/vMEMwH4C
The structure of my project is like this:
For context, I'm using a library called Raylib and trying to run on a windows machine. This makefile was provided with a project template and worked just fine before I tried to modify it to run with C++ instead of C and tried to include my source directories for the project instead of including just the main.cpp file.
It compiles just fine, but the linking is where I keep running into issues.
Here's the output when I run the make file:
Executing task in folder VSCode: C:/raylib/w64devkit/bin/mingw32-make.exe RAYLIB_PATH=C:/raylib/raylib PROJECT_NAME=main OBJS=src/main.cpp BUILD_MODE=DEBUG
i686-w64-mingw32-g++ -o main src/main.cpp -Wall -std=c++17 -D_DEFAULT_SOURCE -Wno-missing-braces -g -O0 C:/raylib/raylib/src/raylib.rc.data -Wl,--subsystem,windows -I. -IC:/raylib/raylib/src -IC:/raylib/raylib/src/external -Ilib/ -Ilib/util -Ilib/systems -Ilib/core -Ilib/components -ID://boost_1_81_0 -L. -LC:/raylib/raylib/src -LC:/raylib/raylib/src -lraylib -lopengl32 -lgdi32 -lwinmm -DPLATFORM_DESKTOP
...
C:/raylib/w64devkit/bin/ld.exe: C:\Users\Josh\AppData\Local\Temp\cczAGA5y.o: in function `Z4initv':
D:\Documents\WindowsRaylib\VSCode/src/main.cpp:276: undefined reference to `LocationManager::moveToLocation(nlohmann::json_abi_v3_11_2::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long long, unsigned long long, double, std::allocator, nlohmann::json_abi_v3_11_2::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, MapLocation&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, MapLocation, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, MapLocation> > >&, entt::basic_registry<entt::entity, std::allocator<entt::entity> >&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >&)'
... (and a bunch more of messages like these)....
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:408: main] Error 1
I've been looking through many posts trying to figure out how to include the right subdirectories in the linking process, but nothing seems to work. I would really appreciate some help!
(one odd thing I noticed is that the object file mentioned in the error "C:\Users\Josh\AppData\Local\Temp\cczAGA5y.o" is in the AppData folder, not my actual project folder. I can't figure out why, though.)

undefined symbol: std::string when linking static library in VS 2017

I need to link static library to my main project in VS2017. I have included the lib file and compile my main project using Gnu++14. Both of the main project and the static library are in C++. The problem is I don't have information how this static library is built. Then I got these undefined symbol errors related to std::string and std::basic_string when compiling my main project.
Error undefined symbol: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
Error undefined symbol: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)
Error undefined symbol: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
Error undefined symbol: std::string::append(char const*, unsigned long)
Error undefined symbol: std::string::assign(char const*, unsigned long)
Error undefined symbol: std::string::assign(std::string const&)
Error undefined symbol: std::string::_Rep::_M_destroy(std::allocator<char> const&)
Error undefined symbol: std::string::_Rep::_S_empty_rep_storage
I suspect the static library is built differently (maybe clang), but I am not sure. Any lead about the possible cause of this error or possible solution?

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)

How do I compile googleTestLibrary on QNX 6.5.0?

I want to compile google Test Library on QNX. But I did not success. I tried everything. Can be seen my compilation errors below
Is someone share to libGoogleTest_g.a and libGoogleTest.a file for me ?
D:/ETCT_PROJECTS/CommonLibrary/Test/ETCCommon/Common/QNXUnitTests/../../../../GoogleTestLibrary/lib\libgoogleTest_g.a(gtest-all.o):
In function `_M_initialize_dispatch<const char* const*>':
/usr/qnx650/target/qnx6/usr/include/c++/4.4.2/ext/new_allocator.h:87: undefined reference to `std::__throw_bad_alloc()'
D:/ETCT_PROJECTS/CommonLibrary/Test/ETCCommon/Common/QNXUnitTests/../../../../GoogleTestLibrary/lib\libgoogleTest_g.a(gtest-all.o):
In function `operator<< <char, std::char_traits<char>, std::allocator<char> >':
/usr/qnx650/target/qnx6/usr/include/c++/4.4.2/bits/basic_string.h:2506:
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
D:/ETCT_PROJECTS/CommonLibrary/Test/ETCCommon/Common/QNXUnitTests/../../../../GoogleTestLibrary/lib\libgoogleTest_g.a(gtest-all.o):
In function `ValueHolder':
/usr/qnx650/target/qnx6/usr/include/c++/4.4.2/ext/new_allocator.h:87: undefined reference to `std::__throw_bad_alloc()'
D:/ETCT_PROJECTS/CommonLibrary/Test/ETCCommon/Common/QNXUnitTests/../../../../GoogleTestLibrary/lib\libgoogleTest_g.a(gtest-all.o): In function `~DeathTestImpl':
/home/emres/GoogleTest/./src/gtest-death-test.cc:374:
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/emres/GoogleTest/./src/gtest-death-test.cc:374:
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/emres/GoogleTest/./src/gtest-death-test.cc:374:
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
Check this link to fix the compilation problem.
https://code.google.com/p/googletest/issues/detail?id=444
After you fixed the compilation problem, follow the below steps to create your static library files.
Generate gtest-all.o object file for all configurations(DEBUG RELEASE) simply open QNX momentics and right click to gtest-all.cc
Login to QNX, and copy your gtest-all.o files to any directory
enter the directory to where files copied
create static libraries by using ar(archive) command as shown below.
DEBUG : ar -rv libgoogle_test_g.a gtest-all.o
RELEASE : ar -rv libgoogle_test.a gtest-all.o
Copy *.a files from QNX and use new static library in your project

Runtime c++ "undefined symbol" exception

I am getting an undefined symbol exception for a method that is actually executing. This makes no sense to me. Here is an example of the log:
/src/CustomerReturnProcessUtils/labelPrintUtils/CreturnLabelPrinter.cpp:402 (null)(): CreturnLabelPrinter: [InitializeZebraPrint] Success connecting to socket
/apollo/env/CustomerReturnUIServiceUS/bin/CustomerReturnUIService: symbol lookup error: /apollo/env/CustomerReturnUIServiceUS/bin/CustomerReturnUIService: undefined symbol: _ZN19CreturnLabelPrinter10PrintLabelESsSsiiiSsbSs
The "Success connecting to socket" is logged by a method call INSIDE of CreturnLabelPrinter::PrintLabel...how can I be getting an undefined symbol exception for that? This is a non-static method. The code for it is not relevant (and I can't post it here anyways)...I am just wondering what conditions this could happen under. I haven't seen any problems during the compiling and linking of these modules. The calling method is in a different library than the "undefined symbol".
Thi happened to me when I had 2 versions of the library and I was linking against the wrong one. Also c++filt shows:
$ c++filt __ZN19CreturnLabelPrinter10PrintLabelESsSsiiiSsbSs
CreturnLabelPrinter::PrintLabel(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)
This has a huge list of arguments, did you check them?