0

如何将目录路径添加到 i386mingw-g++?我在 Linux 下工作。

当我尝试使用 i386mingw-g++ 交叉编译 .cpp 程序时,它不采用包含目录的路径。

在帮助中,它指示我使用该-B选项,但如果我使用它,我会收到此错误:

bash: syntax error near unexpected token `newline'
4

1 回答 1

0

you can add new directories to the include-search path by passing them to gcc/g++ using -I option. For Example:

# search for headers in the current directory
# as well as in in /usr/local/mingw/include 

i386mingw-g++ -I. -I/usr/local/mingw/include -c myfile.cpp -o myfile.o

If you're using makefiles to build your project you can look for a variable called CFLAGS or CXXFLAGS and add your include statements there. Most makefiles use these variables to store global compiler options.

There is a good makefile howto available at metalshell.

In addition the -B option you mention is defined as follows:

-Bprefix
This option specifies where to find the executables, libraries,
include files, and data files of the compiler itself.

As long as you're not using a hand-copied installation of gcc it should be able to find those files without explicit -B prefix_of_my_gcc_install.

Hope this helps.

于 2009-07-02T06:09:38.253 回答