[使用g ++包含来自其他文件夹的头文件

问题描述 投票:2回答:1

我正在尝试安装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. factorial.h ..我正在尝试使用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作为输入或类似内容...

我正在尝试安装FLTK库,并看到使用不同目录的头文件。因此,我尝试将其测试为:D:\ C ++ \ #include //自制头文件在...

c++ terminal header g++
1个回答
1
投票

您是否尝试使用斜杠代替反斜杠? /代替\吗?

© www.soinside.com 2019 - 2024. All rights reserved.