I want to use gcc to produce a shared library, but i want to link some other libraries it depends on statically. Now to produce the \"standard\" dynamically linked output fi
I ran into the same problem. As it turned out, there seems to be no way to link libraries statically without specifying the full path to the .a-file.
However, there seems to be neat trick in Makefile
's allowing for smooth usage.
vpath %.a /opt/local/lib
.LIBPATTERNS lib%.a lib%.dylib lib%.so
STATICLIBS = -lssh2
libmy.dylib: my1.o my2.o $(STATICLIBS)
g++ -dynamiclib -o libmy.dylib $^
Note how the $(STATICLIBS)
variable is put in the dependencies. Make will not treat dependecies with an '-l' prefix as files - but rather as libraries. Using the above vpath
magic make looks up the libraries and put the full path on the commandline to g++.