0

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.

Alasdair
  • 1
  • 1
  • Did you install or cross-compile `libMagick++` for `arm-linux-gnueabihf`? If yes you might have to tell the compiler/linker where to find it. Or in general where to find libraries for your target. – Bodo Jul 02 '21 at 12:46
  • No - ```libmagick++``` isn't cross-compiled. I made my installation with ```./configure``` ```make``` ```make install``` - Hands up: I don't know how to cross-compile it. – Alasdair Jul 02 '21 at 13:40
  • Maybe you should read tutorials about cross-compiling, see e.g. https://stackoverflow.com/questions/19162072/how-to-install-the-raspberry-pi-cross-compiler-on-my-linux-host-machine/58559140#58559140 or https://medium.com/@au42/the-useful-raspberrypi-cross-compile-guide-ea56054de187 (I just found these with a Google search for `libmagick raspberrypi cross-compile`. Unfortunately I did not find any specific instructions for `libmagick++`.) – Bodo Jul 02 '21 at 13:53

0 Answers0