I'm trying to install NaoQI C++ SDK on Linux 18.04.1 (VirtualBox). I followed this installation instruction: http://doc.aldebaran.com/2-1/dev/cpp/install_guide.html
My problem is in Part E. Step.3, when I'm trying to run "qibuild make"
I get this error while I'm trying to build the helloworld example:
CMakeFiles/testhelloworld.dir/testhelloworld.cpp.o: In function
main':
/home/nounou/Documents/SDKfolder/naoqi-sdk/doc/dev/cpp/examples/core/helloworld/testhelloworld.cpp:35:
undefined reference to
AL::ALBroker::createBroker(std::__cxx11::basic_string, std::allocator > const&,
std::__cxx11::basic_string,
std::allocator > const&, int, std::__cxx11::basic_string, std::allocator > const&, int, int,
std::__cxx11::basic_string,
std::allocator >, bool)'
/home/nounou/Documents/SDKfolder/naoqi-sdk/doc/dev/cpp/examples/core/helloworld/testhelloworld.cpp:38:
undefined reference to
AL::ALProxy::ALProxy(boost::shared_ptr<AL::ALBroker>,
std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, int, int)'
CMakeFiles/testhelloworld.dir/testhelloworld.cpp.o: In function
qi::log::LogStream::~LogStream()':
....
CMakeFiles/testhelloworld.dir/build.make:113: recipe for target
'sdk/bin/testhelloworld' failed make[2]: * [sdk/bin/testhelloworld]
Error 1 CMakeFiles/Makefile2:67: recipe for target
'CMakeFiles/testhelloworld.dir/all' failed make[1]: *
[CMakeFiles/testhelloworld.dir/all] Error 2 Makefile:129: recipe for
target 'all' failed make: *** [all] Error 2
[ERROR]: BuildFailed Error occurred when building project hello world
Please, help me if you have any idea about what the problem is. Thank you!
I had the same problem with Fedora 29... After some hours of search I found that adding set(CMAKE_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0") to the CMakeLists.txt file fixed the problem.
I found the solution here:
gcc using c++11 standard even though 98 explicitly specified
Most probably you have an ABI incompatibility issue, due to the transition to C++11. You are using Ubuntu 18.04, which compilers are configured to link with modern C++ libraries, but the toolchain is compiled with former ABIs, and does not enforce compiler flags to ensure compatibility.
To workaround this, either:
Set compiler flags to make sure you don't link against C++11 libraries (if someone knows them, please share).
Compile for the robot instead of your machine, by using the cross-toolchain instead of the Linux toolchain.
Use Ubuntu 12.04, as told in the installation guide.
By the way, in the C++ installation guide, subsection E.4, it says to compile the example under core/sayhelloworld. Here you compiled the example under core/helloworld.
Related
I am trying to develop a program that communicates with a PCSC USB reader using Conan and CMake with the LibLogicalAccess library. I followed the instructions of building and installing the library which seemed to have gone fine. I created a small simple console project with a "main.cpp" file. Following the C++ guide on the wiki of the library I tried to call a function from the library which resulted in a "Undefined reference to function. I know there are a lot of topics covering this but I have read as many as I could but could not seem to find the right solution.
I don't have much experience with Ubuntu/CMake/Conan/C++ so it might as well be a very simple fix.
OS: Kubuntu 18.04
Lang: C++
Related software: LibLogicalAccess
2.2.1,
CMake 3.17.1,
Conan 1.25.0
main.cpp
#include <iostream>
#include <logicalaccess/dynlibrary/librarymanager.hpp>
#include <logicalaccess/readerproviders/readerconfiguration.hpp>
#include <logicalaccess/cards/chip.hpp>
int main()
{
std::cout << "Program started\n";
// Reader configuration object to store reader provider and reader unit selection.
std::shared_ptr<logicalaccess::ReaderConfiguration> readerConfig(new logicalaccess::ReaderConfiguration());
// Set PCSC ReaderProvider by calling the Library Manager which will load the function from the corresponding plug-in
readerConfig->setReaderProvider(logicalaccess::LibraryManager::getInstance()->getReaderProvider("PCSC"));
std::cout << "after..\n";
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(project)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
set(CMAKE_CXX_FLAGS "-I /usr/include/PCSC")
add_executable(project main.cpp)
target_link_libraries(project PUBLIC CONAN_PKG::LogicalAccess)
When I try to build the program using cmake --build . this is the output:
[100%] Linking CXX executable bin/project
CMakeFiles/project.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x140): undefined reference to `logicalaccess::LibraryManager::getReaderProvider(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/project.dir/build.make:191: recipe for target 'bin/project' failed
make[2]: *** [bin/project] Error 1
CMakeFiles/Makefile2:95: recipe for target 'CMakeFiles/project.dir/all' failed
make[1]: *** [CMakeFiles/project.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2
The weird part is that the first line of code: std::shared_ptr<logicalaccess::ReaderConfiguration> readerConfig(...) works fine and the second line of code gives an undefined reference.
I have tried other functions in the same file which give the same result. The file compiles and runs fine when I remove the last "setReaderProvider" line of code. Also tried a lot of different little adjustments regarding the conanfile.txt and CMakeLists.txt.
Your error says:
main.cpp:(.text+0x140): undefined reference to `logicalaccess::LibraryManager::getReaderProvider(std::__cxx11::basic_string, std::allocator > const&)'
It occurs because your CMake is using libstdc++11 to link, however, Conan is configured to use libstdc++ due backward compatibility.
You need to update your default libcxx:
conan profile update settings.compiler.libcxx=libstdc++11 default
Please, read this section in Conan docs How to Manage GCC ABI to get more information.
Also, it's explained on step 5 of Getting Started.
Now when building again, you will need that your local packages won't be available, because it's a new package, using different settings, so you will need to install, or build from sources. The link to libstdc++11 is automatically managed by Conan, it passes the definitions to CMake.
Regards!
i tried to install tiramisu compiler
and once trying install it's sub-modules ( (ISL, LLVM and Halide) by using this command
dina#dina-VBox:~/tiramisu$ ./utils/scripts/install_submodules.sh ./
i get the error
Done installing isl
#### Installing LLVM ####
cd .//3rdParty/llvm
.//utils/scripts/functions.sh: line 6: cd: .//3rdParty/llvm: No such file or directory
and to fix it i used the command shared on the answer here
./utils/scripts/install_submodules.sh $PWD
it worked better then the first one i reached 95% of the installation however it stop here with this error
Linking CXX shared library ../../lib/libLTO.so undefiened refernece to target
Here is the detail of the error
[ 95%] Linking CXX executable ../../bin/opt
[ 95%] Linking CXX shared library ../../lib/libLTO.so
../../lib/libLLVMX86AsmParser.a(X86AsmParser.cpp.o): In function `llvm::RegisterMCAsmParser<(anonymous namespace)::X86AsmParser>::Allocator(llvm::MCSubtargetInfo const&, llvm::MCAsmParser&, llvm::MCInstrInfo const&, llvm::MCTargetOptions const&)':
X86AsmParser.cpp:(.text._ZN4llvm19RegisterMCAsmParserIN12_GLOBAL__N_112X86AsmParserEE9AllocatorERKNS_15MCSubtargetInfoERNS_11MCAsmParserERKNS_11MCInstrInfoERKNS_15MCTargetOptionsE+0x164): undefined reference to `llvm::CreateX86AsmInstrumentation(llvm::MCTargetOptions const&, llvm::MCContext const&, llvm::MCSubtargetInfo const*&)'
CMakeFiles/llvm-mc.dir/llvm-mc.cpp.o: In function `main':
llvm-mc.cpp:(.text.startup.main+0xe4): undefined reference to `LLVMInitializeX86Disassembler'
../../lib/libLLVMX86Desc.a(X86MCTargetDesc.cpp.o): In function `LLVMInitializeX86TargetMC':
X86MCTargetDesc.cpp:(.text.LLVMInitializeX86TargetMC+0xc7): undefined reference to `llvm::createX86_32AsmBackend(llvm::Target const&, llvm::MCRegisterInfo const&, llvm::Triple const&, llvm::StringRef, llvm::MCTargetOptions const&)'
...
...
../../lib/libLLVMAArch64CodeGen.a(AArch64TargetObjectFile.cpp.o):(.data.rel.ro._ZTVN4llvm29AArch64_MachoTargetObjectFileE[_ZTVN4llvm29AArch64_MachoTargetObjectFileE]+0xa0): undefined reference to `llvm::TargetLoweringObjectFileMachO::SelectSectionForGlobal(llvm::GlobalObject const*, llvm::SectionKind, llvm::TargetMachine const&) const'
collect2: error: ld returned 1 exit status
tools/opt/CMakeFiles/opt.dir/build.make:349: recipe for target 'bin/opt' failed
make[2]: *** [bin/opt] Error 1
CMakeFiles/Makefile2:44345: recipe for target 'tools/opt/CMakeFiles/opt.dir/all' failed
make[1]: *** [tools/opt/CMakeFiles/opt.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
dina#dina-VBox:~/tiramisu$ ^C
I do not know what should i do to fix this new error can someone help please.
I have not been able to fix the problem on it's self but i have changed the way of installing tiramisu.
I did pay attention to that and i do want to pay your attention to too that may serve your time and success your installation.
Never ever install tiramisu on virtual box cause tiramisu require a bit high performance machine i mean at least 6G of RAM once compiling it consume >= 6GRAM.
Means it's better to have partition or Linux system directly.
You may find issues from version to version means some succeed to install it in 18.04 where some in 16 where some in 14. So if you fail in version never give up try another version better then still paralyzed.
It better to not lunch anything in parallel once installing tiramisu.
You need to have a good network to clone tiramisu sub-modules and tiramisu on itself with a network of 35kb/s it may took 24h to get clone all stuff.
Respect the all the tips listed to install tiramisu to avoid have trouble ex if it's said you should CMake 5.0 version do it because they have tested in this version and they insure that work nothing grantee that in 6 version it will work so be careful.
If you scattered things in the way that you could not fix issues. It's better to clean up everything and restart from "0".
Be patient : Installing tiramisu is a bit heavy task so be Broad-minded and Zen.
it took me one month to be able to install tiramisu i had many issues. But once i install it in a partition and doing the steps show above carefully i have been finally to install successfully.
Best of luck :).
I tried to complile this project: https://github.com/ccshiro/corecraft
I am use Ubuntu 16.04, i have installed: gcc 4.9, 5.0, 6.0; g++ 4.9, 5.0; clang; cmake3; and libsparsehash-dev .
I got this error:
[ 96%] Linking CXX executable mangosd
../game/libgame.a(Map.cpp.o): In function `sh_hashtable_settings<ObjectGuid, std::tr1::hash<ObjectGuid>, unsigned long, 4>::hash(ObjectGuid const&) const':
/usr/include/google/sparsehash/hashtable-common.h:65: undefined reference to `std::tr1::hash<ObjectGuid>::operator()(ObjectGuid) const'
collect2: error: ld returned 1 exit status
src/mangosd/CMakeFiles/mangosd.dir/build.make:244: recipe for target 'src/mangosd/mangosd' failed
make[2]: *** [src/mangosd/mangosd] Error 1
CMakeFiles/Makefile2:930: recipe for target 'src/mangosd/CMakeFiles/mangosd.dir/all' failed
make[1]: *** [src/mangosd/CMakeFiles/mangosd.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Here Map.cpp , here /usr/include/google/sparsehash/hashtable-common.h
I ve tried to google about "collect2: error: ld returned 1 exit status" error, and found that in code might be cyrrilics or non latinics symbols, but i didnt find something wrong in this 2 files above.
On issue tracker i also found same error from another person https://github.com/ccshiro/corecraft/issues/5
I am not C++ programmer so i cant understand what wrong is here, can anyone help me with this?
What you are seeing is a linker error. Everything compiles fine, and then when the linker starts to stitch the code together it's missing a object that defines the functionality of the std::tr1::hash<ObjectGuid>::operator() hash operator. This is a template specialization that allows this object to be used as a unique key in a map (or hash set).
The template for the hash function is specified here. At first glance, I wasn't seeing why it shouldn't link, but then I realized that the linker is looking for std::tr1::hash<ObjectGuid> instead of std::hash<ObjectGuid>. Basically, it looks like your STL library is using TR1 which is an older pre-standard version of C++11.
Your first attempt should be to figure out how to specify that your compiler uses a newer version of the STL library. You should be able to add -std=c++11 to the CMAKE C++ flags (instead of -std=c++0X). Whether this means editing the CMakeLists.txt file to include the flag or making sure that your compiler was installed with a more modern version of STL.
That should fix the problem. I can think of another solution, but I suspect that you will get more errors by linking to an older version of STL.
I'm trying to install a modified version of caffe as part of the installation of this library: https://github.com/wasidennis/ObjectFlow/tree/master/caffe-cedn-dev
I'm on ubuntu 14.04 and am using a cmake install as listed on the caffe website.
I've installed matlab & have the mex file in the path.
after cmake .. I do a make all and get this error:
Linking CXX executable caffe
../lib/libcaffe.a(io.cpp.o): In function `caffe::ReadImageToDatum(std::string const&, int, int, int, bool, caffe::Datum*)':
io.cpp:(.text+0x67d): undefined reference to `cv::imread(cv::String const&, int)'
../lib/libcaffe.a(window_data_layer.cpp.o): In function `caffe::WindowDataLayer<float>::InternalThreadEntry()':
window_data_layer.cpp:(.text._ZN5caffe15WindowDataLayerIfE19InternalThreadEntryEv[_ZN5caffe15WindowDataLayerIfE19InternalThreadEntryEv]+0x44b): undefined reference to `cv::imread(cv::String const&, int)'
../lib/libcaffe.a(window_data_layer.cpp.o): In function `caffe::WindowDataLayer<double>::InternalThreadEntry()':
window_data_layer.cpp:(.text._ZN5caffe15WindowDataLayerIdE19InternalThreadEntryEv[_ZN5caffe15WindowDataLayerIdE19InternalThreadEntryEv]+0x446): undefined reference to `cv::imread(cv::String const&, int)'
collect2: error: ld returned 1 exit status
make[2]: *** [tools/caffe] Error 1
make[1]: *** [tools/CMakeFiles/caffe.bin.dir/all] Error 2
make: *** [all] Error 2
Following https://github.com/BVLC/caffe/issues/1276 I looked at the output of pkg-config --cvflags opencv which is -I/usr/local/include/opencv -I/usr/local/include
This is the same location as the headers of my OpenCV installation are installed. (I'm not sure of the causal relationship on that.) Both OpenCV 3.1 and 2.4 go to those files - I tried installing both and to switch between them I just move the opencv and opencv2 header folders to a tmp folder while I use the other opencv. I think this might be the source of the error, as I don't know how to tell which version of OpenCV my program is using for sure.
More specifically I have done is:
I added opencv_imgcodecs to the Makefile
installed opencv via apt-get
uninstalled opencv via apt-get remove
installed a version of opencv that I don't remember the version
installed 3.1 & 2.4 from src & switched out the header folders as stated above.
Deleted a version of opencv src & header folders that I didn't know how to see what version it was.
From when I started checking, python import cv2 went from version 3.1 to now 3.2-dev.
I'm running a fedora 21 distribution, in which the default gcc is 4.9.
I have a custom built gcc/g++ 4.8 in /usr/local/gcc48 (for instance, cuda requires gcc =< 4.8, and i use update-alternatives to chose this one)
I have been compiling a few small programs with this version 4.8 without problem so far.
Now, I have been given a source code which makes uses of vtk libraries and others. If I use default gcc 4.9, cmake and make work fine.
However, when using gcc48, I get:
/usr/lib64/vtk/libvtkCommonDataModel.so.1: référence indéfinie vers « std::__throw_out_of_range_fmt(char const*, ...)#GLIBCXX_3.4.20 »
/lib64/libicuuc.so.52: référence indéfinie vers « __cxa_throw_bad_array_new_length#CXXABI_1.3.8 »
collect2: erreur: ld a retourné 1 code d'état d'exécution
CMakeFiles/main.dir/build.make:365: recipe for target '../bin/main' failed
make[2]: *** [../bin/main] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/main.dir/all' failed
make[1]: *** [CMakeFiles/main.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
I understand that is it a linker error, I tried to point LD_LIBRARY_PATH=/usr/local/gcc48/lib or LD_LIBRARY_PATH=/usr/local/gcc48/lib64, but i'm stuck.
What is the problem here ?
Thanks
__cxa_throw_bad_array_new_length was added in GCC 4.9. That's what the #CXXABI_1.3.8 version suffix means. You can look up those version codes here:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html
This error means that you are trying to link an object file /usr/lib64/vtk/libvtkCommonDataModel.so.1 compiled by GCC 4.9 or later with libstdc++.so or libsupc++.so from GCC 4.8 or earlier. Either rebuild libvtkCommonDataModel.so with GCC 4.8, or link against the correct libstdc++.so.
Edit:
Actually, if you want to compile with a newer version of GCC but run with an older libstdc++.so, that can be done.
Compile with -D_GLIBCXX_USE_CXX11_ABI=0 if you want to compile with GCC 5+ and run with libstdc++.so from older GCC. See https://bugzilla.mozilla.org/show_bug.cgi?id=1153109 and Using dual ABI in the libstdc++ manual.
Link against stdc++compat.cpp containing back-compat hacks from Mozilla. You can also take a look at my modified version which doesn't depend on any Mozilla headers, but it's slightly out of date.
In particular, this defines a stub __cxa_throw_bad_array_new_length.
It would be helpful if you post the error message in English.
It appears that the undefined symbol is __cxa_throw_bad_array_new_length. The functions __cxa... come from the C++ runtime library. G++ usually ships with it's own version of this library, called libsupc++. I would guess that the custom-built G++ can not find this library or is emitting a reference to a symbol which is not in the newer (4.9) libsupc++. Try compiling the libsupc++ source that ships with your custom version of G++ and directing the linker toward it. You may also need to do this for libstdc++.