Mac OS 下g++(c++)编译工具无法使用
2015-04-16 16:32
197 查看
最近在Mac OS上做C++ 开发,却遇到一个让人难以费解的问题。g++工具无法编译c++源码,提示找不到__debug文件(这个文件我也不知道是做什么用的,有知道的希望各位高手们能指点一下)。其实源码很简单,就是简单的Hell World。
#include<iostream>
using namespace std;
int main(){
cout << "Hello World!" << endl;
return 0;
}
kevindeMacBook-Air:namespace kevin$ g++ hello.cpp
In file included from hello.cpp:1:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iostream:38:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ios:216:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__locale:15:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:604:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iterator:341:10: fatal error: '__debug' file not found
#include <__debug>
^
1 error generated.
发现上述问题后,baidu了the question,但是没有结果。然后在google上找到了一个凑效的解决方法(但作者没有说明解决的缘由)
kevindeMacBook-Air:namespace kevin$
echo '#define _LIBCPP_ASSERT(x, m) ((void)0)' | sudo tee -a
/Library/Developer/CommandLineTools/usr/include/c++/v1/__debug > /dev/null
Password:
kevindeMacBook-Air:namespace kevin$ g++ hello.cpp
kevindeMacBook-Air:namespace kevin$ ./a.out
Hello World!
感觉作者是创建了一个__debug 文件并在其中写入了相应的内容,但是如果是这样的话,那g++工具在安装的时候就没有这个文件吗?实在不明白怎么回事。 这里只把一种解决方法贴出来,希望能帮到跟我一样的人。如果有人知道这个方法的原理,烦请告知,不胜感激
#include<iostream>
using namespace std;
int main(){
cout << "Hello World!" << endl;
return 0;
}
kevindeMacBook-Air:namespace kevin$ g++ hello.cpp
In file included from hello.cpp:1:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iostream:38:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ios:216:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__locale:15:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:604:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iterator:341:10: fatal error: '__debug' file not found
#include <__debug>
^
1 error generated.
发现上述问题后,baidu了the question,但是没有结果。然后在google上找到了一个凑效的解决方法(但作者没有说明解决的缘由)
kevindeMacBook-Air:namespace kevin$
echo '#define _LIBCPP_ASSERT(x, m) ((void)0)' | sudo tee -a
/Library/Developer/CommandLineTools/usr/include/c++/v1/__debug > /dev/null
Password:
kevindeMacBook-Air:namespace kevin$ g++ hello.cpp
kevindeMacBook-Air:namespace kevin$ ./a.out
Hello World!
感觉作者是创建了一个__debug 文件并在其中写入了相应的内容,但是如果是这样的话,那g++工具在安装的时候就没有这个文件吗?实在不明白怎么回事。 这里只把一种解决方法贴出来,希望能帮到跟我一样的人。如果有人知道这个方法的原理,烦请告知,不胜感激
相关文章推荐
- 使用pl/sql developer开发工具无法编译存储过程,触发器,包等程序文件
- 使用pl/sql developer开发工具无法编译存储过程,触发器,包等程序文件
- MAC OS下Qt SDK1.2安装后出现g++-4.2问题无法编译
- aix 使用g++编译c++程序的编译选项 -- linux到aix移植经验
- 使用Editplus和MinGW的g++配置C++的编译运行环境
- C++ -> Ubuntu 10.04下,使用g++编译C++源程序
- C++ -> 在Window7 命令行下使用微软编译工具 cl.exe
- C++ -> 在Window7 命令行下使用微软编译工具 cl.exe
- 基于C++自动化编译工具的使用详解
- C++ -> 在Window7 命令行下使用微软编译工具 cl.exe
- 使用g++编译C/C++程序,链接时出现undefined reference to错误
- g++ 编译链接C++代码, 生成与使用静态库和动态库
- g++ 编译链接C++代码, 生成与使用静态库和动态库
- 使用G++编译运行c++(by命令行)
- linux下使用g++编译包含多个库的c++的方法
- Python游戏服务器开发日记(四)scons编译工具、C和C++混合使用
- 使用 Android NDK 的交叉编译工具链移植 C/C++ 项目到安卓平台
- 使用 Android NDK 的交叉编译工具链移植 C/C++ 项目到安卓平台
- Android开发-工具:Android Studio 怎么添加使用第三方jar包及无法编译的问题解决方法
- Linux 环境下使用g++编译C++