相关疑难解决方法(0)

为什么不能用c ++ 0x模式中的libc ++来链接这个boost :: program_options示例?

编译boost :: program_options的示例代码:http://svn.boost.org/svn/boost/trunk/libs/program_options/example/first.cpp

...在MacOS Lion(10.7.2)上,使用随MacPorts安装的boost-1.48.0:

$ clang++ -v
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
$ clang++ -std=c++0x --stdlib=libc++ -lc++ -I/opt/local/include -L/opt/local/lib -lboost_program_options first.cpp -o first
Undefined symbols for architecture x86_64:
  "boost::program_options::options_description::options_description(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, unsigned int)", referenced from:
      _main in cc-6QQcwm.o
  "boost::program_options::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, boost::program_options::options_description const&)", referenced from:
      _main in cc-6QQcwm.o
  "boost::program_options::abstract_variables_map::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      boost::program_options::variables_map::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const in …
Run Code Online (Sandbox Code Playgroud)

c++ boost clang c++11 libc++

64
推荐指数
1
解决办法
2万
查看次数

当内联命名空间存在时,如何显式引用封闭命名空间?

请考虑以下代码:

#include <iostream>

namespace Foo{

    void ool()  // Version A
    {
        std::cout << "Foo::ool" << std::endl;
    }

    inline namespace Bar{
        void ool() // Version B
        {
            std::cout << "Foo::Bar::ool" << std::endl;
        }
    }
}


int main()
{
    Foo::ool();  // <- error
}
Run Code Online (Sandbox Code Playgroud)

Clang和G ++都正确地标记Foo::ool为含糊不清.我可以Foo::Bar::ool毫无问题地打电话但有没有办法在不改变声明的情况下调用版本A?

我发现处于类似位置的人试图了解会发生什么,但我没有看到这种情况的解决方案.

我处于这种情况,因为我有一个项目,其中包含一个声明,std::__1::pairstd::pair在不同的地方,std::__1作为内联命名空间.我需要代码std::pair明确指向.有解决方案吗?

c++ namespaces c++11 inline-namespaces

24
推荐指数
2
解决办法
830
查看次数

__1符号来自何处使用LLVM的libc ++?

在IOS 64位项目中,我看到了大量的问题,如Apple Mach-O Linker(Id)错误cryptopp中的未定义符号.问题通常描述为:

Undefined symbols for architecture i386:
  "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from:
      cv::gpu::error(char const*, char const*, int, char const*) in opencv2(gpumat.o)
Run Code Online (Sandbox Code Playgroud)

问题通常会减少到混合/匹配-stdlib=libc++(LLVM C++运行时)和-stdlib=libstdc++(GNU C++运行时).LLVM的C++运行时(libc++)具有__1装饰符号,但GNU C++运行时libstdc++ 缺少__1在其名称符号.它会导致符号显示具有相同名称的链接器问题(如std::string).

__1使用LLVM的libc ++时,符号来自何处?

为什么这个问题不是一个解决gnu命名和llvm命名空间?


这是一个相关的问题:libc ++ - 停止std重命名为std :: __ 1?.但它有点忽略了重命名不会发生的重点.

c++ symbols libstdc++ libc++

9
推荐指数
1
解决办法
3917
查看次数

标签 统计

c++ ×3

c++11 ×2

libc++ ×2

boost ×1

clang ×1

inline-namespaces ×1

libstdc++ ×1

namespaces ×1

symbols ×1