How can I add a directory path to i386mingw-g++? I am working under Linux.
如何添加i386mingw-g ++的目录路径?我在Linux下工作。
When I try to cross-compile a .cpp program with i386mingw-g++, it does not take the path of the include directories.
当我尝试使用i386mingw-g ++交叉编译.cpp程序时,它不会采用包含目录的路径。
In the help, it instructs me to use the -B
option, but if I use that, I get this error:
在帮助中,它指示我使用-B选项,但如果我使用它,我会收到此错误:
bash: syntax error near unexpected token `newline'
1 个解决方案
#1
you can add new directories to the include-search path by passing them to gcc/g++ using -I option. For Example:
您可以使用-I选项将新目录传递给gcc / g ++,从而将新目录添加到包含搜索路径。例如:
# 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.
如果您正在使用makefile构建项目,则可以查找名为CFLAGS或CXXFLAGS的变量,并在其中添加include语句。大多数makefile使用这些变量来存储全局编译器选项。
There is a good makefile howto available at metalshell.
在metalshell上有一个很好的makefile howto。
In addition the -B option you mention is defined as follows:
另外你提到的-B选项定义如下:
-Bprefix
This option specifies where to find the executables, libraries,
include files, and data files of the compiler itself.-Bprefix此选项指定在何处查找编译器本身的可执行文件,库,包含文件和数据文件。
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.
只要您没有使用手动复制的gcc安装,它应该能够找到那些没有显式-B prefix_of_my_gcc_install的文件。
Hope this helps.
希望这可以帮助。
#1
you can add new directories to the include-search path by passing them to gcc/g++ using -I option. For Example:
您可以使用-I选项将新目录传递给gcc / g ++,从而将新目录添加到包含搜索路径。例如:
# 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.
如果您正在使用makefile构建项目,则可以查找名为CFLAGS或CXXFLAGS的变量,并在其中添加include语句。大多数makefile使用这些变量来存储全局编译器选项。
There is a good makefile howto available at metalshell.
在metalshell上有一个很好的makefile howto。
In addition the -B option you mention is defined as follows:
另外你提到的-B选项定义如下:
-Bprefix
This option specifies where to find the executables, libraries,
include files, and data files of the compiler itself.-Bprefix此选项指定在何处查找编译器本身的可执行文件,库,包含文件和数据文件。
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.
只要您没有使用手动复制的gcc安装,它应该能够找到那些没有显式-B prefix_of_my_gcc_install的文件。
Hope this helps.
希望这可以帮助。