使用g++包含来自不同文件夹的头文件
Include header file from different folder using g++
我试图安装FLTK库,发现头文件使用了不同的目录。所以我试着把它测试为:
\check.cpp in D:C++
#include <factorial.h> // Self-made header file in folder D:C++link
#include <iostream>
int main(){
// Blah blah and call to factorial function from factorial.h
}
请注意:链接文件夹包含1。string.exe(一个简单的exe文件(2。阶乘…
我正在尝试使用Cygwin从*D:\C++*编译check.cpp作为:
g++ this.cpp -ID:C++link -o done.exe
当链接文件夹(D:\C++\link(中只有factorial.h时,编译成功完成并生成一个可执行文件。
但是,当同一目录中有另一个文件string.exe时,g++会尝试将exe文件作为输入。。。确切的编译错误如下:
In file included from
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/locale_classes.h:40:0,
from /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/bits/ios_base.h:41,
from /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/ios:42,
from /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/ostream:38,
from /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/include/c++/iostream:39,
from check.cpp:2:
D:C++link/string:1:3: error: stray ‘220’ in program
MZ□ □□ □ @ □ □ □ □!□L□!This program cannot be run in DOS mode.
^
D:C++link/string:1:5: error: stray ‘3’ in program
MZ□ □□ □ @ □ □ □ □!□L□!This program cannot be run in DOS mode.
^
D:C++link/string:1:9: error: stray ‘4’ in program
MZ□ □□ □ @ □ □ □ □!□L□!This program cannot be run in DOS mode.
据我猜测,使用-ID:\C++\link\试图将string.exe作为输入或类似的东西。。。
您尝试过使用斜杠而不是反斜杠吗?/
而不是?
我认为您看到的是编译器在调用时试图包含string.exeCCD_ 3在CCD_。
另外,将文件夹称为"链接"有点令人困惑,"包含"会是一个更好的名称。
看起来你正在使用MinGW-这可能会对你有所帮助:MinGW包括的路径
相关文章:
- 如何将更多文件夹添加到c++include路径
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 如何在文档文件夹中创建目录
- "assimp/config.h"找不到,但它在文件夹中
- C++入门 5 版:类消息和文件夹
- 我可以在 Arduino 的库文件夹之外安装库吗?
- 如何按文件扩展名引用文件夹中的文件
- 在QTreeView中仅显示共享驱动器和文件夹
- 加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
- 介子复制/安装头文件到输出目录并保持文件夹结构
- vcruntime.h 从 Windows 包含文件夹中丢失?
- 在文件夹迭代上实现 RAII
- 使用 Powershell 命令将 cpp 文件的文件夹编译为 GNU 的 g++
- 使文件夹中的所有文件可供所有项目(子目录)访问
- 无法使用 CMake 从其他文件夹添加源文件
- 如何在安卓工作室中将c ++头文件从一个文件夹导入到另一个文件夹?
- 对单元测试(googletest)和项目/文件夹/文件的混淆
- 设计文件夹/文件系统