Файл не распознан /usr/local/lib/libopencv_stitching.so.3.4.1, Cpp, Opencv, RPi toolchain - PullRequest
0 голосов
/ 09 ноября 2018

У меня проблема, когда я пытаюсь создать приложение, используя набор инструментов для RPi. Toolchain устанавливается вместе с руководством из репозитория git. Также есть OpenCV 3.4.1. Я добавлю сюда код из моих файлов cpp и cmakelists.

myClient.cpp:

#include <sys/socket.h>
#include "opencv2/opencv.hpp"
#include <arpa/inet.h>
#include <net/if.h>
#include <unistd.h>
#include <string.h>
#include <cstdlib>
#include <pthread.h>

void run();
void * capture(void *);

int main()
{
    run();
}

void run()
{
    int sockSystemCall, acceptSystemCall,
                bindSystemCall, portNumber;
    char buffer[256];
    pthread_t thread_id;
    struct sockaddr_in serverAddress, clientAddress;
    int clientAddSize;

    portNumber = 3305;

    sockSystemCall = socket(AF_INET, SOCK_DGRAM, 0);

    if(sockSystemCall < 0)
        exit(0);

    // sin_family contains code for address family
    serverAddress.sin_family = AF_INET;
    // sin_addr.s_addr contains ip address
    serverAddress.sin_addr.s_addr = INADDR_ANY;
    // sin_port contains port number
    serverAddress.sin_port = htons(portNumber);

    // bind the server and check if it runs
    bindSystemCall = bind(sockSystemCall, (struct sockaddr *) &serverAddress,
            sizeof(serverAddress) );

    if(bindSystemCall < 0)
        exit(0);

    // listen for connections
    listen(sockSystemCall, 5);

    // accept first incoming and exit if there is an issue
    clientAddSize = sizeof(clientAddress);
    acceptSystemCall = accept(sockSystemCall, (struct sockaddr *) &clientAddress,
                                        (socklen_t *)&clientAddSize);

    if(acceptSystemCall < 0)
        exit(0);

    pthread_create( &thread_id, nullptr, capture, &acceptSystemCall);
}

void * capture(void * pointer)
{
    int serverFor = *(int *)pointer;
    int rows, columns;
    int numberOfDevice = 0;
    cv::VideoCapture captureDevice(numberOfDevice);

    // now it will gain data from camera and send it to server 
    cv::Mat image, grayImage;

    rows = 640;
    columns = 480;
    // CV_8UC1 because i will use utf-8
    image = cv::Mat::zeros(rows, columns, CV_8UC1);

    if( !image.isContinuous() )
        image = image.clone();

    size_t imgSize = image.total() * image.elemSize();
    ssize_t bytes;

    while( true )
    {
        captureDevice >> image;

        cvtColor(image, grayImage, CV_BGR2GRAY);

        bytes = send(serverFor, grayImage.data, imgSize, 0);

        if( bytes < 0 )
            break;
    }

}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.6)# CMake version check
project(clientRPi)                 # Create project
set(CMAKE_CXX_STANDARD 11)         # Enable c++11 standard

set(SOURCE_FILES myClient.cpp)     # Add myClient.cpp file of project root
                                   #directory as source file
add_executable(clientRPi ${SOURCE_FILES}) # Add executable target with source
                                            #files listed in SOURCE_FILES variable

find_package(Threads)
target_link_libraries(clientRPi ${CMAKE_THREAD_LIBS_INIT})

find_package(OpenCV REQUIRED)
target_link_libraries(clientRPi ${OpenCV_LIBS})

# specify system version
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

# Specify the cross compiler
SET(CMAKE_C_COMPILER $ENV{HOME}/Development/toolchains/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER $ENV{HOME}/Development/toolchains/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++)

# Where is the target environment
SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/Development/toolchains/rootfs)

# Search for programs only in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# Search for libraries and headers only in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

и текст вопроса здесь:
[ 50%] Building CXX object CMakeFiles/clientRPi.dir/myClient.cpp.o<br/> [100%] Linking CXX executable clientRPi<br/> /usr/local/lib/libopencv_stitching.so.3.4.1: file not recognized: Nieznany format pliku<br/> collect2: error: ld returned 1 exit status<br/> CMakeFiles/clientRPi.dir/build.make:128: recipe for target 'clientRPi' failed<br/> make[3]: *** [clientRPi] Error 1<br/> CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/clientRPi.dir/all' failed<br/> make[2]: *** [CMakeFiles/clientRPi.dir/all] Error 2<br/> CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/clientRPi.dir/rule' failed<br/> make[1]: *** [CMakeFiles/clientRPi.dir/rule] Error 2<br/> Makefile:118: recipe for target 'clientRPi' failed<br/> make: *** [clientRPi] Error 2 1010 *
*

Для этого проекта я использую CLion. Не совсем сейчас, как справиться с этим. Все для меня ново, поэтому, пожалуйста, игнорируйте плохой код. Буду признателен за каждый ответ.

...