How to merge libraries in linux

36 Views Asked by At

Recently I wanted to build a game engine using C++ and glfw3. I want to create a static library libengine.a and link it with libglfw3.a and its dependencies. My question is how can I replace this:

# add paths. use pkg-config --static --libs glfw3 to 
# find libraries for your specific system
glfw_libs:=\
        /usr/local/lib/libglfw3.a\
        /usr/lib/x86_64-linux-gnu/librt.a\
        /usr/lib/x86_64-linux-gnu/libm.a\
        /usr/lib/x86_64-linux-gnu/libdl.a\
        /usr/lib/x86_64-linux-gnu/libX11.a\
        /usr/lib/x86_64-linux-gnu/libpthread.a\
        /usr/lib/x86_64-linux-gnu/libxcb.a\
        /usr/lib/x86_64-linux-gnu/libXau.a\
        /usr/lib/x86_64-linux-gnu/libXdmcp.a

lib:= $(glfw_libs)
...
...
$(library): $(obj)
    ar rs $@ $^ $(lib)

with something like this:

glfw_libs:=/usr/local/lib/libglfw3.a\
        -lrt -lm -ldl -lX11 -lpthread -lxcb -lXau -lXdmcp

lib:= $(glfw_libs)
...
...
$(library): $(obj)
    ar rs $@ $^ $(lib)
0

There are 0 best solutions below