简体   繁体   English

Makefile错误

[英]error with makefile

I want to compile my C++ files with mingw-g++ in command prompt. 我想在命令提示符下使用mingw-g ++编译我的C ++文件。 My C++ files have OGRE3D libraries also. 我的C ++文件也有OGRE3D库。 How can I add these OGRE3D libaries in makefile. 如何在makefile中添加这些OGRE3D库。 For example after I compile my files in command prompt I get an error like this ; 例如,在命令提示符下编译文件后,出现如下错误: OgreEntity.h :No such file or directory OgreEntity.h:没有这样的文件或目录

To your g++, you should give options. 对于您的g ++,您应该提供选择。 Some useful options are: 一些有用的选项是:

  • -I/path/to/library/include This tells the compiler to look for library headers in this folder also -I/path/to/library/include这告诉编译器也在此文件夹中查找库头
  • -L/path/to/library/lib This tells the compiler to look for library's lib file. -L/path/to/library/lib这告诉编译器寻找库的lib文件。 For example, let's say it's called libBerzos.a 例如,假设它名为libBerzos.a
  • -lLibname This tells the compiler to which library it should link. -lLibname这告诉编译器应该链接到哪个库。 In the example above, you would write -lBarzos 在上面的示例中,您将编写-lBarzos

For example, let's say I have written a library myself named shSGL . 例如,假设我已经编写了一个名为shSGL的库。 I have the files in C:\\shSGL 我在C:\\ shSGL中有文件

Then if I want to compile a file using it, I would compile it like this: 然后,如果我想使用它来编译文件,则可以这样编译它:

g++ -c -o file.o file.cpp -IC:/shSGL/include

and build the executable with 并用构建可执行文件

g++ -o exec file.o -LC:/shSGL/lib -lshSGL

See this Makefile for a real example. 有关实际示例,请参见此Makefile

If you want to learn more about g++ options, just search for man g++ in google and the first site would be this . 如果您想了解有关g ++选项的更多信息,只需在google中搜索man g++ ,第一个网站就是this

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM