0

I've compiled shared library (pppd plugin) with no errors or warnings but when pppd tries to load this plugin, it fails with "undefined symbol g_string_sized_new" message.

Plugin source can be found here: https://raw.github.com/openshine/ModemManager/master/test/mm-test-pppd-plugin.c

To compile shared library I use the following commands:

gcc -fPIC -c ./mm-test-pppd-plugin.c -o mm-test-pppd-plugin.o `pkg-config --cflags --libs glib-2.0`
gcc -shared -o ./mm-test-pppd-plugin.so ./mm-test-pppd-plugin.o

As I find this g_string_sized_new should be in GLib. So as I understand it should be available systemwide?

OS: Ubuntu 13.04

Any ideas what could be wrong? Thanks in advance!

Saleniex
  • 615
  • 5
  • 4

1 Answers1

0

Compilation is not linkage and linkage is not compilation.

On the first line, you are invoking the compiler so as to compile your C source text into object code. Here supplying the --libs flag to pkg-config is completely superfluous, pure compiler can do nothing with libraries.

However, on the second line, you are trying to link the resulting object files into a proper executable using the linker, but now you are missing the pkg-config --libs from the end of the command line - the linker needs to know the libraries to be linked against in order it to be able to resolve symbols.

Long story short, read this.

  • Thanks. All I needed to do, add `pkg-config --cflags --libs glib-2.0` at the end of the second line. – Saleniex May 24 '13 at 06:52
  • @UldisJansons There **do not** use `--cflags`. There's a reason (well, what I explained is **the reason**) why `--cflags` and `--libs` are two different flags for `pkg-config`. –  May 24 '13 at 06:53