Search code examples
c++mingwogre3dogre

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


Solution

  • 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.