I want to enable debug version of libc++ in macOS, so I define _LIBCPP_DEBUG=1 in cxx_build_flags [Debug Version of libC++],
but unable to link debug function of libc++. I guess there is only release version of libc++ in my system, so how can I get the debug version of libc++ in macOS
Undefined symbols for architecture x86_64:
"std::__1::__libcpp_db::__decrementable(void const*) const", referenced from:
void std::__1::__nth_element<std::__1::__debug_less<std::__1::__less<float, float> >&, std::__1::__wrap_iter<float*> >(std::__1::__wrap_iter<float*>, std::__1::__wrap_iter<float*>, std::__1::__wrap_iter<float*>, std::__1::__debug_less<std::__1::__less<float, float> >&)
I think I got this to work!
So the steps I took,
Check your toolchains __config file for _LIBCPP_VERSION's value.
Browse the source repo for the commit where that version was set
From that commit, find the debug.cpp file
Include/compile/link the debug.cpp with your project (and remember to set _LIBCPP_DEBUG=1).
For me the intermediate results for the steps were (with Catalina, XCode Version 11.3.1)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__config was at version 8000
Looking at the history at https://github.com/llvm/llvm-project/commits/main?&path[]=libcxx&path[]=include&path[]=__config I found commit https://github.com/llvm/llvm-project/commit/25977548aa5ad7cfe45a17e4ba136abfa4613b96#diff-0a85f740cd20254bc3bb03975c89d93a
The debug.cpp for that commit is at https://github.com/llvm/llvm-project/blob/25977548aa5ad7cfe45a17e4ba136abfa4613b96/libcxx/src/debug.cpp
I try to reactivate this thread without an answer with more details.
I have the same issue. This is very easy to reproduce:
#include <string>
int main()
{
std::string name;
return 0;
}
and then compile with:
clang++ -D_LIBCPP_DEBUG=1 main.cpp
We obtain:
Undefined symbols for architecture x86_64:
"std::__1::__libcpp_db::__insert_c(void*)", referenced from:
void std::__1::__libcpp_db::__insert_c<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) in main-7ff3c5.o
"std::__1::__libcpp_db::__erase_c(void*)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string() in main-7ff3c5.o
"std::__1::__c_node::~__c_node()", referenced from:
std::__1::_C_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::~_C_node() in main-7ff3c5.o
"std::__1::__get_db()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string() in main-7ff3c5.o
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string() in main-7ff3c5.o
"typeinfo for std::__1::__c_node", referenced from:
typeinfo for std::__1::_C_node<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > in main-7ff3c5.o
"vtable for std::__1::__c_node", referenced from:
std::__1::__c_node::__c_node(void*, std::__1::__c_node*) in main-7ff3c5.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)
And if I use g++-9 providen by brew (a real g++ not a disguised Apple Clang compiler), it compiles and runs perfectly.
Forgetting to use debug mode of libc++, is it the only solution?
NB: I saw the same question in https://forums.developer.apple.com/thread/99194
and still no answer.
Related
When I try to convert my program to run in netanim I get the following error.
Undefined symbols for architecture arm64:
"ns3::AnimationInterface::SetConstantPosition(ns3::Ptr<ns3::Node>, double, double, double)", referenced from:
experiment(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in wifi-hidden-terminal.cc.16.o
"ns3::AnimationInterface::AnimationInterface(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
experiment(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in wifi-hidden-terminal.cc.16.o
"ns3::AnimationInterface::~AnimationInterface()", referenced from:
experiment(bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in wifi-hidden-terminal.cc.16.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Waf: Leaving directory `/Users/nithindeepkumar/Mtech/Wireless/ns-allinone-3.35/ns-3.35/build'
Build failed
-> task in 'wifi-hidden-terminal' failed with exit status 1 (run with -v to display more information)
The code I try to run is :
anim.SetConstantPosition(nodes.Get(0),1.0, 2.0 );
anim.SetConstantPosition(nodes.Get(1), 3.0 , 2.0 );
anim.SetConstantPosition(nodes.Get(2), 4.0, 2.0);
I am running ns3-3.35.
I'm trying to link id3lib statically to my XCode project.
I've found some answers in other threads suggesting to add as linker flags the full path to the .a file. This works but produces a huge number of errors:
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::copy(char*, unsigned long, unsigned long) const", referenced from:
dami::io::StringReader::readChars(unsigned char*, unsigned int) in libid3.a(tag_impl.o)
dami::convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ID3_TextEnc, ID3_TextEnc) in libid3.a(utils.o)
dami::io::StringReader::readChars(unsigned char*, unsigned int) in libid3.a(tag_parse_lyrics3.o)
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
ID3_TagImpl::IsV2Tag(ID3_Reader&) in libid3.a(tag_impl.o)
dami::mm::parse(ID3_TagImpl&, ID3_Reader&) in libid3.a(tag_parse_musicmatch.o)
dami::id3::v1::parse(ID3_TagImpl&, ID3_Reader&) in libid3.a(tag_parse_v1.o)
dami::lyr3::v1::parse(ID3_TagImpl&, ID3_Reader&) in libid3.a(tag_parse_lyrics3.o)
dami::lyr3::v2::parse(ID3_TagImpl&, ID3_Reader&) in libid3.a(tag_parse_lyrics3.o)
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
void std::__1::vector<ID3_Field*, std::__1::allocator<ID3_Field*> >::__push_back_slow_path<ID3_Field* const>(ID3_Field* const&) in libid3.a(frame_impl.o)
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::reserve(unsigned long) in libid3.a(tag.o)
std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>, std::__1::allocator<unsigned char> >::__grow_by_and_replace(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned char const*) in libid3.a(tag.o)
std::__1::basic_string<unsigned char, std::__1::char_traits<unsigned char>,
And so on. Again, googling suggests that the issue might be the fact the choice for standard library. Hence I tried to switch the C++ Standard Library field from "Compiler Default" to "libstdc++" (and I'm still getting the huge amount errors) or to "libc++" - and I'm getting way less errors, namely:
Undefined symbols for architecture x86_64:
"_compress", referenced from:
dami::io::CompressedWriter::flush() in libid3.a(io_decorators.o)
"_iconv", referenced from:
dami::convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ID3_TextEnc, ID3_TextEnc) in libid3.a(utils.o)
"_iconv_close", referenced from:
dami::convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ID3_TextEnc, ID3_TextEnc) in libid3.a(utils.o)
"_iconv_open", referenced from:
dami::convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, ID3_TextEnc, ID3_TextEnc) in libid3.a(utils.o)
"_uncompress", referenced from:
dami::io::CompressedReader::CompressedReader(ID3_Reader&, unsigned int) in libid3.a(io_decorators.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have no idea of how to solve this. If I remove the library full path as linker flag, everything seems to work, but the library is linked dynamically (which doesn't work for me). I'm on Mac OS X 10.10; id3lib was installed via homebrew (manual installation tests led to similar results).
Does anybody have a clue?
Thanks,
Daniele
Go to Link Binary With Libraries in project settings and link your project with system libraries libz (_compress, _uncompress) and libiconv ( _iconv, _iconv_close, _iconv_open).
I've managed to compile Swiften library for a iOS project, but now I'm having linking errors related to Boost library.
I've compiled Boost following these steps, the error I'm getting during linking is:
Undefined symbols for architecture arm64:
"vtable for boost::filesystem::detail::utf8_codecvt_facet", referenced from:
__GLOBAL__I_a in boost(path.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've read some articles which suggest including some compilation params, but not sure which params or where should I put them. I've also reached this thread with no solution. Anyone else faced this issue? Anyone succeeded compiling and running Swiften for iOS? Any tip on the right direction would be much appreciated.
UPDATE 1
It seems filesystem and program_options libs share utf8_codecvt_facet object, and one was overriding the other while building boost. Finally, I managed to compile the whole Swiften library, but when I try to use it I'm getting more linking errors :( I get this error when I declare a JID object on my main class:
Undefined symbols for architecture armv7:
"Swift::StringPrep::getPrepared(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
Swift::StringPrep::Profile)", referenced from:
Swift::JID::nameprepAndSetComponents(std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> > const&, std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > const&) in JID.o
I just downloaded assimp 3.0 library and build the required make files with cmake, then compiled and build the library itself the process was successfull (with little modification to StepFile.h),
my assimp header folder is located in:
/usr/local/include
and my libassimp.a is located in:
/usr/local/lib
however when i specify library and header files in my command line project and try to test my project i get the following error:
Undefined symbols for architecture x86_64:
"Assimp::Importer::Importer()", referenced from:
_main in main.o
"Assimp::Importer::~Importer()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
and when i add -lassimp to Other Linker Flags i get the following errors:
Undefined symbols for architecture x86_64:
"_crc32", referenced from:
_unzReadCurrentFile in libassimp.a(unzip.c.o)
"_get_crc_table", referenced from:
_unzOpenCurrentFile3 in libassimp.a(unzip.c.o)
"_inflate", referenced from:
Assimp::XGLImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
_unzReadCurrentFile in libassimp.a(unzip.c.o)
"_inflateEnd", referenced from:
Assimp::XGLImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
_unzCloseCurrentFile in libassimp.a(unzip.c.o)
"_inflateInit2_", referenced from:
Assimp::XGLImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(XGLLoader.cpp.o)
Assimp::BlenderImporter::InternReadFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, aiScene*, Assimp::IOSystem*) in libassimp.a(BlenderLoader.cpp.o)
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
_unzOpenCurrentFile3 in libassimp.a(unzip.c.o)
"_inflateReset", referenced from:
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.cpp.o)
"_inflateSetDictionary", referenced from:
Assimp::XFileParser::XFileParser(std::__1::vector<char, std::__1::allocator<char> > const&) in libassimp.a(XFileParser.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)
I had the same issue recently. The actual solution for me was to ensure that the project where I was using the compiled libassimp.a also linked to libz.dylib rather than turn assimp into a .dylib.
i rebuild assimp so that the makefile yields three library files namely libassimp.3.0.255.dylib libassimp.3.dylib libassimp.dylib, i included them in my project and it worked.
I've been pulling my hair out trying to link my iOS app with an arm64 library.
The library in question is Crypto++. I've tried both the precompiled fat library that's in the wiki : http://www.cryptopp.com/wiki/IOS_(Command_Line). I've tried compiling the library myself, but I keep getting link errors of the following kind:
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long, unsigned long)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) in libcryptopp.a(randpool.o)
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const*) in libcryptopp.a(modes.o)
The libcryptopp.a seems to be fine for armv7, but not for arm64 for some reason. If I exclude libcryptopp.a's 64 bit version from the linking process, it gives even more errors.
They both were compiled using -stdlib=libstdc++
What is going on?
(I need arm64 support because of tweak development reasons)
update sorry all - it turns out it was using the old libcryptopp.a, and not finding the libcryptopp.a properly. The .a was sourced from somewhere else, which has been fixed.
"std::__1::basic_string, std::__1::allocator >::__init(char const*, unsigned long, unsigned long)", referenced from: ... libcryptopp.a(randpool.o)
This library has been built, and depends on LLVM's C++ runtime libc++, and not GNU's C++ runtime libstdc++.
They both were compiled using -stdlib=libstdc++
You need to either rebuild libcryptopp.a against libstdc++, or link with -stdlib=libc++ (and build the rest of your code against libc++ as well).
If interested, the __1 is an inline namespace used for versioning. See What are inline namespaces for? and Where does the __1 symbol come from when using LLVM's libc++?.