相关疑难解决方法(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万
查看次数

G ++&Clang ++ - 名称空间std _GLIBCXX_VISIBILITY(默认)

我正在尝试使用clang++冲突的命名空间来编译我的C++代码,但不断收到此错误.我的main.cpp文件是一个简单的Hello World程序(用于调试).

我有一种感觉问题是我在我的集​​群上编译的GCC或clang版本.关于如何追踪这个问题的任何想法?或者排除故障的步骤?

[aebrenne@hpc src]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/data/apps/gcc/4.8.1/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --with-gmp=/data/apps/gmp/5.1.2 --with-mpfr=/data/apps/mpfr/3.1.2 --with-mpc=/data/apps/mpc-1.0.1 --enable-threads=posix --with-as=/data/apps/binutils/2.23.2/bin/as --mandir=/data/apps/gcc/4.8.1/man --pdfdir=/data/apps/gcc/4.8.1/pdf --htmldir=/data/apps/gcc/4.8.1/html --enable-languages=c,c++,fortran,ada,go,java,lto,objc,obj-c++ --prefix=/data/apps/gcc/4.8.1
Thread model: posix
gcc version 4.8.1 (GCC) 

[aebrenne@hpc src]$ clang++ --version
clang version 3.4 (trunk 193367)
Target: x86_64-unknown-linux-gnu
Thread model: posix
[aebrenne@hpc src]$ 


[aebrenne@hpc src]$ cat main.cpp 
#include <iostream>

int main() {
    std::cout << "Starting test..." << std::endl;

    return 0;
}
[aebrenne@hpc src]$ clang++ -std=c++11 -Wall -g -I/data/apps/gcc/4.8.1/include/c++/4.8.1  main.cpp 
In file …
Run Code Online (Sandbox Code Playgroud)

c++ gcc namespaces clang++

7
推荐指数
2
解决办法
6197
查看次数

错误:名称空间'std'中的'mutex'未在gcc 4.6.2中命名类型

简单的程序就像这样

#include <iostream>       // std::cout
#include <thread>         // std::thread
#include <mutex>          // std::mutex

std::mutex mtx;           // mutex for critical section

int main ()
{
     return 0;
}
Run Code Online (Sandbox Code Playgroud)

尝试以下编译

$ /usr/local/Cellar/gcc46/4.6.4/bin/g++-4.6 -std=gnu++0x -I/usr/local/Cellar/gcc46/4.6.4/gcc/include/c++ -L/usr/local/Cellar/gcc46/4.6.4/gcc/lib temp_mutex.cpp 
temp_mutex.cpp:6:1: error: 'mutex' in namespace 'std' does not name a type
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我在Mac上编译.

c++ c++11 gcc4.6

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

标签 统计

c++ ×3

c++11 ×2

boost ×1

clang ×1

clang++ ×1

gcc ×1

gcc4.6 ×1

libc++ ×1

namespaces ×1