link fails with clang / llvm using g++ - c++

I'm trying to compile this .ccp file. I got it from https://github.com/loarabia/Clang-tutorial.
// This code is licensed under the New BSD license.
// See LICENSE.txt for more details.
#include <iostream>
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Host.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "clang/Frontend/DiagnosticOptions.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Frontend/CompilerInstance.h"
int main()
{
clang::DiagnosticOptions diagnosticOptions;
clang::TextDiagnosticPrinter *pTextDiagnosticPrinter =
new clang::TextDiagnosticPrinter(
llvm::outs(),
diagnosticOptions);
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> pDiagIDs;
//clang::DiagnosticIDs diagIDs;
clang::DiagnosticsEngine *pDiagnosticsEngine =
new clang::DiagnosticsEngine(pDiagIDs, pTextDiagnosticPrinter);
clang::LangOptions languageOptions;
clang::FileSystemOptions fileSystemOptions;
clang::FileManager fileManager(fileSystemOptions);
clang::SourceManager sourceManager(
*pDiagnosticsEngine,
fileManager);
clang::HeaderSearch headerSearch(fileManager, *pDiagnosticsEngine);
clang::TargetOptions targetOptions;
targetOptions.Triple = llvm::sys::getDefaultTargetTriple();
clang::TargetInfo *pTargetInfo =
clang::TargetInfo::CreateTargetInfo(
*pDiagnosticsEngine,
targetOptions);
clang::CompilerInstance compInst;
clang::Preprocessor preprocessor(
*pDiagnosticsEngine,
languageOptions,
pTargetInfo,
sourceManager,
headerSearch,
compInst);
return 0;
}
And I use g++ compile line like this:
g++ tutorial1.cpp -g -fno-rtti `llvm-config --cxxflags --ldflags --libs` -lclangBasic
-lclangLex -lclangDriver -lclangFrontend -lclangParse -lclangAST -lclangSema
-lclangAnalysis -I ../llvm/tools/clang/include/
-I/Users/scher/Documents/Projects/task/C/last_clang/llvm/include
-I/Users/scher/Documents/Projects/task/C/last_clang/build/include
-I/Users/scher/Documents/Projects/task/C/last_clang/build/tools/clang/include
But it fails with the following report:
Undefined symbols for architecture x86_64:
"clang::serialization::ModuleManager::lookup(llvm::StringRef)", referenced from:
clang::ASTUnit::TranslateStoredDiagnostics(clang::ASTReader*, llvm::StringRef, clang::SourceManager&, llvm::SmallVectorImpl<clang::StoredDiagnostic> const&, llvm::SmallVectorImpl<clang::StoredDiagnostic>&)in libclangFrontend.a(ASTUnit.o)
"clang::ASTWriter::ASTWriter(llvm::BitstreamWriter&)", referenced from:
clang::ASTUnit::serialize(llvm::raw_ostream&) in libclangFrontend.a(ASTUnit.o)
"clang::ASTWriter::WriteAST(clang::Sema&, clang::MemorizeStatCalls*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, clang::Module*, llvm::StringRef)", referenced from:
clang::ASTUnit::serialize(llvm::raw_ostream&) in libclangFrontend.a(ASTUnit.o)
"clang::ASTWriter::~ASTWriter()", referenced from:
clang::ASTUnit::serialize(llvm::raw_ostream&) in libclangFrontend.a(ASTUnit.o)
"clang::PCHGenerator::PCHGenerator(clang::Preprocessor const&, llvm::StringRef, clang::Module*, llvm::StringRef, llvm::raw_ostream*)", referenced from:
(anonymous namespace)::PrecompilePreambleConsumer::PrecompilePreambleConsumer(clang::ASTUnit&, clang::Preprocessor const&, llvm::StringRef, llvm::raw_ostream*)in libclangFrontend.a(ASTUnit.o)
"clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&)", referenced from:
(anonymous namespace)::PrecompilePreambleConsumer::HandleTranslationUnit(clang::ASTContext&)in libclangFrontend.a(ASTUnit.o)
"clang::ASTWriter::getDeclID(clang::Decl const*)", referenced from:
(anonymous namespace)::PrecompilePreambleConsumer::HandleTranslationUnit(clang::ASTContext&)in libclangFrontend.a(ASTUnit.o)
"clang::PCHGenerator::~PCHGenerator()", referenced from:
(anonymous namespace)::PrecompilePreambleConsumer::~PrecompilePreambleConsumer()in libclangFrontend.a(ASTUnit.o)
"vtable for clang::ASTReaderListener", referenced from:
clang::ASTReaderListener::ASTReaderListener()in libclangFrontend.a(ASTUnit.o)
"clang::ASTReaderListener::~ASTReaderListener()", referenced from:
(anonymous namespace)::ASTInfoCollector::~ASTInfoCollector()in libclangFrontend.a(ASTUnit.o)
"clang::PCHGenerator::GetASTMutationListener()", referenced from:
vtable for (anonymous namespace)::PrecompilePreambleConsumerin libclangFrontend.a(ASTUnit.o)
"clang::PCHGenerator::GetASTDeserializationListener()", referenced from:
vtable for (anonymous namespace)::PrecompilePreambleConsumerin libclangFrontend.a(ASTUnit.o)
"clang::serialization::ModuleManager::addInMemoryBuffer(llvm::StringRef, llvm::MemoryBuffer*)", referenced from:
clang::ASTReader::addInMemoryBuffer(llvm::StringRef&, llvm::MemoryBuffer*) in libclangFrontend.a(ChainedIncludesSource.o)
"clang::ASTReader::ASTReader(clang::Preprocessor&, clang::ASTContext&, llvm::StringRef, bool, bool)", referenced from:
clang::CompilerInstance::createPCHExternalASTSource(llvm::StringRef, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, clang::Preprocessor&, clang::ASTContext&, void*, bool)in libclangFrontend.a(CompilerInstance.o)
clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef<std::pair<clang::IdentifierInfo*, clang::SourceLocation> >, clang::Module::NameVisibilityKind, bool)in libclangFrontend.a(CompilerInstance.o)
clang::ASTUnit::LoadFromASTFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>, clang::FileSystemOptions const&, bool, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::PointerUnion<char const*, llvm::MemoryBuffer const*> >*, unsigned int, bool)in libclangFrontend.a(ASTUnit.o)
createASTReader(clang::CompilerInstance&, llvm::StringRef, llvm::SmallVector<llvm::MemoryBuffer*, 4u>&, llvm::SmallVector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, 4u>&, clang::ASTDeserializationListener*)in libclangFrontend.a(ChainedIncludesSource.o)
"clang::ASTReader::setDeserializationListener(clang::ASTDeserializationListener*)", referenced from:
clang::CompilerInstance::createPCHExternalASTSource(llvm::StringRef, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, clang::Preprocessor&, clang::ASTContext&, void*, bool)in libclangFrontend.a(CompilerInstance.o)
clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef<std::pair<clang::IdentifierInfo*, clang::SourceLocation> >, clang::Module::NameVisibilityKind, bool)in libclangFrontend.a(CompilerInstance.o)
createASTReader(clang::CompilerInstance&, llvm::StringRef, llvm::SmallVector<llvm::MemoryBuffer*, 4u>&, llvm::SmallVector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, 4u>&, clang::ASTDeserializationListener*)in libclangFrontend.a(ChainedIncludesSource.o)
"clang::ASTReader::ReadAST(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, clang::serialization::ModuleKind)", referenced from:
clang::CompilerInstance::createPCHExternalASTSource(llvm::StringRef, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, clang::Preprocessor&, clang::ASTContext&, void*, bool)in libclangFrontend.a(CompilerInstance.o)
clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef<std::pair<clang::IdentifierInfo*, clang::SourceLocation> >, clang::Module::NameVisibilityKind, bool)in libclangFrontend.a(CompilerInstance.o)
clang::ASTUnit::LoadFromASTFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>, clang::FileSystemOptions const&, bool, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::PointerUnion<char const*, llvm::MemoryBuffer const*> >*, unsigned int, bool)in libclangFrontend.a(ASTUnit.o)
createASTReader(clang::CompilerInstance&, llvm::StringRef, llvm::SmallVector<llvm::MemoryBuffer*, 4u>&, llvm::SmallVector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, 4u>&, clang::ASTDeserializationListener*)in libclangFrontend.a(ChainedIncludesSource.o)
"clang::ASTReader::makeModuleVisible(clang::Module*, clang::Module::NameVisibilityKind)", referenced from:
clang::CompilerInstance::loadModule(clang::SourceLocation, llvm::ArrayRef<std::pair<clang::IdentifierInfo*, clang::SourceLocation> >, clang::Module::NameVisibilityKind, bool)in libclangFrontend.a(CompilerInstance.o)
"clang::ASTReader::getOriginalSourceFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, clang::FileManager&, clang::DiagnosticsEngine&)", referenced from:
ParsePreprocessorArgs(clang::PreprocessorOptions&, clang::driver::ArgList&, clang::FileManager&, clang::DiagnosticsEngine&)in libclangFrontend.a(CompilerInvocation.o)
"clang::ASTDeserializationListener::~ASTDeserializationListener()", referenced from:
(anonymous namespace)::DelegatingDeserializationListener::~DelegatingDeserializationListener()in libclangFrontend.a(FrontendAction.o)
clang::MultiplexASTDeserializationListener::~MultiplexASTDeserializationListener()in libclangFrontend.a(MultiplexConsumer.o)
"vtable for clang::ASTDeserializationListener", referenced from:
clang::ASTDeserializationListener::ASTDeserializationListener()in libclangFrontend.a(FrontendAction.o)
clang::ASTDeserializationListener::ASTDeserializationListener()in libclangFrontend.a(MultiplexConsumer.o)
"clang::PCHGenerator::PCHGenerator(clang::Preprocessor const&, llvm::StringRef, clang::Module*, llvm::StringRef, llvm::raw_ostream*)", referenced from:
clang::GeneratePCHAction::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) in libclangFrontend.a(FrontendActions.o)
clang::GenerateModuleAction::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) in libclangFrontend.a(FrontendActions.o)
clang::ChainedIncludesSource::create(clang::CompilerInstance&) in libclangFrontend.a(ChainedIncludesSource.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I'd like to add that it occurs, when you add this clang::CompilerInstance compInst; line of code. Without this line it compiles normally.
Also I use clang/llvm 3.0, It was built using this tutorial http://clang.llvm.org/get_started.html
Any suggestions why it could fails?

You probably aren't listing the right libraries in the correct order. I don't know what the correct list is off the top of my head, but at the very least you're missing -lclangSerialization.

The order of libraries in the command line might be wrong. Try using the makefile given in the project - https://github.com/loarabia/Clang-tutorial/blob/master/makefile. Just copy the makefile to your directory and run make.

Related

How to link Boost Regex C++ on Mac from Source?

I have downloaded the whole Boost source from https://www.boost.org/doc/libs/1_72_0/libs/regex/doc/html/index.html and I have the instructions of installation:
tar -vcf boost_1_76_0.tar
./bootstrap.sh --with-toolset=clang --with-libraries=program_options,regex,filesystem,system
./b2
sudo ./b2 install
Then I got a message that everything has been successfully installed:
The following directory should be added to compiler include paths:
/Users/3omni/Documents/GitHub/PERSONAL/GEN/boost_1_76_0
The following directory should be added to linker library paths:
/Users/3omni/Documents/GitHub/PERSONAL/GEN/boost_1_76_0/stage/lib
Now, I have a code where I load the Boost regex header:
#include <boost/regex.hpp>
[More code...]
And now the problem is with library linking, I have tried to compile with:
gcc -I/Users/3omni/Documents/GitHub/PERSONAL/GEN/boost_1_76_0 -L/Users/3omni/Documents/GitHub/PERSONAL/GEN/boost_1_76_0/stage/lib -O3 -o readvcf readvcf.cc -lboost_regex
(Not sure if I should use -lboost_regex but that's something I found in the internet).
And this fails horribly with ...
Undefined symbols for architecture x86_64:
"std::logic_error::what() const", referenced from:
vtable for boost::wrapexcept<std::invalid_argument> in readvcf-3b61f4.o
vtable for boost::wrapexcept<std::logic_error> in readvcf-3b61f4.o
"std::runtime_error::what() const", referenced from:
vtable for boost::wrapexcept<std::runtime_error> in readvcf-3b61f4.o
vtable for boost::regex_error in readvcf-3b61f4.o
vtable for boost::wrapexcept<boost::regex_error> in readvcf-3b61f4.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
char* boost::re_detail_500::re_is_set_member<char*, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(char*, char*, boost::re_detail_500::re_set_long<unsigned int> const*, boost::re_detail_500::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, bool) in readvcf-3b61f4.o
std::__1::__wrap_iter<char const*> boost::re_detail_500::re_is_set_member<std::__1::__wrap_iter<char const*>, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(std::__1::__wrap_iter<char const*>, std::__1::__wrap_iter<char const*>, boost::re_detail_500::re_set_long<unsigned int> const*, boost::re_detail_500::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, bool) in readvcf-3b61f4.o
"std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(unsigned long, unsigned long, char const*, unsigned long) const", referenced from:
unsigned int boost::re_detail_500::find_sort_syntax<boost::re_detail_500::cpp_regex_traits_implementation<char>, char>(boost::re_detail_500::cpp_regex_traits_implementation<char> const*, char*) in readvcf-3b61f4.o
boost::re_detail_500::lookup_default_collate_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in readvcf-3b61f4.o
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
VCF2SNP(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, int) in readvcf-3b61f4.o
boost::re_detail_500::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_open_paren() in readvcf-3b61f4.o
boost::re_detail_500::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_alt() in readvcf-3b61f4.o
boost::re_detail_500::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_perl_extension() in readvcf-3b61f4.o
void boost::re_detail_500::named_subexpressions::set_name<char>(char const*, char const*, int) in readvcf-3b61f4.o
boost::re_detail_500::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_set_literal(boost::re_detail_500::basic_char_set<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >&) in readvcf-3b61f4.o
boost::re_detail_500::basic_regex_creator<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::create_startmaps(boost::re_detail_500::re_syntax_base*) in readvcf-3b61f4.o
...
"std::__1::__vector_base_common<true>::__throw_out_of_range() const", referenced from:
boost::re_detail_500::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_open_paren() in readvcf-3b61f4.o
boost::re_detail_500::basic_regex_parser<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::parse_perl_extension() in readvcf-3b61f4.o
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
boost::re_detail_500::cpp_regex_traits_char_layer<char>::init() in readvcf-3b61f4.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&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in readvcf-3b61f4.o
boost::re_detail_500::cpp_regex_traits_implementation<char>::lookup_classname(char const*, char const*) const in readvcf-3b61f4.o
boost::re_detail_500::cpp_regex_traits_implementation<char>::lookup_classname_imp(char const*, char const*) const in readvcf-3b61f4.o
boost::re_detail_500::cpp_regex_traits_implementation<char>::error_string(boost::regex_constants::error_type) const in readvcf-3b61f4.o
boost::re_detail_500::cpp_regex_traits_implementation<char>::lookup_collatename(char const*, char const*) const in readvcf-3b61f4.o
boost::re_detail_500::lookup_default_collate_name(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in readvcf-3b61f4.o
...
"std::__1::locale::has_facet(std::__1::locale::id&) const", referenced from:
boost::re_detail_500::cpp_regex_traits_base<char>::imbue(std::__1::locale const&) in readvcf-3b61f4.o
std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in readvcf-3b61f4.o
"std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
getAlleles(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::vector<bool, std::__1::allocator<bool> >, std::__1::allocator<std::__1::vector<bool, std::__1::allocator<bool> > > >&, int) in readvcf-3b61f4.o
VCF2SNP(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, int) in readvcf-3b61f4.o
std::__1::basic_filebuf<char, std::__1::char_traits<char> >::imbue(std::__1::locale const&) in readvcf-3b61f4.o
boost::re_detail_500::cpp_regex_traits_base<char>::imbue(std::__1::locale const&) in readvcf-3b61f4.o
boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const in readvcf-3b61f4.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in readvcf-3b61f4.o
std::__1::basic_filebuf<char, std::__1::char_traits<char> >::basic_filebuf() in readvcf-3b61f4.o
...
And much more. Up to:
_main in readvcf-3b61f4.o
std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_istringstream() in readvcf-3b61f4.o
virtual thunk to std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_istringstream() in readvcf-3b61f4.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 run out of ideas and I cannot find any solution. Please, any help would be really appreciated! Thank you in advance
You are using GCC to build a c++ program, so we get these linkage errors. The g++ tool is used to build a c++ program, it automatically adds the standard library linkage for you.
Can be fixed by
use g++
g++ -I/Users/3omni/Documents/GitHub/PERSONAL/GEN/boost_1_76_0 -L/Users/3omni/Documents/GitHub/PERSONAL/GEN/boost_1_76_0/stage/lib -O3 -o readvcf readvcf.cc -lboost_rege
use GCC with the additional option (Strongly not recommended)
gcc -x c++ -I/Users/3omni/Documents/GitHub/PERSONAL/GEN/boost_1_76_0 -L/Users/3omni/Documents/GitHub/PERSONAL/GEN/boost_1_76_0/stage/lib -O3 -o readvcf readvcf.cc -lboost_regex -lstdc++
Related question:undefined reference to __cxa_end_cleanup'

Issue installing openmp on mac using homebrew

I'm trying to use Openmp on my mac, but i'm getting a compiler error I don't understand. I installed openmp using
brew install llvm
When I try to compile my code using -fopenmp I get errors like this
Undefined symbols for architecture x86_64:
"std::runtime_error::what() const", referenced from:
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::runtime_error> > in ccOEbbPM.o
vtable for boost::exception_detail::error_info_injector<std::runtime_error> in ccOEbbPM.o
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::range_error> > in ccOEbbPM.o
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::overflow_error> > in ccOEbbPM.o
vtable for boost::exception_detail::error_info_injector<std::range_error> in ccOEbbPM.o
vtable for boost::exception_detail::error_info_injector<std::overflow_error> in ccOEbbPM.o
"std::locale::operator==(std::locale const&) const", referenced from:
boost::detail::lcast_put_unsigned<std::char_traits<char>, unsigned long long, char>::convert() in ccOEbbPM.o
"std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_not_of(char, unsigned long) const", referenced from:
boost::multiprecision::backends::cpp_int_backend<0u, 0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::allocator<unsigned long long> >::do_get_string[abi:cxx11](std::_Ios_Fmtflags, mpl_::bool_<false> const&) const in ccOEbbPM.o
"std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const", referenced from:
std::basic_ostream<char, std::char_traits<char> >& boost::multiprecision::operator<< <boost::multiprecision::backends::cpp_int_backend<0u, 0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::allocator<unsigned long long> >, (boost::multiprecision::expression_template_option)1>(std::basic_ostream<char, std::char_traits<char> >&, boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<0u, 0u, (boost::multiprecision::cpp_integer_type)1, (boost::multiprecision::cpp_int_check_type)0, std::allocator<unsigned long long> >, (boost::multiprecision::expression_template_option)1> const&) in ccOEbbPM.o
It's just a small segment of the error code since it goes on for quite a while, but I post the rest if need be. I also have the boost library installed.
Any help is appreciated, thanks.
EDIT:
Simple program that causes the error:
#include <iostream>
#include <omp.h>
using namespace std;
int main(){
int x = 5;
#pragma omp parallel
for(int y = 0; y < 50;y++){
x += 5;
}
cout << x << endl;
return 0;
}
Commands used to compile:
gcc-7 -fopenmp -Wall ex.cc
gcc-7 -std=c++11 -fopenmp -Wall ex.cc (I get less errors doing it this way)
Error when using the second compile command:
Undefined symbols for architecture x86_64:
"std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)
(std::basic_ostream<char, std::char_traits<char> >&))", referenced from:
_main in ccXt8Pa8.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(int)", referenced from:
_main in ccXt8Pa8.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccXt8Pa8.o
"std::ios_base::Init::~Init()", referenced from:
__static_initialization_and_destruction_0(int, int) in ccXt8Pa8.o
"std::cout", referenced from:
_main in ccXt8Pa8.o
"std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
_main in ccXt8Pa8.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
Use g++-7 rather than gcc-7, and all will be fine - it is C++ after all ;-)
g++-7 -std=c++11 -fopenmp openmp.cpp -o openmp

Linker error trying to embed v8

I am trying to make a simple program where I embed Google's V8 Javascript engine. The instructions seem straight forward, but I'm getting an odd link error.
I'm on Mac OS X 10.9, and I'm using Xamarin Studio as my IDE which appears to be using g++ as the compiler.
I compiled v8 using the instructions on their site. Specifically, after all the make dependencies, I ran:
make x64.release
This appeared to complete successfully.
Here's the output I'm getting when I try to build my project:
g++ -o "/Users/mike/Projects/vate/vate/bin/Debug/vate" "/Users/mike/Projects/vate/vate/bin/Debug/hello_world.o" -v -L"/Users/mike/Projects/v8/xcodebuild/Debug" -l"icudata" -l"icui18n" -l"v8_snapshot" -l"icuuc" -l"v8_libbase" -l"v8_base" -l"v8_libplatform"
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o /Users/mike/Projects/vate/vate/bin/Debug/vate -L/Users/mike/Projects/v8/xcodebuild/Debug /Users/mike/Projects/vate/vate/bin/Debug/hello_world.o -licudata -licui18n -lv8_snapshot -licuuc -lv8_libbase -lv8_base -lv8_libplatform -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"std::string::c_str() const", referenced from:
v8::internal::Logger::SharedLibraryEvent(std::string const&, unsigned long, unsigned long) in libv8_base.a(log.o)
"std::allocator::allocator()", referenced from:
v8::base::OS::GetSharedLibraryAddresses() in libv8_libbase.a(platform-macos.o)
"std::allocator::~allocator()", referenced from:
v8::base::OS::GetSharedLibraryAddresses() in libv8_libbase.a(platform-macos.o)
"std::basic_string, std::allocator >::basic_string(char const*, std::allocator const&)", referenced from:
v8::base::OS::GetSharedLibraryAddresses() in libv8_libbase.a(platform-macos.o)
"std::basic_string, std::allocator >::basic_string(std::string const&)", referenced from:
v8::base::OS::SharedLibraryAddress::SharedLibraryAddress(v8::base::OS::SharedLibraryAddress const&) in libv8_libbase.a(platform-macos.o)
v8::base::OS::SharedLibraryAddress::SharedLibraryAddress(std::string const&, unsigned long, unsigned long) in libv8_libbase.a(platform-macos.o)
"std::basic_string, std::allocator >::~basic_string()", referenced from:
v8::base::OS::SharedLibraryAddress::~SharedLibraryAddress() in libv8_base.a(log.o)
v8::base::OS::GetSharedLibraryAddresses() in libv8_libbase.a(platform-macos.o)
v8::base::OS::SharedLibraryAddress::~SharedLibraryAddress() in libv8_libbase.a(platform-macos.o)
"std::string::operator=(std::string const&)", referenced from:
v8::base::OS::SharedLibraryAddress::operator=(v8::base::OS::SharedLibraryAddress const&) in libv8_libbase.a(platform-macos.o)
"std::_Rb_tree_decrement(std::_Rb_tree_node_base*)", referenced from:
std::_Rb_tree_iterator >::operator--() in libv8_base.a(allocation-tracker.o)
std::_Rb_tree_iterator >::operator--() in libv8_base.a(lithium-codegen.o)
std::_Rb_tree_iterator::operator--() in libv8_base.a(verifier.o)
std::_Rb_tree_iterator::operator--() in libv8_base.a(instruction.o)
std::_Rb_tree_iterator >::operator--() in libv8_base.a(instruction-selector.o)
std::_Rb_tree_iterator::operator--() in libv8_base.a(typer.o)
std::_Rb_tree_iterator::operator--() in libv8_base.a(graph-visualizer.o)
...
"std::_Rb_tree_increment(std::_Rb_tree_node_base const*)", referenced from:
std::_Rb_tree_const_iterator >::operator++() in libv8_base.a(lithium.o)
std::_Rb_tree_const_iterator::operator++() in libv8_base.a(verifier.o)
std::_Rb_tree_const_iterator >::operator++() in libv8_base.a(instruction.o)
std::_Rb_tree_const_iterator::operator++() in libv8_base.a(typer.o)
std::_Rb_tree_const_iterator::operator++() in libv8_base.a(graph-visualizer.o)
"std::_Rb_tree_increment(std::_Rb_tree_node_base*)", referenced from:
std::_Rb_tree_iterator >::operator++() in libv8_base.a(allocation-tracker.o)
std::_Rb_tree_iterator >::operator++(int) in libv8_base.a(allocation-tracker.o)
"std::__throw_length_error(char const*)", referenced from:
std::vector >::_M_insert_aux(__gnu_cxx::__normal_iterator > >, v8::base::OS::SharedLibraryAddress const&) in libv8_libbase.a(platform-macos.o)
std::vector >::_M_insert_aux(__gnu_cxx::__normal_iterator > >, v8::internal::compiler::Reducer* const&) in libv8_base.a(pipeline.o)
std::vector >::_M_fill_insert(__gnu_cxx::__normal_iterator > >, unsigned long, v8::internal::compiler::Node* const&) in libv8_base.a(ast-graph-builder.o)
std::vector >::_M_insert_aux(__gnu_cxx::__normal_iterator > >, v8::internal::compiler::Node* const&) in libv8_base.a(ast-graph-builder.o)
std::vector >::_M_insert_aux(__gnu_cxx::__normal_iterator > >, v8::internal::compiler::FrameStateDescriptor* const&) in libv8_base.a(instruction.o)
std::vector >::_M_insert_aux(__gnu_cxx::__normal_iterator > >, v8::internal::compiler::Node* const&) in libv8_base.a(simplified-lowering.o)
std::vector >::reserve(unsigned long) in libv8_base.a(instruction-selector.o)
...
"std::__throw_out_of_range(char const*)", referenced from:
std::vector >::_M_range_check(unsigned long) const in libv8_base.a(graph-reducer.o)
std::vector >::_M_range_check(unsigned long) const in libv8_base.a(ast-graph-builder.o)
std::vector >::_M_range_check(unsigned long) const in libv8_base.a(verifier.o)
std::vector >::_M_range_check(unsigned long) const in libv8_base.a(verifier.o)
std::vector >::_M_range_check(unsigned long) const in libv8_base.a(graph-replay.o)
std::vector >::_M_range_check(unsigned long) const in libv8_base.a(js-context-specialization.o)
std::vector >::_M_range_check(unsigned long) const in libv8_base.a(graph-builder.o)
...
"std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:
std::_Rb_tree, std::_Select1st >, std::less, std::allocator > >::erase(std::_Rb_tree_iterator >) in libv8_base.a(allocation-tracker.o)
"std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:
std::_Rb_tree, std::_Select1st >, std::less, std::allocator > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair const&) in libv8_base.a(allocation-tracker.o)
std::_Rb_tree, v8::internal::Handle, std::_Identity >, std::less >, v8::internal::zone_allocator > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, v8::internal::Handle const&) in libv8_base.a(lithium-codegen.o)
std::_Rb_tree, std::less, v8::internal::zone_allocator >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, v8::internal::compiler::Node* const&) in libv8_base.a(verifier.o)
std::_Rb_tree, std::less, v8::internal::zone_allocator >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, int const&) in libv8_base.a(instruction.o)
std::_Rb_tree, std::_Select1st >, std::less, v8::internal::zone_allocator > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair const&) in libv8_base.a(instruction-selector.o)
std::_Rb_tree, std::less, v8::internal::zone_allocator >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, v8::internal::compiler::Node* const&) in libv8_base.a(typer.o)
std::_Rb_tree, std::less, v8::internal::zone_allocator >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, v8::internal::compiler::Node* const&) in libv8_base.a(graph-visualizer.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 a feeling that I compiled v8 wrong, or perhaps for a different compiler, but I can't find any way to customize that. Has anyone else seen this?
I have figured it out. I had two problems:
I was confused about which compiler I was actually using. On OSX, g++ is actually symlinked to clang++, so I needed to compile V8 using the Clang conventions, not g++
The instructions on compiling with clang on Google's page are incorrect, per this bug: https://code.google.com/p/v8/issues/detail?id=3072
For reference, to compile with clang, you need to configure your environment like this:
export CXX=`which clang++`
export CC=`which clang`
export CPP="`which clang` -E -std=c++11 -stdlib=libc++"
export LINK="`which clang++` -std=c++11 -stdlib=libc++"
export CXX_host=`which clang++`
export CC_host=`which clang`
export CPP_host="`which clang` -E"
export LINK_host=`which clang++`
export GYP_DEFINES="clang=1 mac_deployment_target=10.9"
You can then run your make whatever command as normal.
Obviously, requires that xcode be installed so that clang and clang++ exist.

Error on C++'s Hello World

I started learning C++ and I tried to run the classic Hello World program:
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello, World!";
return 0;
}
but when I compile it in terminal using GCC I always get that error:
Undefined symbols for architecture x86_64:
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const", referenced from:
std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccpe3DPY.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned long) const", referenced from:
std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in ccpe3DPY.o
"std::cout", referenced from:
_main in ccpe3DPY.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
_main in ccpe3DPY.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccpe3DPY.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in ccpe3DPY.o
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in ccpe3DPY.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
can you tell me why?
You've compiled your program with gcc, which is a C compiler, not a C++ compiler. Use g++ instead; it knows to include the C++ run-time libraries, where those missing symbols are defined.
Thats a C compiler you need to use a C++ compiler like rob says above g++. Also if you are a beginner I would highly recommend using Microsoft visual studio express if you run a windows OS; if not then netbeans.

c++ boost 1_46_1 on OSX 10.6.6. not linking

i downloaded c++ boost 1_46_1. unzipped it and followed the installation instructions.
i have tried to get a basic boost program to compile and link, but with no luck so far.
here it the boost program
#include <boost/program_options.hpp>
namespace po = boost::program_options;
#include <iostream>
#include <iterator>
using namespace std;
int main(int ac, char* av[])
{
try {
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
po::variables_map vm;
po::store(po::parse_command_line(ac, av, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
if (vm.count("compression")) {
cout << "Compression level was set to "
<< vm["compression"].as<int>() << ".\n";
} else {
cout << "Compression level was not set.\n";
}
}
catch(exception& e) {
cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
cerr << "Exception of unknown type!\n";
}
return 0;
}
here is my makefile
# compiler to use
CC = c++
INC = -I ~/usr/local/boost_1_46_1
#-I /usr/include/c++/4.2.1
LIB=-L~/usr/local/boost_1_46_1/stage/lib
#LIB =-Lusr/local/lib
#LIBNAME =-libboost_program_options.dylib
SOURCE = main.cpp
OUTPUT = out
all:
$(CC) $(INC) $(SOURCE) -o $(OUTPUT) -v $(LIB) -dynamic
here is the error i get
Using built-in specs. Target: i686-apple-darwin10 Configured with: /var/tmp/gcc/gcc-5664~89/src/configure
--disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/
--with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5664) /usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1plus
-quiet -v -I /Users/smith/usr/local/boost_1_46_1
-imultilib x86_64 -D__DYNAMIC__ main.cpp -fPIC -quiet -dumpbase main.cpp -mmacosx-version-min=10.6.6
-m64 -mtune=core2 -auxbase main -version -D__private_extern__=extern -o /var/folders/y7/y7wCKCc3HJWLBAK5YLrg5E+++TI/-Tmp-//ccumV5Oo.s ignoring nonexistent directory "/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../../i686-apple-darwin10/include" ignoring nonexistent directory "/Users/smith/usr/local/boost_1_46_1"
#include "..." search starts here:
#include <...> search starts here: /usr/include/c++/4.2.1 /usr/include/c++/4.2.1/i686-apple-darwin10/x86_64 /usr/include/c++/4.2.1/backward /usr/local/include /usr/lib/gcc/i686-apple-darwin10/4.2.1/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. GNU C++ version 4.2.1 (Apple Inc. build 5664) (i686-apple-darwin10) compiled by GNU C version 4.2.1 (Apple Inc. build 5664). GGC heuristics: --param ggc-min-expand=150
--param ggc-min-heapsize=131072 Compiler executable checksum: 35e7c8ac2c3562481c35a1833320fc34 /usr/libexec/gcc/i686-apple-darwin10/4.2.1/as
-arch x86_64 -force_cpusubtype_ALL -o /var/folders/y7/y7wCKCc3HJWLBAK5YLrg5E+++TI/-Tmp-//cce6AA55.o /var/folders/y7/y7wCKCc3HJWLBAK5YLrg5E+++TI/-Tmp-//ccumV5Oo.s /usr/libexec/gcc/i686-apple-darwin10/4.2.1/collect2
-dynamic -arch x86_64 -dynamic -macosx_version_min 10.6.6 -weak_reference_mismatches non-weak -o out -lcrt1.10.6.o
-L~/usr/local/boost_1_46_1/stage/lib -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64
-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64
-L/usr/lib/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1
-L/usr/lib/gcc/i686-apple-darwin10/4.2.1
-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.. /var/folders/y7/y7wCKCc3HJWLBAK5YLrg5E+++TI/-Tmp-//cce6AA55.o
-lstdc++ -lSystem -lgcc -lSystem ld: warning: directory '~/usr/local/boost_1_46_1/stage/lib' following -L not found Undefined symbols: "boost::program_options::operator<<(std::basic_ostream<char, std::char_traits<char> >&, boost::program_options::options_description const&)", referenced from:
_main in cce6AA55.o "vtable for boost::program_options::variables_map", referenced from:
boost::program_options::variables_map::~variables_map()in cce6AA55.o "boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>)", referenced from:
boost::program_options::basic_command_line_parser<char>::extra_parser(boost::function1<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>)in cce6AA55.o "typeinfo for boost::program_options::validation_error", referenced from:
typeinfo for boost::exception_detail::error_info_injector<boost::program_options::validation_error>in cce6AA55.o
typeinfo for boost::program_options::invalid_option_valuein cce6AA55.o "boost::program_options::detail::cmdline::cmdline(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)", referenced from:
boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*)in cce6AA55.o "boost::program_options::options_description_easy_init::operator()(char const*, char const*)", referenced from:
_main in cce6AA55.o "boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) const", referenced from:
vtable for boost::program_options::typed_value<int, char>in cce6AA55.o "boost::program_options::detail::cmdline::style(int)", referenced from:
boost::program_options::basic_command_line_parser<char>::style(int)in cce6AA55.o "boost::program_options::to_internal(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > boost::program_options::to_internal<std::basic_string<char, std::char_traits<char>, std::allocator<char> >
>(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)in cce6AA55.o "boost::program_options::notify(boost::program_options::variables_map&)", referenced from:
_main in cce6AA55.o "boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)", referenced from:
_main in cce6AA55.o "boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)", referenced from:
_main in cce6AA55.o "boost::program_options::arg", referenced from:
boost::program_options::typed_value<int, char>::name() constin cce6AA55.o
boost::program_options::typed_value<int, char>::name() constin cce6AA55.o "vtable for boost::program_options::value_semantic_codecvt_helper<char>", referenced from:
boost::program_options::value_semantic_codecvt_helper<char>::value_semantic_codecvt_helper()in cce6AA55.o
boost::program_options::value_semantic_codecvt_helper<char>::~value_semantic_codecvt_helper()in cce6AA55.o "typeinfo for boost::program_options::value_semantic_codecvt_helper<char>", referenced from:
typeinfo for boost::program_options::typed_value<int, char>in cce6AA55.o "boost::program_options::options_description::add_options()", referenced from:
_main in cce6AA55.o "boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const& boost::program_options::validators::get_single_string<char>(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool)in cce6AA55.o
std::basic_string<char, std::char_traits<char>, std::allocator<char> > const& boost::program_options::validators::get_single_string<char>(std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool)in cce6AA55.o "vtable for boost::program_options::validation_error", referenced from:
boost::program_options::validation_error::~validation_error()in cce6AA55.o
boost::program_options::validation_error::~validation_error()in cce6AA55.o
boost::program_options::validation_error::validation_error(boost::program_options::validation_error const&)in cce6AA55.o "boost::program_options::validation_error::what() const", referenced from:
vtable for boost::exception_detail::error_info_injector<boost::program_options::validation_error>in cce6AA55.o
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::validation_error>
>in cce6AA55.o
vtable for boost::exception_detail::error_info_injector<boost::program_options::invalid_option_value>in cce6AA55.o
vtable for boost::program_options::invalid_option_valuein cce6AA55.o
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::invalid_option_value>
>in cce6AA55.o "boost::program_options::variables_map::variables_map()", referenced from:
_main in cce6AA55.o "boost::program_options::options_description::options_description(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)", referenced from:
_main in cce6AA55.o "boost::program_options::detail::cmdline::run()", referenced from:
boost::program_options::basic_command_line_parser<char>::run() in cce6AA55.o "boost::program_options::invalid_option_value::invalid_option_value(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
void boost::program_options::validate<int, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, int*, long)in cce6AA55.o "boost::program_options::options_description::m_default_line_length", referenced from:
_main in cce6AA55.o
_main in cce6AA55.o "boost::program_options::detail::cmdline::set_options_description(boost::program_options::options_description const&)", referenced from:
boost::program_options::basic_command_line_parser<char>::options(boost::program_options::options_description const&)in cce6AA55.o "boost::program_options::validators::check_first_occurrence(boost::any const&)", referenced from:
void boost::program_options::validate<int, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, int*, long)in cce6AA55.o "boost::program_options::abstract_variables_map::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const", referenced from:
boost::program_options::variables_map::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) constin cce6AA55.o ld: symbol(s) not found collect2: ld returned 1 exit status make: *** [all] Error 1
You lack -lboost_program_options
all:
$(CC) $(INC) $(SOURCE) -o $(OUTPUT) $(LIB) -lboost_program_options -dynamic
you are providing linker with wrong path:
warning: directory '~/usr/local/boost_1_46_1/stage/lib' following -L not found
results in not linking your objects
The linker output includes the line:
ignoring nonexistent directory "/Users/smith/usr/local/boost_1_46_1"
so there is some mismatch between where you expect the libraries to be and where they actually are...