I am trying to include symbols from a pre-built static library into a static library that I am building. The static library that I am building is then used inside of an executable. The problem I am having is that I am getting undefined symbols in my static library from the other static library. Which means the symbols I need from the pre-built static library are not being included in my static library.
What is the correct approach with auto tools to do this? I know I need to un-archive the pre-built and include those .o files inside my archive. I just don't know how to do this using automake.
Below is my makefile.am that I currently have with the relative build errors that I am getting.
lib_LTLIBRARIES = lib_xml_wrapper.la
# List your sources
lib_xml_wrapper_la_SOURCES = \
xml_system.cpp
lib_xml_wrapper_la_LDFLAGS = -static -l$(WRAPPER_LDFLAGS)
lib_xml_wrapper_la_CXXFLAGS = -DXERCES_STATIC_LIBRARY
lib_xml_wrapper_la_CPPFLAGS = -I../.. $(WRAPPER_CPPFLAGS)
where $(WRAPPER_CPPFLAGS) and $(WRAPPER_LDFLAGS) are defined as:
-I../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include -DXERCES_STATIC_LIBRARY
and
-static -l../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/lib/libxerces-c.a
and my build errors are
make all-recursive
make[1]: Entering directory `/home/mehoggan/Devel/RuleSimulator/src/xml'
Making all in xml_wrapper
make[2]: Entering directory `/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper'
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I../.. -DLINUX -DAMD64 -I../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include -DXERCES_STATIC_LIBRARY -g -O2 -MT lib_xml_wrapper_la-xml_system.lo -MD -MP -MF .deps/lib_xml_wrapper_la-xml_system.Tpo -c -o lib_xml_wrapper_la-xml_system.lo `test -f 'xml_system.cpp' || echo './'`xml_system.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../.. -DLINUX -DAMD64 -I../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include -DXERCES_STATIC_LIBRARY -g -O2 -MT lib_xml_wrapper_la-xml_system.lo -MD -MP -MF .deps/lib_xml_wrapper_la-xml_system.Tpo -c xml_system.cpp -fPIC -DPIC -o .libs/lib_xml_wrapper_la-xml_system.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../.. -DLINUX -DAMD64 -I../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include -DXERCES_STATIC_LIBRARY -g -O2 -MT lib_xml_wrapper_la-xml_system.lo -MD -MP -MF .deps/lib_xml_wrapper_la-xml_system.Tpo -c xml_system.cpp -o lib_xml_wrapper_la-xml_system.o >/dev/null 2>&1
mv -f .deps/lib_xml_wrapper_la-xml_system.Tpo .deps/lib_xml_wrapper_la-xml_system.Plo
/bin/sh ../libtool --tag=CXX --mode=link g++ -DXERCES_STATIC_LIBRARY -g -O2 -static -l../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/lib/libxerces-c.a -o lib_xml_wrapper.la -rpath /usr/local/lib lib_xml_wrapper_la-xml_system.lo
libtool: link: ar cru .libs/lib_xml_wrapper.a lib_xml_wrapper_la-xml_system.o
libtool: link: ranlib .libs/lib_xml_wrapper.a
libtool: link: ( cd ".libs" && rm -f "lib_xml_wrapper.la" && ln -s "../lib_xml_wrapper.la" "lib_xml_wrapper.la" )
make[2]: Leaving directory `/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper'
Making all in xml_wrapper_tester
make[2]: Entering directory `/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper_tester'
g++ -DHAVE_CONFIG_H -I. -I.. -DLINUX -DAMD64 -I../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include -I../xml_wrapper -I../../../tools/unit_tests/cxxtest-4.2.1/ -I../.. -g -O2 -MT xml_wrapper_tester-runner.o -MD -MP -MF .deps/xml_wrapper_tester-runner.Tpo -c -o xml_wrapper_tester-runner.o `test -f 'runner.cpp' || echo './'`runner.cpp
mv -f .deps/xml_wrapper_tester-runner.Tpo .deps/xml_wrapper_tester-runner.Po
/bin/sh ../libtool --tag=CXX --mode=link g++ -g -O2 -o xml_wrapper_tester xml_wrapper_tester-runner.o ../xml_wrapper/.libs/lib_xml_wrapper.a
libtool: link: g++ -g -O2 -o xml_wrapper_tester xml_wrapper_tester-runner.o ../xml_wrapper/.libs/lib_xml_wrapper.a
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
xml_wrapper_tester-runner.o: In function `xercesc_3_1::XMLAttDefList::~XMLAttDefList()':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper_tester/../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/xercesc/framework/XMLAttDefList.hpp:158: undefined reference to `xercesc_3_1::XMemory::operator delete(void*)'
xml_wrapper_tester-runner.o: In function `xercesc_3_1::HandlerBase::fatalError(xercesc_3_1::SAXParseException const&)':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper_tester/../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/xercesc/sax/HandlerBase.hpp:398: undefined reference to `xercesc_3_1::SAXParseException::SAXParseException(xercesc_3_1::SAXParseException const&)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper_tester/../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/xercesc/sax/HandlerBase.hpp:398: undefined reference to `xercesc_3_1::SAXParseException::~SAXParseException()'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper_tester/../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/xercesc/sax/HandlerBase.hpp:398: undefined reference to `typeinfo for xercesc_3_1::SAXParseException'
xml_wrapper_tester-runner.o: In function `xercesc_3_1::DTDEntityDecl::~DTDEntityDecl()':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper_tester/../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/xercesc/validators/DTD/DTDEntityDecl.hpp:160: undefined reference to `xercesc_3_1::XMLEntityDecl::~XMLEntityDecl()'
xml_wrapper_tester-runner.o: In function `~DTDEntityDecl':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper_tester/../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/xercesc/validators/DTD/DTDEntityDecl.hpp:160: undefined reference to `xercesc_3_1::XMLEntityDecl::~XMLEntityDecl()'
xml_wrapper_tester-runner.o: In function `xercesc_3_1::DTDEntityDecl::~DTDEntityDecl()':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper_tester/../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/xercesc/validators/DTD/DTDEntityDecl.hpp:162: undefined reference to `xercesc_3_1::XMemory::operator delete(void*)'
xml_wrapper_tester-runner.o:(.rodata._ZTIN11xercesc_3_113DTDEntityDeclE[_ZTIN11xercesc_3_113DTDEntityDeclE]+0x10): undefined reference to `typeinfo for xercesc_3_1::XMLEntityDecl'
xml_wrapper_tester-runner.o:(.rodata._ZTVN11xercesc_3_113XMLAttDefListE[_ZTVN11xercesc_3_113XMLAttDefListE]+0x20): undefined reference to `xercesc_3_1::XMLAttDefList::isSerializable() const'
xml_wrapper_tester-runner.o:(.rodata._ZTVN11xercesc_3_113XMLAttDefListE[_ZTVN11xercesc_3_113XMLAttDefListE]+0x28): undefined reference to `xercesc_3_1::XMLAttDefList::serialize(xercesc_3_1::XSerializeEngine&)'
xml_wrapper_tester-runner.o:(.rodata._ZTVN11xercesc_3_113XMLAttDefListE[_ZTVN11xercesc_3_113XMLAttDefListE]+0x30): undefined reference to `xercesc_3_1::XMLAttDefList::getProtoType() const'
xml_wrapper_tester-runner.o:(.rodata._ZTVN11xercesc_3_113DTDEntityDeclE[_ZTVN11xercesc_3_113DTDEntityDeclE]+0x20): undefined reference to `xercesc_3_1::DTDEntityDecl::isSerializable() const'
xml_wrapper_tester-runner.o:(.rodata._ZTVN11xercesc_3_113DTDEntityDeclE[_ZTVN11xercesc_3_113DTDEntityDeclE]+0x28): undefined reference to `xercesc_3_1::DTDEntityDecl::serialize(xercesc_3_1::XSerializeEngine&)'
xml_wrapper_tester-runner.o:(.rodata._ZTVN11xercesc_3_113DTDEntityDeclE[_ZTVN11xercesc_3_113DTDEntityDeclE]+0x30): undefined reference to `xercesc_3_1::DTDEntityDecl::getProtoType() const'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o): In function `rule_builder::xml_system::startElement(unsigned short const*, xercesc_3_1::AttributeList&)':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:130: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:130: undefined reference to `xercesc_3_1::XMLString::transcode(unsigned short const*, xercesc_3_1::MemoryManager*)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:132: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:132: undefined reference to `xercesc_3_1::XMLString::release(char**, xercesc_3_1::MemoryManager*)'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o): In function `rule_builder::xml_system::fatalError(xercesc_3_1::SAXParseException const&)':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:139: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:139: undefined reference to `xercesc_3_1::XMLString::transcode(unsigned short const*, xercesc_3_1::MemoryManager*)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:141: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:141: undefined reference to `xercesc_3_1::XMLString::release(char**, xercesc_3_1::MemoryManager*)'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o): In function `rule_builder::xml_system::deinitialize()':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:40: undefined reference to `xercesc_3_1::XMLPlatformUtils::Terminate()'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:42: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:42: undefined reference to `xercesc_3_1::XMLString::transcode(unsigned short const*, xercesc_3_1::MemoryManager*)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:43: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:43: undefined reference to `xercesc_3_1::XMLString::release(char**, xercesc_3_1::MemoryManager*)'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o): In function `rule_builder::xml_system::parse_and_validate(std::string const&, std::string const&)':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:61: undefined reference to `xercesc_3_1::XercesDOMParser::resetCachedGrammarPool()'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:83: undefined reference to `xercesc_3_1::AbstractDOMParser::parse(char const*)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:70: undefined reference to `xercesc_3_1::XercesDOMParser::loadGrammar(char const*, xercesc_3_1::Grammar::GrammarType, bool)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:86: undefined reference to `xercesc_3_1::AbstractDOMParser::getDocument()'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o): In function `rule_builder::xml_system::xml_system()':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:27: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:27: undefined reference to `xercesc_3_1::XercesDOMParser::XercesDOMParser(xercesc_3_1::XMLValidator*, xercesc_3_1::MemoryManager*, xercesc_3_1::XMLGrammarPool*)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:29: undefined reference to `xercesc_3_1::AbstractDOMParser::setDoNamespaces(bool)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:30: undefined reference to `xercesc_3_1::AbstractDOMParser::setDoSchema(bool)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:32: undefined reference to `xercesc_3_1::XercesDOMParser::cacheGrammarFromParse(bool)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:33: undefined reference to `xercesc_3_1::XercesDOMParser::setErrorHandler(xercesc_3_1::ErrorHandler*)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:34: undefined reference to `xercesc_3_1::AbstractDOMParser::setValidationScheme(xercesc_3_1::AbstractDOMParser::ValSchemes)'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:27: undefined reference to `xercesc_3_1::XercesDOMParser::~XercesDOMParser()'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o): In function `rule_builder::xml_system::initialize()':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:11: undefined reference to `xercesc_3_1::XMLUni::fgXercescDefaultLocale'
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:11: undefined reference to `xercesc_3_1::XMLPlatformUtils::Initialize(char const*, char const*, xercesc_3_1::PanicHandler*, xercesc_3_1::MemoryManager*)'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o): In function `rule_builder::xml_system::~xml_system()':
/home/mehoggan/Devel/RuleSimulator/src/xml/xml_wrapper/xml_system.cpp:47: undefined reference to `xercesc_3_1::XercesDOMParser::~XercesDOMParser()'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o):(.gcc_except_table+0x1c): undefined reference to `typeinfo for xercesc_3_1::XMLException'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o):(.gcc_except_table+0xdc): undefined reference to `typeinfo for xercesc_3_1::XMLException'
../xml_wrapper/.libs/lib_xml_wrapper.a(lib_xml_wrapper_la-xml_system.o):(.gcc_except_table+0x10c): undefined reference to `typeinfo for xercesc_3_1::XMLException'
collect2: error: ld returned 1 exit status