使用从源代码生成的库的Xalan链接失败



我正在将我们的一个库升级到最新版本。来自GitHub的xalanhttps://github.com/apache/xalan-c.我能够使用gcc12成功地编译这个库。当我运行make-test命令时,一切都很好。但当它在我的代码中使用时,它在尝试链接时会失败,我得到了这样的错误(我确实检查了库搜索路径,ld可以找到libxalan-c.so和libxalanMsg.so(:

g++   -g -O0  -Werror -Wunused -Wall -D__USE_XOPEN2K8 -D_REENTRANT -D__STL_PTHREADS -std=c++17 -pthread -Wno-parentheses -Wno-nonnull -pipe -lxerces-c -L/rapid/rapid_workspaces/chuhuan/GitHub/xalan-c/build/lib64/ -lxalan-c -lxalanMsg -Lxxxxxxxxx/TargetRTS/ -ldhf
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: linux/TargetRTS/ParamConfig.o: in function `dhf::DataHandlerFactory::initializeXMLLibs()':
xxxxxxxxx/DataHandlerFactory.hh:58: undefined reference to `xalanc_1_12::XalanTransformer::initialize(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DataHandlerFactory.hh:59: undefined reference to `xalanc_1_12::XPathEvaluator::initialize(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::transform(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
xxxxxxxxx/DOMImpl.cc:173: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:183: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char16_t const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:184: undefined reference to `xalanc_1_12::XercesDOMWrapperParsedSource::XercesDOMWrapperParsedSource(xercesc_4_0::DOMDocument const*, xalanc_1_12::XercesParserLiaison&, xalanc_1_12::XercesDOMSupport&, xalanc_1_12::XalanDOMString const&, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:190: undefined reference to `xalanc_1_12::FormatterToXercesDOM::FormatterToXercesDOM(xercesc_4_0::DOMDocument*, xercesc_4_0::DOMElement*, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:191: undefined reference to `xalanc_1_12::XalanTransformer::XalanTransformer(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:192: undefined reference to `xalanc_1_12::XSLTResultTarget::XSLTResultTarget(xalanc_1_12::FormatterListener&, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:192: undefined reference to `xalanc_1_12::XSLTInputSource::XSLTInputSource(char const*, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double*)':
xxxxxxxxx/DOMImpl.cc:237: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:244: undefined reference to `xalanc_1_12::XercesParserLiaison::createDocument(xercesc_4_0::DOMDocument const*, bool, bool, bool)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:246: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:248: undefined reference to `xalanc_1_12::XPathEvaluator::XPathEvaluator(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:250: undefined reference to `xalanc_1_12::XPathEvaluator::evaluate(xalanc_1_12::DOMSupport&, xalanc_1_12::XalanNode*, char16_t const*, xalanc_1_12::XalanElement const*)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::getSize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int*)':
xxxxxxxxx/DOMImpl.cc:298: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:305: undefined reference to `xalanc_1_12::XercesParserLiaison::createDocument(xercesc_4_0::DOMDocument const*, bool, bool, bool)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:307: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:309: undefined reference to `xalanc_1_12::XPathEvaluator::XPathEvaluator(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:313: undefined reference to `xalanc_1_12::XPathEvaluator::selectSingleNode(xalanc_1_12::DOMSupport&, xalanc_1_12::XalanNode*, char16_t const*, xalanc_1_12::XalanElement const*)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
xxxxxxxxx/DOMImpl.cc:364: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:371: undefined reference to `xalanc_1_12::XercesParserLiaison::createDocument(xercesc_4_0::DOMDocument const*, bool, bool, bool)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:373: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:375: undefined reference to `xalanc_1_12::XPathEvaluator::XPathEvaluator(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:377: undefined reference to `xalanc_1_12::XPathEvaluator::evaluate(xalanc_1_12::DOMSupport&, xalanc_1_12::XalanNode*, char16_t const*, xalanc_1_12::XalanElement const*)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::serialize(std::ostream&)':
xxxxxxxxx/DOMImpl.cc:486: undefined reference to `xalanc_1_12::XalanStdOutputStream::XalanStdOutputStream(std::ostream&, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o):xxxxxxxxx/DOMImpl.cc:490: more undefined references to `xalanc_1_12::XalanDOMString::XalanDOMString(xercesc_4_0::MemoryManager&)' follow
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::serialize(std::ostream&)':
xxxxxxxxx/DOMImpl.cc:490: undefined reference to `xalanc_1_12::FormatterToXML::FormatterToXML(xalanc_1_12::Writer&, xalanc_1_12::XalanDOMString const&, bool, int, xalanc_1_12::XalanDOMString const&, xalanc_1_12::XalanDOMString const&, xalanc_1_12::XalanDOMString const&, xalanc_1_12::XalanDOMString const&, bool, xalanc_1_12::XalanDOMString const&, xalanc_1_12::FormatterListener::eFormat, bool, xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:501: undefined reference to `xalanc_1_12::XercesDOMWalker::traverse(xercesc_4_0::DOMNode*)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/TargetRTS//libdhf.a(DOMImpl.o): in function `dhf::DOMImpl::selectNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
xxxxxxxxx/DOMImpl.cc:510: undefined reference to `xalanc_1_12::XercesParserLiaison::XercesParserLiaison(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:517: undefined reference to `xalanc_1_12::XercesParserLiaison::createDocument(xercesc_4_0::DOMDocument const*, bool, bool, bool)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:522: undefined reference to `xalanc_1_12::XalanDOMString::XalanDOMString(char const*, xercesc_4_0::MemoryManager&, unsigned long)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:527: undefined reference to `xalanc_1_12::XPathEvaluator::XPathEvaluator(xercesc_4_0::MemoryManager&)'
xxxxxxxxxgcc-12.2.0/../binutils-2.36.1/bin/ld: xxxxxxxxx/DOMImpl.cc:528: undefined reference to `xalanc_1_12::XPathEvaluator::selectSingleNode(xalanc_1_12::DOMSupport&, xalanc_1_12::XalanNode*, char16_t const*, xalanc_1_12::XalanElement const*)'
collect2: error: ld returned 1 exit status

我的cmake选项:

CC=gcc-12.2.0/bin/gcc CXX=gcc-12.2.0/bin/g++ CFLAGS=-O3 CXXFLAGS=-O3 cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=xalan-c/build -DCMAKE_BUILD_TYPE=Release -Dmessage-loader=inmemory -Dtranscoder=default xalan-c

似乎有什么东西可能与我的构建选项不一致,有没有办法解决这个问题?

非常感谢!

Chunde

最终解决了这个问题,这是因为Xalan需要链接到Xercesc,而不指定Xercesc 4.0.0版本的路径,它将在系统路径上链接到默认版本。所以我用了

-DCMAKE_PREFIX_PATH

变量来设置,新的cmake命令看起来像这样:

CC=gcc-12.2.0/bin/gcc CXX=gcc-12.2.0/bin/g++ CFLAGS=-O3 CXXFLAGS=-O3 cmake -DCMAKE_PREFIX_PATH=xxx/xerces-c_4.0.0/ -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=xalan-c/build -DCMAKE_BUILD_TYPE=Release -Dmessage-loader=inmemory -Dtranscoder=default xalan-c

相关内容

  • 没有找到相关文章

最新更新