How to solve linking pdfium on windows 10

473 Views Asked by At

I have the main.cpp on Windows at C:\repo\pdfium\out\debug\obj\test directory. Pdfium.lib is at obj directory.

#include <stdio.h>
#include <fpdfview.h>
int main() {
FPDF_InitLibrary();
FPDF_DestroyLibrary();
printf("PDFium hello.\n");
return 0;}

pdfium.lib is build with GCC(is_lang=false)

With command i am producing main.o

g++.exe -std=c++11 -g -I........\public -c C:\repo\pdfium\out\debug\obj\test\main.cpp -o obj\Debug\main.o

With command bellow i am trying to link pdfium.lib

g++.exe  -o bin\Debug\test.exe obj\Debug\main.o   ..\pdfium.lib

But i am taking ...

Warning: corrupt .drectve at end of def file
..\pdfium.lib(obj/core/fpdfapi/parser/parser/fpdf_parser_utility.obj):(.xdata[$unwind$?_Makestr@_System_error@std@@CA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@Verror_code@2@V32@@Z]+0x8): undefined reference to `__GSHandlerCheck'

I have try so many time but nothing on linking on windows 10. Any advice will be redemptive.

Thank you

Jim

1

There are 1 best solutions below

0
On

If you're building PDFium with a non-component build (is_component_build = false in args.gn) and not setting pdf_is_complete_lib = true, the generated .lib files won't have their dependencies included, so you're quite likely to have the linker complain about missing symbols. Try either generating DLLs (is_component_build = true) or setting pdf_is_complete_lib = true.

If you use a component build, you'll need to package the PDFium DLL and its dependencies (at least the zlib DLL, possibly others) with your application.