【发布时间】:2013-07-10 20:44:25
【问题描述】:
我正在尝试使用 C++11,但 eclipse 遇到了一些问题。我使用 macports 来获取 gcc48,并遵循各种指南让 eclipse 使用新编译器,包括this、this、 而且我还将编译器命令从 eclipse 标准更改为 g++-mp-4.8,如 here
所述我正在尝试构建以下程序:
#include <iostream>
#include<memory>
using namespace std;
int main() {
std::unique_ptr<double> ptr(new double);
*ptr = 11.345;
cout << (*ptr) << endl;
return 0;
}
终端会编译这个很好,
make all
Building file: ../src/C++11.cpp
Invoking: Cross G++ Compiler
/opt/local/bin/g++ -I/opt/local/bin -I/opt/local/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -MMD -MP -MF"src/C++11.d" -MT"src/C++11.d" -o "src/C++11.o" "../src/C++11.cpp"
Finished building: ../src/C++11.cpp
Building target: C++11
Invoking: Cross G++ Linker
g++ -o "C++11" ./src/C++11.o
Finished building target: C++11
程序按预期运行。但是,在eclipse中,我仍然收到错误消息Symbol 'unique_ptr' could not be resolved。
我希望继续使用 eclipse,而不仅仅是项目经理和 makefile 构建器,因此我们将不胜感激!
【问题讨论】: