1

Right now, I am trying to compile some C++ code that uses both PoDoFo and Magick++ (part of ImageMagick) using MinGW on linux. I'm using MinGW so I can compile for Windows. When I try to compile, I get this error:

/usr/lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lpodofo

However, when I run ld -L/usr/local/lib -lpodofo --verbose, it is able to find the library. How would I fix this problem? I have a theory that the MinGW's linker is unable to find it, but the original GNU tools' linker is able to find it. If this was the problem, I'm not too sure how I would go about on fixing it.

Just as more info, here is my include section in my code:

#include <iostream>
#include <string>
#include <podofo.h>
#include <Magick++.h>
#include <vector>
#include <thread>

and this is my compile command:

x86_64-w64-mingw32-g++ main_multithreaded.cpp -L /usr/local/lib `Magick++-config --cppflags --cxxflags --ldflags --libs` -I"/usr/local/include/PoDoFo" -l"podofo" -DDEBUG

Note that I had to do a bunch of changes in order to get MinGW to even add PoDoFo into its include directories, so this might not be reproducible on another person's computer. Also, I am able to compile this properly with g++

Zium
  • 163
  • 9
  • Have you installed the library into your MinGW environment? How did you install it? Have you checked that it really comes with the PoDoFo library? Perhaps PoDoFo needs a separate installation? – Some programmer dude Nov 20 '20 at 16:19
  • Could you clarify what you mean by installing it into the MinGW environment please? I installed it using `pacman` and I manually linked the code in the compiler command – Zium Nov 20 '20 at 16:22
  • I should also add to the question that my code compiles and runs properly with g++ – Zium Nov 20 '20 at 16:22

1 Answers1

1

Your ld find the library because it was compiled for linux which use elf64-x86-64 format. It is not compatible with mingw which will need libraries in pei format (probably pei-x86-64 format).

In order to use this library you need to find the mingw version of the library or cross compile it yourself.

yflelion
  • 1,698
  • 2
  • 5
  • 16
  • Thank you for answering. This seems like it's true. I'll try it out and ask any questions if it doesn't work. – Zium Nov 20 '20 at 17:13