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++
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.