【问题标题】:G++ compilation, difference between mac os and ubuntuG++编译,mac os和ubuntu的区别
【发布时间】:2013-11-10 13:55:13
【问题描述】:

我有一个 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;
}

【问题讨论】:

  • 为什么要投反对票?请至少发表评论。
  • 您能否提供来自main.cpp#include
  • 我的猜测:区分大小写? Linux 对文件名区分大小写!
  • @Thrustmaster 如果我没记错的话,MacOS 也区分大小写。
  • @Alex,刚刚提供了原始问题的内容。

标签: c++ ubuntu makefile g++


【解决方案1】:

我能想到的唯一一件事是,在您的 Mac 上,PATH 环境变量还包含 ./

因此,您可以尝试通过以下方式更改您的 makefile:

g++ ./src/* -I ./include/ -o ./bin/program

【讨论】:

  • 我刚试过,不行。同样的错误。我试图在另一台 Windows 机器上做同样的事情,它也适用于 Windows。但仍然无法在 ubuntu 上运行。
猜你喜欢
  • 2018-05-09
  • 2019-06-08
  • 1970-01-01
  • 2014-02-18
  • 2013-11-23
  • 1970-01-01
  • 2012-09-30
  • 2022-11-01
  • 1970-01-01
相关资源
最近更新 更多