3

I try to crosscompile a c++-code for an arm-processor from a linux-ubuntu-vm.

A normal compilation works without errors. When I try the following command I've got an error:

arm-linux-gnueabihf-g++ main.cpp onnx.proto3.pb.cc -o readonnx pkg-config --cflags --libs protobuf

--> /usr/local/lib/libprotobuf.so: file not recognized: File format not recognized collect2: error: ld returned 1 exit status

How can I compile my code for an Intel Cyclone V (Linux Angstrom)?

file /usr/local/lib/libprotobuf.so

--> /usr/local/lib/libprotobuf.so: symbolic link to libprotobuf.so.20.0.0

USER9123
  • 61
  • 2
  • 6

2 Answers2

3

I've solved the problem. You have to compile the protobuf-compiler for arm.

sudo ./configure --prefix=/usr/local/lib_arm --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++

Now it works fine.

Thanks

USER9123
  • 61
  • 2
  • 6
  • your solution solved also my problem to cross compile sqlite3. I had the same error in Eclipse: file format not recognized – Lorenzo May 17 '20 at 00:29
0

You need to cross-compile the libprotobuf.so library file also.

Currently you are trying to link against the libprotobuf.so that is installed on your host system, which is presumably x86 version and thus unknown for ARM compiler.

jpa
  • 10,351
  • 1
  • 28
  • 45