1
我使用cygwin創建了一個使用Xerces的共享庫/ DLL。當我從主應用程序調用xercesc函數時,一切正常,但是當我嘗試將一些代碼放入庫中時,則會爲xerxesc定義的所有靜態內容獲取未定義的符號。使用xerces鏈接DLL給出了未定義的符號
例如:
std::string fromXMLString(XMLCh *oXMLString)
{
std::string result;
xercesc::DOMImplementation *impl = xercesc::DOMImplementationRegistry::getDOMImplementation(X("Core"));
char *temp = xercesc::XMLString::transcode(oXMLString);
result = temp;
xercesc::XMLString::release(&temp);
return result;
}
鏈接:
g++ -shared -Wl,-soname,cygsupport.so -L /usr/local/lib -l xerces-c -o cygsupport.so obj/helper/xml_helper.o
當鏈接庫,我得到:
/usr/local/include/xercesc/internal/XSerializable.hpp:37: undefined reference to `xercesc_3_1::DOMImplementationRegistry::getDOMImplementation(wchar_t const*)'
/usr/local/include/xercesc/internal/XSerializable.hpp:37: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/usr/local/include/xercesc/internal/XSerializable.hpp:37: undefined reference to `xercesc_3_1::XMLString::transcode(wchar_t const*, xercesc_3_1::MemoryManager*)'
/usr/local/include/xercesc/internal/XSerializable.hpp:37: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/usr/local/include/xercesc/internal/XSerializable.hpp:37: undefined reference to `xercesc_3_1::XMLString::release(char**, xercesc_3_1::MemoryManager*)'
/usr/local/include/xercesc/internal/XSerializable.hpp:37: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
/usr/local/include/xercesc/internal/XSerializable.hpp:37: undefined reference to `xercesc_3_1::XMLString::release(wchar_t**, xercesc_3_1::MemoryManager*)'
/usr/local/include/xercesc/internal/XSerializable.hpp:37: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'
...
您是否正確設置了路徑變量?從xerces網站:「您需要將xerces-c-3.1.1- {arch} - {os} - {compiler}/bin目錄添加到您的PATH環境變量中:」 – ChrisCM
當我編譯主應用程序時,它作品。這只是共享庫,給我帶來麻煩。我的假設是,共享符號應該以某種方式轉發給主應用程序,並且不需要在共享庫中解析。 – Devolus