0

I'm working on a C code but need to couple with a C++ code. My Makefile.am has lines like

libfoo_la_LIBADD += -lstdc++

but the generated libtool archive libmhd.la does not have -lstdc++ in the dependency_libs, and at linking time errors like "undefined references" to stdc++ symbols flush my screen. I tried to add -lstdc++ to libfoo_la_LDFLAGS, also tried "make LDFLAGS=-lstdc++" but neither helped.

I read from the libstdc++ mail list that -lstdc++ is removed from libtool postdeps for CXX. How can I manually force it either in the Makefile.am or at command line?

Thanks.

Liang
  • 1,015
  • 1
  • 10
  • 13

1 Answers1

0

It turned out if I append the -lstdc++ option to the final executable's LDADD, i.e. myexe_LDADD = -lstdc++ $(LDADD), then it works. To generate the .la file, libtool does not need to link to libstdc++ (yet), thus the -lstdc++ option is removed.

Liang
  • 1,015
  • 1
  • 10
  • 13