适用于建筑x86_64的升压X code C ++命令行未定义的符号 [英] Boost Xcode C++ command line Undefined symbols for architecture x86_64
问题描述
我已经成功地得到提振按照说明书的此处。我现在需要创建一个命令行应用程序生成许可证。我继承了这个code和它使用的提振。我想我已经正确设置好一切,但是当我尝试建立我收到的x86_64架构在未定义的符号错误的一切使用boost。
我创建了一个命令行应用程序:
我添加了助推的路径:
我甚至试图改变C ++标准库的编译器:
下面是一些code,其中我引用Boost库:
的#include<升压/ DATE_TIME /了posix_time / posix_time_io.hpp>命名空间BG =的boost ::格利高;
命名空间BP =提振::了posix_time;
下面是错误的:
适用于建筑x86_64的未定义符号:
提振:: program_options :: to_internal(标准::字符串常量和放大器;),从引用:
的std ::矢量<标准::字符串,性病::分配器<标准::字符串> >提高:: program_options :: to_internal<标准::字符串>(的std ::矢量<标准::字符串,性病::分配器<标准::字符串>>常量和放大器;)在main.o中
提振:: program_options :: variables_map :: variables_map(),从引用:
在_main main.o中
的boost :: program_options :: options_description :: add_options(),从引用:
在_main main.o中
的boost :: program_options :: options_description :: m_default_line_length,从引用:
在_main main.o中
的boost :: program_options :: options_description :: options_description(标准::字符串常量和放大器;,为unsigned int,unsigned int类型),从引用:
在_main main.o中
提振:: program_options :: options_description_easy_init ::运算符()(字符常量*,提振:: program_options :: value_semantic常量*,字符常量*),从引用:
在_main main.o中
提振:: program_options :: options_description_easy_init ::运算符()(字符常量*,字符常量*),从引用:
在_main main.o中
提振:: program_options :: ARG,从引用:
提高:: program_options :: typed_value<的std ::字符串,字符> ::名称()在main.o中常量
提振:: program_options ::店(升压:: program_options :: basic_parsed_options<焦炭>常量和放大器;,提振:: program_options :: variables_map&放;,布尔),从引用:
在_main main.o中
\"boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::string,标准::字符串&gt;中的std ::字符串常量和放大器;&GT;),从引用:
boost::program_options::basic_command_line_parser<char>::extra_parser(boost::function1<std::pair<std::string,在main.o中);标准::字符串&gt;中的std ::字符串常量和放大器;&GT
\"boost::program_options::detail::cmdline::set_options_description(boost::program_options::options_description常量和放大器;),从引用:
boost::program_options::basic_command_line_parser<char>::options(boost::program_options::options_description常量和放大器;)在main.o中
提振:: program_options ::详细:: CMDLINE :: get_canonical_option_ preFIX(),从引用:
提高:: program_options :: basic_command_line_parser&LT;&烧焦GT; ::在main.o中的run()
提振:: program_options ::详细:: CMDLINE :: run()的从引用:
提高:: program_options :: basic_command_line_parser&LT;&烧焦GT; ::在main.o中的run()
提振:: program_options ::详细:: CMDLINE ::风格(INT),从引用:
提高:: program_options :: basic_command_line_parser&LT;&烧焦GT; ::风格(INT)在main.o中
提振:: program_options ::详细:: CMDLINE :: CMDLINE(性病::矢量&lt;标准::字符串,性病::分配器&LT;标准::字符串&GT;&GT;常量和放大器;),从引用:
提高:: program_options :: basic_command_line_parser&LT;&烧焦GT; :: basic_command_line_parser(INT,字符常量* const的*)在main.o中
提振:: program_options ::通知(升压:: program_options :: variables_map&安培;),从引用:
在_main main.o中
提振:: program_options ::验证(升压::任何和放;,的std ::矢量&lt;标准::字符串,性病::分配器&LT;标准::字符串&GT;&GT;常量和放大器;,的std :: string的*,INT),从引用:
提高:: program_options :: typed_value&LT;的std ::字符串,字符&GT; :: xparse(升压::任何和放;,的std ::矢量&lt;标准::字符串,性病::分配器&LT;标准::字符串&GT;&GT;常量和放大器;)常量在main.o中
提振:: program_options ::运算&LT;&LT;(的std :: ostream的和放;,提振:: program_options :: options_description常量和放大器;),从引用:
在_main main.o中
的boost :: program_options :: error_with_option_name :: get_canonical_option_name()const的,从引用:
在main.o中的boost :: program_options :: error_with_option_name :: get_option_name()const的
提振:: program_options :: value_semantic_ codecvt_helper&LT;焦炭&GT; ::解析(升压::任何和放;,的std ::矢量&lt;标准::字符串,性病::分配器&LT;标准::字符串&GT;&GT;常量和放大器;,布尔)常量,从引用:
虚函数表升压:: program_options :: typed_value&LT;的std ::字符串,字符&GT;在main.o中
所属类别升压:: program_options :: error_with_option_name,从引用:
所属类别升压:: program_options ::在main.o中required_option
所属类别升压:: program_options :: value_semantic_ codecvt_helper&LT;&烧焦GT;,从引用:
所属类别升压:: program_options :: typed_value&LT;的std ::字符串,字符&GT;在main.o中
从虚函数表升压:: program_options :: variables_map,引用:
提高:: program_options :: variables_map ::〜variables_map()在main.o中
注:缺少虚函数表通常意味着第一个非内联虚成员函数没有定义。
虚函数表升压:: program_options :: value_semantic_ codecvt_helper&LT;&烧焦GT;,从引用:
提高:: program_options :: value_semantic_ codecvt_helper&LT;&烧焦GT; ::在main.o中value_semantic_ codecvt_helper()
注:缺少虚函数表通常意味着第一个非内联虚成员函数没有定义。
LD:符号(S)未找到x86_64的架构
铿锵:错误:连接命令,退出code 1(使用-v看看调用)失败
有没有人用得到提振成功打造一个命令行应用程序?如果是,那么可以请你帮忙吗?
感谢您。
该问题可能是两个不同的问题造成的:
- 您还没有链接的库propertly:
在构建阶段选项卡,在链接二进制与libaries补充:
libboost_program_options.a
如果你想使用的libstdc ++,你应该推动建立这样的:
./ bootstrap.sh
./b2 CXXFLAGS = - STDLIB = ++的libstdcLINKFLAGS = - STDLIB = ++的libstdc
./b2安装 - preFIX = YOURINSTALLATIONDIRECTORY
和再使用的libstdc ++以x code。
I have successfully gotten boost to work in a test application by following the instructions here. I now need to create a command-line application to generate licenses. I've inherited this code and it uses boost. I think I've set everything up correctly but when I try to build I receive the Undefined symbols for architecture x86_64 error for everything using boost.
I created a command-line application:
I added the path for boost:
I even tried to change the C++ Standard Library compiler:
Here is some code where I am referencing the boost library:
#include <boost/date_time/posix_time/posix_time_io.hpp>
namespace bg = boost::gregorian;
namespace bp = boost::posix_time;
Here are the errors:
Undefined symbols for architecture x86_64:
"boost::program_options::to_internal(std::string const&)", referenced from:
std::vector<std::string, std::allocator<std::string> > boost::program_options::to_internal<std::string>(std::vector<std::string, std::allocator<std::string> > const&) in main.o
"boost::program_options::variables_map::variables_map()", referenced from:
_main in main.o
"boost::program_options::options_description::add_options()", referenced from:
_main in main.o
"boost::program_options::options_description::m_default_line_length", referenced from:
_main in main.o
"boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)", referenced from:
_main in main.o
"boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)", referenced from:
_main in main.o
"boost::program_options::options_description_easy_init::operator()(char const*, char const*)", referenced from:
_main in main.o
"boost::program_options::arg", referenced from:
boost::program_options::typed_value<std::string, char>::name() const in main.o
"boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)", referenced from:
_main in main.o
"boost::program_options::detail::cmdline::set_additional_parser(boost::function1<std::pair<std::string, std::string>, std::string const&>)", referenced from:
boost::program_options::basic_command_line_parser<char>::extra_parser(boost::function1<std::pair<std::string, std::string>, std::string const&>) in main.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 main.o
"boost::program_options::detail::cmdline::get_canonical_option_prefix()", referenced from:
boost::program_options::basic_command_line_parser<char>::run() in main.o
"boost::program_options::detail::cmdline::run()", referenced from:
boost::program_options::basic_command_line_parser<char>::run() in main.o
"boost::program_options::detail::cmdline::style(int)", referenced from:
boost::program_options::basic_command_line_parser<char>::style(int) in main.o
"boost::program_options::detail::cmdline::cmdline(std::vector<std::string, std::allocator<std::string> > const&)", referenced from:
boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*) in main.o
"boost::program_options::notify(boost::program_options::variables_map&)", referenced from:
_main in main.o
"boost::program_options::validate(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, std::string*, int)", referenced from:
boost::program_options::typed_value<std::string, char>::xparse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&) const in main.o
"boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)", referenced from:
_main in main.o
"boost::program_options::error_with_option_name::get_canonical_option_name() const", referenced from:
boost::program_options::error_with_option_name::get_option_name() const in main.o
"boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, bool) const", referenced from:
vtable for boost::program_options::typed_value<std::string, char> in main.o
"typeinfo for boost::program_options::error_with_option_name", referenced from:
typeinfo for boost::program_options::required_option in main.o
"typeinfo for boost::program_options::value_semantic_codecvt_helper<char>", referenced from:
typeinfo for boost::program_options::typed_value<std::string, char> in main.o
"vtable for boost::program_options::variables_map", referenced from:
boost::program_options::variables_map::~variables_map() in main.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"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 main.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)
Has anybody gotten a command-line application using boost to successfully build? If YES, then can you please help?
Thank you.
The problem may be caused for two different problems:
- You haven't linked the library propertly:
In "Build Phases" Tab, in "Link Binary with libaries" add: libboost_program_options.a
- Another problem is how have you compiled and linked the boost library when you installed the library.
If you want to use libstdc++ you should build boost like this:
./bootstrap.sh
./b2 cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++"
./b2 install --prefix=YOURINSTALLATIONDIRECTORY
And then use libstdc++ in xcode.
这篇关于适用于建筑x86_64的升压X code C ++命令行未定义的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!