c++ - 一个简短的 c++ 文件和 makefile : I can make in the shell,,但在 Eclipse 中构建它时出现很多错误

标签 c++ eclipse makefile

我正在使用makefile编译一个非常短的c++文件。该c++文件使用名为ClanLib的外部库,但这不是重点,因为我可以使用“make”命令在shell中编译它,所以c++文件并且 makefile 都正常。

#include <ClanLib/core.h>
#include <ClanLib/application.h>

class ConsoleProgram {
public:
    static int main(const std::vector<CL_String> &args);
};
CL_ClanApplication app(&ConsoleProgram::main);
int ConsoleProgram::main(const std::vector<CL_String> &args) {
    CL_SetupCore setup_core;
    CL_ConsoleWindow console_window("Console");
    CL_Console::write_line("Hello World!");
    CL_Console::wait_for_key();
    return 0;
}




BIN     = main
OBJF    = main.o
LIBS    = clanCore  clanDisplay  clanGL  clanGL1  clanApp clanSWRender
VERSION = 2.3

PACKAGES = $(patsubst %, %-$(VERSION), $(LIBS))
INCLUDE += -I/usr/include/ClanLib-2.3/ 
CXXFLAGS += $(INCLUDE) `pkg-config --cflags $(PACKAGES)` -pthread

all: $(BIN)

$(BIN): $(OBJF)
    $(CXX) $(CXXFLAGS) $(OBJF) -o $(BIN) `pkg-config --libs $(PACKAGES)`

clean:
    find . -name '*.o' -type f -print -exec rm -rf {} \;
    rm -f $(BIN)

%.o : %.cpp
    $(CXX) $(CXXFLAGS) -c $< -o $@

%.o : %.hpp
    $(CXX) $(CXXFLAGS) -c $< -o $@

但是我在 Eclipse 中编译它时遇到了很多错误,我从早上就开始谷歌搜索,但没有任何线索。

/usr/include/ClanLib-2.3/ClanLib/Core/Crypto/aes128_decrypt.h:116:2: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
In file included from /usr/include/ClanLib-2.3/ClanLib/core.h:217:0,
                 from main.cpp:1:
/usr/include/ClanLib-2.3/ClanLib/Core/Crypto/aes192_encrypt.h:114:2: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
In file included from /usr/include/ClanLib-2.3/ClanLib/core.h:218:0,
                 from main.cpp:1:
/usr/include/ClanLib-2.3/ClanLib/Core/Crypto/aes192_decrypt.h:116:2: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
In file included from /usr/include/ClanLib-2.3/ClanLib/core.h:219:0,
                 from main.cpp:1:
/usr/include/ClanLib-2.3/ClanLib/Core/Crypto/aes256_encrypt.h:114:2: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
In file included from /usr/include/ClanLib-2.3/ClanLib/core.h:220:0,
                 from main.cpp:1:
/usr/include/ClanLib-2.3/ClanLib/Core/Crypto/aes256_decrypt.h:116:2: error: ‘shared_ptr’ in namespace ‘std’ does not name a type
make: *** [main.o] Error 1

任何线索或建议将不胜感激。

我使用的是 Fedora 17 x86_64、eclipse indigo。

最佳答案

您需要将 std=c++0x 添加到 g++ 编译器标志中才能获取 std::shared_ptr

关于c++ - 一个简短的 c++ 文件和 makefile : I can make in the shell,,但在 Eclipse 中构建它时出现很多错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12329226/

相关文章:

c++ - 链表上的 Ostream 重载运算符

c++ - 在 boost::asio 异步模式下创建和接受套接字时可以使用 boost::shared_ptr 吗?

java - 使用 EclEmma 和 Eclipse 获取 "no coverage data has been collected"消息

c - 我如何更改我的 makefile 以进行调试构建?

go - "make: go: command not found"- 尽管 go 二进制文件在 $PATH 中

c# - 尝试读取或写入 protected 内存。导入到 C# 的 C++ dll

c++ - 将非引用变量分配给返回引用的函数,反之亦然

c++ - 执行格式错误 Eclipse CDT

java - 如何将我的项目转换回 IntelliJ 项目?

linux - 如何修复linux下编译错误