Add .so and .a libraries to Makefile

后端 未结 4 1595
南旧
南旧 2021-02-02 00:01

I have a makefile which looks like this .

DEFINES=-std=c++0x
INCS_GTK=-I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/include/atk-1.0 -I/usr/include/cairo         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 00:29

    Append -lYARP_OS -lYARP_sig -lYARP_math -lYARP_dev -lYARP_name -lYARP_init to LDLIBS.

    Warning: the linking order may matter.

    Also, be sure that the linker knows that /usr/local/lib is a place where to look for libraries, otherwise instruct it with -L/usr/local/lib (you could add another makefile variable, e.g. LIBPATHS or something similar, to contain the libraries paths).

    As a general synopsis, if you have a library libMyLib.a in folder /my/path, the gcc (or g++) can be invoked with the following parameters:

    gcc -L/my/path -lMyLib [...]
    
    • -L is used to include paths where the linker will look for libraries
    • -l is used to link a library, which must be passed without the lib prefix and the extension

    This question may be useful for a general understanding of libraries usage in C and C++: How to use Libraries

提交回复
热议问题