qpdf with visual studio console project but lnk1107 - a dll cannot read at 0x308

181 views Asked by At

I follow this link and download the built directory, tring to use qpdf library in a easy way. How to build qpdf on Windows?

I do these steps to setup my visual studio project:

1. C/C++ -> General -> Additional Include Directories : qpdf-10.3.3\include
2. Linker -> General -> Additional Library Directories : qpdf-10.3.3\bin;qpdf-10.3.3\lib
3. Linker -> General -> Additional Dependencies :
      C:\SDKs\qpdf-10.6.3\bin\libgcc_s_dw2-1.dll
      C:\SDKs\qpdf-10.6.3\bin\libstdc++-6.dll
      C:\SDKs\qpdf-10.6.3\bin\libwinpthread-1.dll
      C:\SDKs\qpdf-10.6.3\bin\qpdf28.dll

,then I try a sample code from qpdf github examples: https://github.com/qpdf/qpdf/blob/main/examples/pdf-attach-file.cc

At the end, I got an error (and a warning), which is

Error   
Code    Description                                     File                               Line 
LNK1107 invalid or corrupt file: cannot read at 0x308   C:\qpdf-10.6.3\bin\libgcc_s_dw2-1.dll   1

Warning 
C26495  Variable 'QPDFObjectHandle::TokenFilter::pipeline' is uninitialized. Always initialize a member variable (type.6).  qpdf_t01    C:\qpdf-10.6.3\include\qpdf\QPDFObjectHandle.hh 172 

Although at this point, I found I can use bin\qpdf.exe in command line terminal.

but I suppose I can use it as a c++ library, so what did I miss here?

Thankful to any suggestion.

1

There are 1 answers

0
tian On

Answer to my own question to at least provide some information.

I found out that I downloaded bin-mingw32.zip by mistake, instead of bin-msvc32.zip which I want.

msvc linker reference - link input files,shows I shouldn't put dll in step 3. then put dlls in executable-directory and add the path to system environment. Finally it works.

Sorry there are still some black boxs for me so that I cannot explain detailly the difference located. Maybe I could edit my answer with more knowledge about linking.