【问题标题】:Netbeans Ubuntu C++ cannot find include files in release build but can in debugNetbeans Ubuntu C++ 在发布版本中找不到包含文件,但可以在调试中找到
【发布时间】:2015-11-16 17:47:21
【问题描述】:

在多年未使用 C/C++ 之后,我正在创建一个小型命令行 C/C++ 应用程序来将二进制文件转换为制表符分隔的文本文件。 Netbeans 对我来说也是新的。当我使用“调试”构建时,下面的包含文件工作正常,但使用“发布”时,我收到 IDE 错误“找不到包含文件”;文件和代码行都被标记。编译器错误是“没有这样的文件”或目录”。

我在工作空间中有其他应用程序可以使用发布选项卡集进行编译。

// these are the first code lines in the file    
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>

// No problem with these
#include <math.h>
#include <stdbool.h>

我没有注意到正确构建的应用程序和这个应用程序之间的属性有任何差异。

编辑:

我已经添加了包含的路径,/usr/include 用于 C 和 /usr/include/c++/4.9.2/ 用于 C++,(我还没有为其他应用程序这样做并且它们编译)并且发布包含的错误颜色从红色变为黄色,代码中只有两行有红色下划线。 size_type 和 npos 出现错误“无法找到标识符:

void replaceExt(std::string& s, const std::string& newExt) {

    std::string::size_type i = s.rfind('.', s.length()); // size_type

    if (i != std::string::npos) {                        //npos
        s.replace(i + 1, newExt.length(), newExt);
    }
}

编译器产生了这个错误信息:

gcc -m64   -c -g -I/usr/include/c++/4.9.2 -I/usr/include -MMD -MP -MF "build/Release/GNU-Linux-x86/main.o.d" -o build/Release/GNU-Linux-x86/main.o main.c
In file included from main.c:9:0:
/usr/include/c++/4.9.2/cstdlib:41:28: fatal error: bits/c++config.h: No such file or directory
 #include <bits/c++config.h>

最终编辑

NetBeans 没有标准包含的路径似乎不正确,因此我创建了一个新的 C++ 项目,接受所有默认首选项,并将除 main 之外的所有代码从失败的项目复制到新项目检查它是否会编译。最后我复制了 main ,发现它在发布和调试中都没有错误。

我不知道出了什么问题,但我找到了解决办法。

【问题讨论】:

    标签: gcc g++ netbeans-8 ubuntu-11.04


    【解决方案1】:

    NetBeans 没有标准包含的路径似乎不正确,因此我创建了一个新的 C++ 项目,接受所有默认首选项,并将除 main 之外的所有代码从失败的项目复制到新项目检查它是否会编译。最后我复制了 main ,发现它在 release 和 debug 中都没有错误。

    我不知道出了什么问题,但我找到了解决办法。

    【讨论】:

      猜你喜欢
      • 2019-12-13
      • 1970-01-01
      • 2021-08-19
      • 2015-11-18
      • 2017-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多