Forums » Saxon/C Help and Discussions »
Anyone knowing how to use SaxonC 12 in Windows MFC code?
Added by Martin Honnen 19 days ago
I have tried to use SaxonC HE 12.5 in an Windows C++ MFC application, but I don't get anything to link, I get errors LNK2019 and LNK2001 errors:
- reference to unresolved external symbol ""public: __cdecl SaxonProcessor::SaxonProcessor(void)" (??0SaxonProcessor@@QEAA@XZ)" in Funktion ""public: __cdecl CMFCApplicationSaxonCTest1App::CMFCApplicationSaxonCTest1App(void)" (??0CMFCApplicationSaxonCTest1App@@QEAA@XZ)".
- unresolved external symbol ""public: static class SaxonProcessor * CMFCApplicationSaxonCTest1App::saxonProc" (?saxonProc@CMFCApplicationSaxonCTest1App@@2PEAVSaxonProcessor@@EA)".
I am not really familiar with all the details of C++ and peculiarities of MFC, I have found some documentation suggesting code needs to be decorated with a macro to switch to MFC used __cdecl calling conventions, but it is not clear to me whether and how that is possible if I link to the existing SaxonC library, and my initial attempts to use the macro don't seem to change the link errors.
Anyone reading here that has successfully used SaxonC 12 with Windows C++ MFC code and can show some minimal code/project or at least can tell whether the use of existing compiled library like the SaxonC 12 one with MFC is possible without needing to recompile everything with the right calling conventions?
I might lack the C++ and MFC coding skills but as I successfully get SaxonC to compile and link in non MFC C++ code under Windows I currently think the error is due to trying to use SaxonC with C++ and MFC.
Replies (3)
Please register to reply
RE: Anyone knowing how to use SaxonC 12 in Windows MFC code? - Added by Martin Honnen 18 days ago
It seems the errors were just about my failure to get the project to include/compile/link all of the Saxon.C.API properly, they are (at least that is my understanding of today) not about a calling convention mismatch.
Still far away from integrating SaxonC into the existing MFC library I have but the above post can be ignored.
RE: Anyone knowing how to use SaxonC 12 in Windows MFC code? - Added by Matt Patterson 17 days ago
Let me know how you get on. I have been poking around the C build system and have discovered that there are things about symbol visibility where we've been getting the expected behaviour partly as a side-effect of the way we have asked people to integrate SaxonC with their other CPP code.
Specifically, we haven't been explicitly setting visibility for symbols under MSVC, which defaults to symbols being private, instead of GCC/Clang, which default to them being public.
If this remains a problem, you can set some kind of compiler setting to consider all symbols public. I've been seeing this through the CMake machinery, so I'm not sure how to apply that knowledge in your context, but maybe it will help.
We're looking at behaving more in line with compiler expectations for future releases.
RE: Anyone knowing how to use SaxonC 12 in Windows MFC code? - Added by Martin Honnen 15 days ago
Thanks, Matt, it seems it was all just a lack of experience to properly set up my project(s), I now have a prototype of the XMLTools plugin for Notepad++ extended/forked to run XSLT 3.0 with SaxonC HE 12.5; only the author of the original plugin would like the Saxon specific code to implement a certain interface that to me seems rather XSLT 1/XPath 1 specific. But I will first try to get Saxon inside Notepad++ to run XSLT 3 and XPath 3.1 cleanly before I try to force my code to implement some interface that seems heavily influenced by the existing MSXML library used for XSLT 1.0 (and all other XML stuff like parsing, validating, XPath 1.0 evaluation).
Screenshot 2024-12-06 110900.png (297 KB) Screenshot 2024-12-06 110900.png | fork of XMLTools plugin for Notepad++ that allows running XSLT 3 (and 2) with SaxonC HE 12 |
Please register to reply