-1

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.

tian
  • 1
  • 1
  • 1
  • For step *#3.*, **you must supply *.lib* files**. Check [\[SO\]: LNK2005 Error in CLR Windows Form (@CristiFati's answer)](https://stackoverflow.com/a/34777349/4788546) for more details. The *URL* that you provided doesn't contain the steps you took, neither does the official page. – CristiFati Jul 23 '22 at 21:35
  • There is only one file in lib folder "libqpdf.dll.a", I included it in step 3 and still in same error. Then I also tried to build .lib from this method "Generating LIB File for DLL Library"[link](https://www.asawicki.info/news_1420_generating_lib_file_for_dll_library) ,option1: from these four dlls, option2: from libqpdf.dll.a. All options encounters same error. I know .lib is the problem right now, but have no clue to fix it. any guess/suggestion plz? – tian Jul 24 '22 at 14:17

1 Answers1

0

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.

tian
  • 1
  • 1
  • 1