I am trying to use yaml-cpp in my project. I am using cmake to build both my project and yaml-cpp which is a git submodule in my project.
I have the boost library on my computer (required by yaml-cpp).
I am building it statically. Using add_subdirectory in my main CMakeLists.txt then using target_link_libraries(components yaml-cpp) (component is a static library I am using on different modules of my project).
I have an error during the linking phase for one of my source files :
CMakeFiles/rsa-packer.dir/options/addObject.cpp.o : In function « YAML::detail::node& YAML::detail::node_data::get<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::shared_ptr<YAML::detail::memory_holder>) » :
~/git/apps/rsa-packer/options/addObject.cpp:(.text._ZN4YAML6detail9node_data3getINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERNS0_4nodeERKT_N5boost10shared_ptrINS0_13memory_holderEEE[_ZN4YAML6detail9node_data3getINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERNS0_4nodeERKT_N5boost10shared_ptrINS0_13memory_holderEEE]+0x157) : undefined reference to: « YAML::detail::node_data::convert_to_map(boost::shared_ptr<YAML::detail::memory_holder>) »
I checked the make output, there is the -lyaml-cpp option.
I checked the libyaml-cpp.a file, it contains the function (but I do not really understand the output of nm :
000000000000005d r .L__PRETTY_FUNCTION__._ZN4YAML6detail9node_data14convert_to_mapESt10shared_ptrINS0_13memory_holderEE
0000000000000940 T _ZN4YAML6detail9node_data14convert_to_mapESt10shared_ptrINS0_13memory_holderEE
The weird thing is :
// this works
YAML::Node node = YAML::Load(manifest.getStream());
// this does not work
if(node["objects"]) {
std::cout << "no objects" << std::endl;
}
I can build the node object using the YAML::Load function that works and is found in the static lib.
But I can't call node["..."] because the function is not found in the lib.
I have no idea what is causing this error.
I don't know if it can lead to problems, but I am compiling my project in C++14 and the yaml-cpp lib is built using c++11.
Thanks!
Ok, I was tired...
mongodb had already installed yaml-cpp on my computer. I was using the headers files from mongodb with the static library I just compiled from sources... The header was calling the function with boost::shared_ptr and my library was implemented using std::shared_ptr
Related
I am currently trying to compile a program using a library that I'm not very familiar with. When I run the compiler, I get the following output/error:
Undefined symbols for architecture x86_64:
"_cblas_ddot", referenced from:
shark::LDA::train(shark::LinearClassifier<shark::blas::vector<double> >&, shark::LabeledData<shark::blas::vector<double>, unsigned int> const&) in libshark.a(LDA.cpp.o)
shark::LDA::train(shark::LinearClassifier<shark::blas::vector<double> >&, shark::WeightedLabeledData<shark::blas::vector<double>, unsigned int> const&) in libshark.a(LDA.cpp.o)
My current idea is that this is from missing BLAS library, which I just downloaded and compiled (from fortran code?).
The command-line arg for compiling looks like thsi
g++ -o example -I/to/boost/include -I/to/shark/include -L/to/boost/lib -L/to/shark/lib -L/to/BLAS -lshark -lblas -l(boost_flags)
In /to/BLAS have a libblas.a, and I ran nm libblas.a which gives a line
libblas.a(ddot.o):
00000000000001c0 s EH_frame1
0000000000000000 T _ddot_
Without being too secure abut this, I assume that this means that the library does have the symbol, but without the _cblas_ prefix.
What can I do from this point? Can I change the symbols name? Or do I need to link this library with something else?
I use OS X Mavericks
Thanks in advance : )
OS X ships with BLAS (including cblas) already installed (it's part of the Accelerate.framework). There's no need to download and build your own. Just link with -lcblas.
Solution was as suggested by Logicrat, that I needed other files, I downloaded te source code from here and build it with cmake/make very seamless. Linking with the libraries that came from this resolved the issue.
I'm trying to compile a project (swac-record) that relies on qt, portaudio and FLAC. I'm on Mac OS X.
This is what I've got so far:
qmake swac-record-0.4 // This creates a Makefile at the same level as the project and .pro and .qrc files inside the project.
qmake swac-record-0.4/swac-record.pro // not sure what this does exactly
make // will compile the whole project
...but then compilation fails because some symbols cannot be resolved.
Undefined symbols for architecture x86_64:
"_FLAC__StreamDecoderErrorStatusString", referenced from:
DecoderFlac::error_callback(FLAC__StreamDecoderErrorStatus) in codec_flac.o
"_FLAC__StreamDecoderInitStatusString", referenced from:
DecoderFlac::decode(Channel&) in codec_flac.o
"_FLAC__metadata_object_new", referenced from:
EncoderFlac::setTag(Tag const&) in codec_flac.o
"_FLAC__metadata_object_vorbiscomment_append_comment", referenced from:
EncoderFlac::setTag(Tag const&) in codec_flac.o
"_FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair", referenced from:
EncoderFlac::setTag(Tag const&) in codec_flac.o
I don't really have experience with C++. Anyway, my understanding of it is that compilation fails because it cannot find the FLAC library.
The project's website says it uses Flac++ (libflac++-dev) and it is referenced like so in the code:
#include <FLAC++/decoder.h>
#include <FLAC++/encoder.h>
My questions then become:
How can I install libflac++? (Is it not included in flac already installed on the Mac?)
How can I link to libflac++?
I haven't had much luck researching this question (the closest I got is this question but I'm not using Xcode.)
EDIT: as ddriver's advised, I've built libflac myself and added it to the project.
Building libflac: I got the source code and compiled it using ./configure && make && make check && make install. As far as I can tell it went fine:
pkg-config --list-all | grep FLAC++
ls /usr/local/lib | grep FLAC
flac++ FLAC++ - Free Lossless Audio Codec Library (C++ API)
libFLAC++.6.dylib
libFLAC++.a
libFLAC++.dylib
libFLAC++.la
Adding it to the project:
I did so by editing swac-record.pro and adding the library like so (this thread helped):
INCLUDEPATH += /usr/local/lib
LIBS += -L"/usr/local/lib" -lFLAC++
However, I'm still getting the same Undefined symbols error. What did I miss?
im trying to compile a simple Ogre3d application using OIS; i override the function like so:
virtual bool keyPressed(const OIS::KeyEvent& arg);
However, i get linker errors like this:
CMakeFiles/thorium.dir/Application/Application.cpp.o:(.rodata._ZTVN7Thorium11ApplicationE[_ZTVN7Thorium11ApplicationE]+0x48): undefined reference to `Thorium::Application::keyPressed(OIS::KeyEvent const&)'
Ive added the library to my cmake as well as tried using a shared library but it also did not work. Im using the ois package and therefore havent compiled myself.
target_link_libraries(... OgreMain OIS.a)
Undefined reference error often occures when the library code not loaded.
Put libNAME.a file in lib searching path and compile modules with key
-lNAME
I'm writing in C++ under XCode 4.6 on Mountain Lion. I'm trying to add and use the Apache log4cxx library. I installed the library this morning via Brew. I'm linking against liblog4cxx.dylib. I'm getting a link error that just one symbol can't be found:
Undefined symbols for architecture x86_64:
"log4cxx::Logger::forcedLog(log4cxx::helpers::ObjectPtrT
const&, std::__1::basic_string,
std::__1::allocator > const&, log4cxx::spi::LocationInfo const&)
const", referenced from:
I know it's finding the library file because if I remove it, I get lots more undefined symbol errors relating to log4cxx.
relevant code is basically:
#include <log4cxx/logger.h>
static LoggerPtr logger(log4cxx::Logger::getLogger("foo.bar.Baz"));
void foo(int p1, int p2)
{
LOG4CXX_WARN(logger, "blah blah blah");
}
Creating the logger object inside the function, either as static or not, doesn't change the behavior. Also, linking with the static library, with or without defining LOG4CXX_STATIC in my project, does not change the behavior.
Looking at the macro I'm calling, I see that this symbol is the actual method that performs the log operation. If take out the logging call but leave in the code that defines the logger object, the code links fine as you might expect.
What do I need to do to have this last symbol resolve?
TIA!
I traced my issue down to compiling the library in a non C++11 compiler, but then my target project was a C++11 compiler.
I was able to compile log4cxx in a C+11 compiler by viewing the changes to log4cxx in the development git repo, which mainly consisted of inserting static_casts, as in this update:
http://apache-logging.6191.n7.nabble.com/C-11-does-not-allow-char-literals-with-highest-bit-set-unless-cast-td34908.html
I suppose the few incompatible routines came up undefined, which is why we were getting confused with only a few seemingly random undefines. (Or I was anyway)
I am trying to add Boost.Log to the Boost libraries using CMake, but I am having trouble when trying to link into my program.
I've added a wrapper around the Boost.Log and generated a shared library called libcls_utils.so. The Boost libraries (along with Boost.Log) appear to be built and generate all the .so files properly in the correct location, and so does libcls_utils.so.
When I try to link my file, I get the following error:
/media/data/workspace/mdxdev/tmp/staging/i686-mv-linux/usr/lib/libcls_utils.so: undefined reference to `boost::log_mt_posix::sinks::basic_text_file_backend::construct(boost::filesystem2::basic_path, std::allocator >, boost::filesystem2::path_traits> const&, std::_Ios_Openmode, unsigned long long, boost::function0 const&, bool)
As far as I can tell, I'm linking against all the correct libraries. Has anyone tried this before successfully? What am I doing wrong?
I am using CMake 2.8.8, Boost-1.49.0 and Boost.Log from the svn trunk.
You might need to define BOOST_LOG_DYN_LINK:
g++ -DBOOST_LOG_DYN_LINK blog.cpp -lboost_log -lpthread