我有一个如下所示的 C++ 项目,
-project/
-include/ --> .hpp files
-src/ --> .cpp files
-bin/ --> for output executable
-makefile
我的makefile如下,
g++ src/* -I include/ -o bin/program
当我运行 makefile
时,它在我的 Mac OS 上运行得很好。但是,我尝试使用我的 Ubuntu 编译它,但没有成功。我有以下错误,
src/SomeFileName.cpp:1:28: fatal error: SomeFileName.hpp: No such file or directory
compilation terminated.
src/main.cpp:1:28: fatal error: SomeFileName.hpp: No such file or directory
compilation terminated.
我应该专门为 Ubuntu 更改 makefile
的某些部分吗?有什么问题?
我的 ubuntu g++ 版本:
x@x:~$ g++ --version
g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
我的main.cpp如下,
#include "ListController.hpp"
#include <time.h>
int main() {
doStuff();
return 0;
}
最佳答案
我唯一可以假设的是,在您的 Mac 上,PATH
环境变量还包含 ./
因此,您可以尝试通过以下方式更改您的 makefile:
g++ ./src/* -I ./include/ -o ./bin/program
关于c++ - G++编译,mac os和ubuntu的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19890511/