I am trying to compile a c++ program containing Magick++.h on a PC running VS-Code on Ubuntu20.04, which compiles fine. If I change the compiler from GCC 9.3.0 x86_64-linux-gnu
to GCC 9.3.0 arm-linux-gnueabihf
to compile the project for Raspberry Pi then it fails saying:
[build] /usr/local/lib/libMagick++-7.Q16HDRI.so: file not recognized: file format not recognized
My c++ program is simplified to:
#include <iostream>
#include "Magick++.h"
int main(int, char**) {
std::cout << "Hello, world!\n";
}
The full output is:
[main] Building folder: testProject
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/user/dev/testProject/build --config Debug --target all -j 4 --
[build] [1/1 100% :: 0.025] Linking CXX executable testProject
[build] FAILED: testProject
[build] : && /usr/bin/arm-linux-gnueabihf-g++-9 -pthread -g -rdynamic CMakeFiles/testProject.dir/main.cpp.o -o testProject -L/usr/local/lib -lMagick++-7.Q16HDRI -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI && :
[build] /usr/local/lib/libMagick++-7.Q16HDRI.so: file not recognized: file format not recognized
[build] collect2: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[build] Build finished with exit code 1
If the second include is commented out then the program compiles fine and runs on the Pi. My feeling is that this could be an issue with the ImageMagick libraries not being correctly configured to be cross-compiled. But I'm clutching at straws there.