Search code examples
clinuxwarningsshared-librariesstatic-libraries

What is the meaning of "Warning: Linking the shared library against static library is not portable"?


I am making one dynamic library by using some function of libmxml.a library but I get this warning:

*Warning: Linking the shared library libgstmatroskademux.la against the _
*static library /home/Mr32/gst-template4_final/gst-plugin/src/libmxml.a _
is not portable!

I also get this warning:

gcc: /home/Mr32/gst-template4_final/gst-plugin/src/libmxml.a: linker _
input file unused because linking not done

So what's the meaning of this warning and how could I solve it?

Edit :

There is one already autogenerated make file for compiling the gstreamer plugin. Now to use some function of libmxml.a in that plugin I have added $(PATH)/libmxml.a in the GST_CFLAGS variable in the make file. Now, when I do make and make install, the plugin works fine, but I still get this warning.


Solution

  • Linking shared libraries to static libraries is not possible (unless you really know very well what you are doing). Don't do it.

    The first warning is from libtool. It tells you, that the operation you asked for will do different things on different systems and some of those things are probably not what you want. Often it's just going to fail in various spectacular ways, because code that goes in shared and static libraries needs to be compiled with different compiler flags.

    The second warning is from gcc. It is telling you that providing static library when compiling is pointless. That's because you have $(PATH)/libmxml.a in CFLAGS, where it has no business of being. In fact, most of the time you should not have $(PATH)/libmxml.a, but -L$(PATH) -lmxml instead. That should still go in LDFLAGS, but gcc won't complain if this makes it to the compiler command-line too.