After successfully building Pdfium as per Google's docs, I created a new C++ console app with VS2022 and tried to embed .lib resulting from Pdfium build but, it results in several unresolved symbols which, I guess, should be included in standard C++. As an example, here is two of the unresolved symbols:
fx_string.obj: error LNK2001: unresolved external symbol "void __cdecl std::Cr::__libcpp_verbose_abort(char const *,...)"
fpdf_parser_utility.obj : error LNK2001: unresolved external symbol "public: class std::Cr::basic_ostream<char,struct std::Cr::char_traits<char> > & __cdecl std::Cr::basic_ostream<char,struct std::Cr::char_traits<char> >::write(char const *,__int64)"
Steps taken:
- build Pdfium following docs steps using below
args.gn:use_goma = false is_debug = false pdf_use_skia = false pdf_enable_xfa = false pdf_enable_v8 = false pdf_is_standalone = false is_component_build = false pdf_is_complete_lib = true - Created a simple C++ console app with following content (copied from Getting started):
#include <iostream> #include "../PDFium/public/fpdfview.h" int main() { std::cout << "PDFium test!\n"; FPDF_LIBRARY_CONFIG config{}; config.version = 2; config.m_pUserFontPaths = NULL; config.m_pIsolate = NULL; config.m_v8EmbedderSlot = 0; FPDF_InitLibraryWithConfig(&config); FPDF_DestroyLibrary(); return 0; } - Copied Pdfium's public folder and resulting
.libfile into a separate folder of the project, added necessary fields for linker and set C++ language spec tostdc++20; below, the corresponding tags in.vcxproj<!-- other tags --> <ClCompile> <!-- other tags --> <LanguageStandard>stdcpp20</LanguageStandard> <LanguageStandard_C>stdc11</LanguageStandard_C> </ClCompile> <!-- other tags --> <Link> <SubSystem>Console</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <AdditionalLibraryDirectories>$(SolutionDir)PDFium\x64</AdditionalLibraryDirectories> <AdditionalDependencies>PDFium.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link>
(Unsuccessful) Tests did
- Tried to compile PDFium with and without
pdf_is_complete_lib = true, and thus, linking also single.objs, andv8andxfasupport - Tried to compile with Microsoft's
clang-clinstead ofMSBuild(the one provided by Visual Studio's Native Development pack) - Tried to compile with depot tools's
clang-cl(currently, version16.0.0) - Tried several options found here and there on SO and on internet
Any help is appreciated. Thanks in advance.