一个简短的c++文件和makefile:我可以在shell中制作,但在Eclipse中构建它时会遇到很多错误
A short c++ file and makefile: I can make in the shell, but get lots of error while building it in the Eclipse
我正在使用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 $@
但我在日食中编译它时遇到了很多错误,我从早上开始就在谷歌上搜索,但没有任何线索。
/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,黯然失色的靛蓝。
您需要将std=c++0x
添加到g++编译器标志中才能获得std::shared_ptr
。
相关文章:
- 代码在main()中运行,但在函数中出现错误
- 链接阶段在Ubuntu上失败,但在MacOS上失败
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- c++17文件系统::recursive_directory迭代器()在mac上没有给出这样的目录,但在windows上
- 断言中的Fold表达式在某些计算机上编译,但在其他计算机上不编译
- 从 eclipse IDE 运行工作正常,但在从终端运行时终止
- 生成可执行文件时找不到文件,但在eclipse c 中运行正常
- Eclipse 在检查语法时看不到包含文件,但在构建或运行应用程序时会看到
- 在 C++ Eclipse 中未定义对(错误)的引用,但在 Visual Studio 2015 中工作
- 为什么我的 c++ 程序在 Eclipse 中没有输出而终止,但在 Visual Studio 中工作
- 一个简短的c++文件和makefile:我可以在shell中制作,但在Eclipse中构建它时会遇到很多错误
- 钻石继承方案在 G++ 中编译良好,但在 VC++/Eclipse 中产生警告/错误
- 代码可以运行,但不在 Eclipse 中显示结果。
- 无法在Eclipse中运行SDL程序,但可以在Windows资源管理器中运行
- OpenCV - C++ 代码在 Eclipse 中运行,但不在终端中运行
- Eclipse ADT "undefined reference to (custom class)",但在 Xcode 中工作正常(使用 Cocos2dx)
- Libpcap的例子不工作,但项目在eclipse中构建
- wxWidget应用程序没有错误,但在Eclipse中可以很好地工作
- 非常奇怪的行为:我的c++程序突然退出,但它在Eclipse CDT的调试模式下完美地运行到了最后
- Eclipse c++ 库在调试模式下找不到,但在发布模式下找到