mpromonet / v4l2onvif

ONVIF server for V4L2 Devices
GNU General Public License v3.0
118 stars 61 forks source link

RISC-V architecture #12

Open sidharthasajeev2000 opened 11 months ago

sidharthasajeev2000 commented 11 months ago

Hi Is it possible to cross-compile the source code for RISC-V Architecture?

mpromonet commented 11 months ago

Hi, It should. Best Regards Michel

sidharthasajeev2000 commented 11 months ago

Hi,I tried to compile with my cross-compiler like I did for v4l2rtspserver . But I think it only compiles the v4l2rtspserver part in the onvif folder not the other files and gave me this.

/usr/bin/ld: liblibv4l2rtspserver.a(BasicTaskScheduler.cpp.o): Relocations in generic ELF (EM: 243) /usr/bin/ld: liblibv4l2rtspserver.a(BasicTaskScheduler.cpp.o): Relocations in generic ELF (EM: 243) /usr/bin/ld: liblibv4l2rtspserver.a(BasicTaskScheduler.cpp.o): Relocations in generic ELF (EM: 243) /usr/bin/ld: liblibv4l2rtspserver.a(BasicTaskScheduler.cpp.o): Relocations in generic ELF (EM: 243) /usr/bin/ld: liblibv4l2rtspserver.a(BasicTaskScheduler.cpp.o): Relocations in generic ELF (EM: 243) /usr/bin/ld: liblibv4l2rtspserver.a(BasicTaskScheduler.cpp.o): Relocations in generic ELF (EM: 243) /usr/bin/ld: liblibv4l2rtspserver.a: error adding symbols: file in wrong format collect2: error: ld returned 1 exit status make: *** [Makefile:76: onvif-server.exe] Error 1

Do you know,what should i do?

didomenico commented 11 months ago

It is possible, I have done it. From your error message, it looks like your libv4l2rtspserver was built for the host architecture instead of risc-v. The cross compiling flags are not relayed to some of the dependencies, including v4l2rtspserver. You have to look at the Makefiles and use the commands of the targets manually to build it. These were the commands I used to build liblibrtspserver.a:

git submodule update --recursive --init v4l2rtspserver
cd v4l2rtspserver && cmake -DALSA=OFF -DCMAKE_CXX_FLAGS=-I[openssl/ssl.h folder] -DCMAKE_CXX_COMPILER=your-riscv-c++-cross-compiler -DCMAKE_C_COMPILER=your-riscv-c-cross-compiler
make libv4l2rtspserver
sidharthasajeev2000 commented 10 months ago

riscv64-eyenix-linux-gnu-c++ -std=c++11 -g2 -I inc -I ws-discovery/gsoap/ -I gen -I /usr/include -I /usr/share/gsoap/plugin -DWITH_DOM -DWITH_OPENSSL -DSOAP_PURE_VIRTUAL -fpermissive -pthread -DVERSION=\"a59b554-dirty\" -I v4l2rtspserver/live/groupsock/include -I v4l2rtspserver/live/liveMedia/include -I v4l2rtspserver/live/UsageEnvironment/include -I v4l2rtspserver/live/BasicUsageEnvironment/include -I v4l2rtspserver/inc -I v4l2rtspserver/libv4l2cpp/inc -c -o src/onvif-server.o src/onvif-server.cpp In file included from /usr/include/ctype.h:39, from /opt/riscv/eyenix/riscv64-eyenix-linux-gnu/include/c++/10.1.0/cctype:42, from /opt/riscv/eyenix/riscv64-eyenix-linux-gnu/include/c++/10.1.0/bits/localefwd.h:42, from /opt/riscv/eyenix/riscv64-eyenix-linux-gnu/include/c++/10.1.0/ios:41, from /opt/riscv/eyenix/riscv64-eyenix-linux-gnu/include/c++/10.1.0/istream:38, from /opt/riscv/eyenix/riscv64-eyenix-linux-gnu/include/c++/10.1.0/sstream:38, from src/onvif-server.cpp:20: /opt/riscv/eyenix/sysroot/usr/include/bits/endian.h:2:3: error: #error "Never use <bits/endian.h> directly; include instead." 2 | # error "Never use <bits/endian.h> directly; include instead."

what file should I edit to rectify it?
sidharthasajeev2000 commented 10 months ago

when making the new repository v4l2rtspserver builds in rsicV rest are being build in x86 .This causes linking problem.so we edited the make file a bit a got the above response.

we hardcoded CC and CXX

-DCMAKE_CXX_COMPILER=riscv64-eyenix-linux-gnu-c++ -DCMAKE_C_COMPILER=riscv64-eyenix-linux-gnu-gcc

and made changes here also

SYSROOT?=$(shell $(CXX) --print-sysroot)

CXX:=riscv64-eyenix-linux-gnu-c++

mpromonet commented 10 months ago

Hi,

Did you try ?

make CC=riscv64-eyenix-linux-gnu-gcc CXX=riscv64-eyenix-linux-gnu-g++

Best Regards, Michel.

sidharthasajeev2000 commented 10 months ago

it provided me with this error PREFIX=/usr SYSROOT=/opt/riscv/eyenix/bin/../sysroot DESTDIR=/usr/bin VERSION=a59b554 mkdir -p gen /opt/riscv/eyenix/bin/../sysroot/usr/bin/wsdl2h -d -Ntev -W -L -o gen/onvif.h wsdl/b-2.xsd wsdl/bf-2.xsd wsdl/bw-2.wsdl wsdl/common.xsd wsdl/deviceio.wsdl wsdl/devicemgmt.wsdl wsdl/display.wsdl wsdl/event.wsdl wsdl/imaging.wsdl wsdl/include wsdl/media.wsdl wsdl/onvif.xsd wsdl/ptz.wsdl wsdl/r-2.xsd wsdl/receiver.wsdl wsdl/recording.wsdl wsdl/replay.wsdl wsdl/rw-2.wsdl wsdl/search.wsdl wsdl/t-1.xsd make: /opt/riscv/eyenix/bin/../sysroot/usr/bin/wsdl2h: No such file or directory make: *** [Makefile:44: gen/onvif.h] Error 127

mpromonet commented 10 months ago

Hi,

You need to specify GSOAP_BIN to get wsdl2h from the host, something like:

make CC=riscv64-eyenix-linux-gnu-gcc CXX=riscv64-eyenix-linux-gnu-g++ GSOAP_BIN=/usr/bin

Best Regards, Michel.

sidharthasajeev2000 commented 10 months ago

hi While cross-compiling i am encountering problems with gsoap should I try and cross compile it for my project and then do this?