简体   繁体   中英

error with makefile

I want to compile my C++ files with mingw-g++ in command prompt. My C++ files have OGRE3D libraries also. How can I add these OGRE3D libaries in makefile. For example after I compile my files in command prompt I get an error like this ; OgreEntity.h :No such file or directory

To your g++, you should give options. Some useful options are:

  • -I/path/to/library/include This tells the compiler to look for library headers in this folder also
  • -L/path/to/library/lib This tells the compiler to look for library's lib file. For example, let's say it's called libBerzos.a
  • -lLibname This tells the compiler to which library it should link. In the example above, you would write -lBarzos

For example, let's say I have written a library myself named shSGL . I have the files in 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.

If you want to learn more about g++ options, just search for man g++ in google and the first site would be this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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