对符号'_ZN5boost6system15system_categoryEv'的未定义引用添加符号时出错:命令行缺少DSO

时间:2019-05-07 16:55:00

标签: cmake ubuntu-18.04 cxx

运行make时,出现以下错误:

john@john-Inspiron-7720:~/sdrportal/SDRPortal/build$ make
[  8%] Built target genc
[ 82%] Built target sdrportalShared
[ 86%] Linking CXX executable uhdd
/usr/bin/ld: CMakeFiles/uhdd.dir/uhd_daemon.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
//usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
src/CMakeFiles/uhdd.dir/build.make:98: recipe for target 'src/uhdd' failed
make[2]: *** [src/uhdd] Error 1
CMakeFiles/Makefile2:109: recipe for target 'src/CMakeFiles/uhdd.dir/all' failed
make[1]: *** [src/CMakeFiles/uhdd.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

所以一段时间以来,我一直在试图解决这个问题,我尝试过手动链接boost库,但是仍然发生相同的错误。

我还注意到这可能是编译器问题。

此外,如果有人使用过gnuradio / SDR,尤其是Ben Kempke库(https://github.com/bpkempke),您可能会更轻松地帮助我解决这个问题。

(很抱歉,如果帖子令人困惑或解决方案太微不足道,软件并不是我真正的专长,我刚被分配到一个涉及软件定义无线电的研究项目,我需要弄清楚如何使这些Kempke库正常工作,或者有人可以指导我开发一种为gnu无线电开发自己的CCSDS编码,解码和相关块的方法。

我也尝试了以下解决方案:How do you add Boost libraries in CMakeLists.txt?

使用Spandan的方法:make不能成功完成,因为“目标”不是此“项目”正在“构建”的可执行文件。

我还想尝试以下解决方案:https://github.com/raulmur/ORB_SLAM2/issues/535,但是在此编译器中,我没有找到包含CMakeLists.txt自变量的Makefileset(LIBS...)包。

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
project(SDRPortal)

#Version 0.1
set(SDRPortal_VERSION_MAJOR 0)
set(SDRPortal_VERSION_MINOR 1)

#Set the paths to find the correct header files
include_directories(
    ${CMAKE_SOURCE_DIR}/lib
)

#And the library which provides dynamic linking (will be different for NaCl though...)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

#Find the threading library 'package'
find_package(Threads)
find_package(UHD)
find_package(LibHackRF)
find_package(LibRTLSDR)
find_package(Portaudio)

#Add in debugging symbols for now... TODO: Get rid of debugging symbols
set(CMAKE_CXX_FLAGS "-g -Wall -std=c++0x")

add_subdirectory(lib)
add_subdirectory(src)

set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)

调用 cmake

john@john-Inspiron-7720:~/sdrportal/SDRPortal/build$ cmake ../
-- Configuring done
-- Generating done
-- Build files have been written to: /home/john/sdrportal/SDRPortal/build

我只需要制作并安装此软件包。它将在gnuradio伴侣中生成可用的块。

按照Spandan的方法,即使调用cmake ../,我也会得到更多的错误和警告。

john@john-Inspiron-7720:~/sdrportal/SDRPortal/build$ cmake ../
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:32 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:32 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:32 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:32 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:32 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:32 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:32 (find_package)


-- Could NOT find Boost
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:34 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:34 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:34 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:34 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:34 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:34 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:34 (find_package)


CMake Error at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1947 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:34 (find_package)


CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
  Imported targets and dependency information not available for Boost version
  (all versions older than 1.33)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.10/Modules/FindBoost.cmake:1558 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:35 (find_package)


CMake Error at /usr/share/cmake-3.10/Modules/FindBoost.cmake:1947 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:35 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/john/sdrportal/SDRPortal/build/CMakeFiles/CMakeOutput.log".
See also "/home/john/sdrportal/SDRPortal/build/CMakeFiles/CMakeError.log".

portalDataSocket.h

#ifndef PORTAL_DATA_H
#define PORTAL_DATA_H

#include "hierarchicalDataflowBlock.h"
#include "genericSocketInterface.h"
#include "streamConverter.h"
#include "generic.h"

class genericSDRInterface;

class portalDataSocket : public hierarchicalDataflowBlock{
public:
    portalDataSocket(socketType in_socket_type, int socket_num);
    ~portalDataSocket();

    int getPortNum();
    void setUID(int in_uid);
    int getUID();

    streamType getStreamType(){return stream_type;};
    void setStreamType(streamType in_stream_type){stream_type = in_stream_type;};

    //Methods inherited from hierarchicalDataflowBlock
    virtual void dataFromUpperLevel(void *data, int num_bytes, int local_up_channel=0);
    virtual void dataFromLowerLevel(void *data, int num_bytes, int local_down_channel=0);
private:
    int uid;
    genericSocketInterface *socket_int;
    streamType stream_type;
};

#endif

portalCommandSocket.cc

#include <iostream>
#include <vector>
#include <sstream>
#include <stdio.h>
#include "portalDataSocket.h"
#include "portalCommandSocket.h"
#include "streamConverter.h"

portalCommandSocket::portalCommandSocket(socketType in_socket_type, int socket_num, genericSDRInterface *in_sdr_int){
    sdr_int = in_sdr_int;
    cmd_socket_type = in_socket_type;
    profile_loaded = false;

    //Create the socket that we'll be listening on...
    socket_int = new genericSocketInterface(in_socket_type, socket_num);

    //Link upper and lower 
    this->addLowerLevel(socket_int);
    socket_int->addUpperLevel(this);
}

portalCommandSocket::~portalCommandSocket(){
    delete socket_int;
}

void portalCommandSocket::dataFromUpperLevel(void *data, int num_bytes, int local_up_channel){
    //Data coming in from the SDR -- should only be handled by portalDataSocket...

}

void portalCommandSocket::dataFromLowerLevel(void *data, int num_messages, int local_down_channel){
    //Data coming in from the socket

    //First, we need to make sure data is casted correctly (data is a pointer to a vector of messages)
    messageType *in_messages = static_cast<messageType *>(data);
    std::cout << "GOT HERE" << std::endl;

    //Insert historic messages into a string stream so as to easily extract lines
    //TODO: There probably needs to be one stringstream for each channel, otherwise parsing will get confused...
    static std::stringstream command_stream;
    for(int ii=0; ii < num_messages; ii++){
        std::string in_data_string(in_messages[ii].buffer,in_messages[ii].num_bytes);
        command_stream << in_data_string;
    }

    //Now parse out incoming commands
    std::string current_command;
    if(!getline(command_stream, current_command).fail()){
        std::stringstream arg_stream(current_command);
        std::string command, arg1, arg2;

        //Process the command, first argument, and second argument
        arg_stream >> command;
        arg_stream >> arg1;
        arg_stream >> arg2;

        //cout << command << " " << arg1 << " " << arg2 << std::endl;

        //Now do whatever we need to do based on the received command
        //TODO: Put in some error checking here
        char response[20];
        messageType response_message;
        response_message.socket_channel = in_messages[0].socket_channel;
        response_message.buffer = response;
        try{
            if(command == "NEWCHANNEL"){
                //Figure out what type of socket we want to make here...
                socketType new_channel_type = SOCKET_TCP;
                if(arg1 == "WS_TEXT")
                    new_channel_type = SOCKET_WS_TEXT;
                else if(arg1 == "WS_BINARY")
                    new_channel_type = SOCKET_WS_BINARY;

                //The client wants to add a data channel connection...
                // Better create one! (and pass the random port back to the client so that he can connect to it...)
                portalDataSocket *data_socket = new portalDataSocket(new_channel_type, 0);

                cur_channel = sdr_int->addChannel(data_socket);
                data_socket->addUpperLevel(sdr_int);
                response_message.num_bytes = sprintf(response_message.buffer,"%d: %d\r\n", cur_channel, data_socket->getPortNum());
                dataToLowerLevel(&response_message, 1);
            } else if(command == "CHANNEL"){
                if(isInteger(arg1)){
                    int candidate_channel = strtol(arg1.c_str(), NULL, 0);
                    if(sdr_int->getNumAllocatedChannels() > candidate_channel)
                        cur_channel = candidate_channel;
                    else
                        throw badArgumentException(badArgumentException::OUT_OF_BOUNDS, 1, arg1);
                } else
                    throw badArgumentException(badArgumentException::MALFORMED, 1, arg1);
            } else if(command == "RXCHANNEL"){
                if(isInteger(arg1)){
                    sdr_int->bindRXChannel(strtol(arg1.c_str(), NULL, 0), cur_channel);
                    response_message.num_bytes = sprintf(response_message.buffer,"%d\r\n",cur_channel);
                    dataToLowerLevel(&response_message, 1);
                } else
                    throw badArgumentException(badArgumentException::MALFORMED, 1, arg1);
            } else if(command == "TXCHANNEL"){
                if(isInteger(arg1)){
                    sdr_int->bindTXChannel(strtol(arg1.c_str(), NULL, 0), cur_channel);
                    response_message.num_bytes = sprintf(response_message.buffer,"%d\r\n",cur_channel);
                    dataToLowerLevel(&response_message, 1);
                } else
                    throw badArgumentException(badArgumentException::MALFORMED, 1, arg1);
            } else if(command == "DATATYPE"){
                streamType new_type = stringToStreamType(arg1);
                if(new_type != STREAM_UNKNOWN){
                    sdr_int->setStreamDataType(new_type, cur_channel);
                    response_message.num_bytes = sprintf(response_message.buffer,"%s\r\n",arg1.c_str());
                    dataToLowerLevel(&response_message, 1);
                } else
                    throw badArgumentException(badArgumentException::MALFORMED, 1, arg1);
            } else if(command == "SDR_DISCONNECT"){
                //This command disconnects the SDR from SDRPortal for use elsewhere
                sdr_int->disconnect();
            } else if(command == "SDR_CONNECT"){
                //This command re-connects a previously-disconnected SDR to SDRPortal
                sdr_int->connect();
            } else if(command == "TX_LOGFILE"){
                //TODO: Implement this...
            } else if(command == "RX_LOGFILE"){
                //TODO: Implement this...
            } else if(command == "LOAD_PROFILE"){
                //TODO: Profiles need to be instantiated on a connection-by-connection basis...
                if(isValidProfile(arg1)){
                    //Unload the current profile if there is one
                    if(profile_loaded)
                        delete cur_profile;

                    //Now load up a new profile with the specified name
                    cur_profile = new portalProfile(arg1);
                    profile_loaded = true;
                }
            } else if(command == "UNLOAD_PROFILE"){
                //Unload the current profile if there is one
                if(profile_loaded)
                    delete cur_profile;
                profile_loaded = false;
            } else if(profile_loaded && cur_profile->acceptsCommand(command)){
                //Send profile-specific command off to the currently-loaded profile
                std::string response = cur_profile->sendCommand(current_command);
                response_message.num_bytes = response.length();
                memcpy(response_message.buffer, &response[0], response_message.num_bytes);
                dataToLowerLevel(&response_message, 1);
            } else {
                sdr_int->setSDRParameter(cur_channel, command, arg1);
            }
        } catch(badArgumentException const& e){
            std::stringstream response;
            response << "?" << e.what() << std::endl;
            dataToLowerLevel((void*)(response.str().c_str()),response.gcount());
        } catch(invalidCommandException const& e){
            std::stringstream response;
            response << "?" << e.what() << std::endl;
            dataToLowerLevel((void*)(response.str().c_str()),response.gcount());
        }

        //Query-based commands
        response_message.num_bytes = 0;
        rxtxChanInfo cur_chan_info = sdr_int->getChanInfo(cur_channel);
        if(command.substr(0,6) == "RXFREQ")
            response_message.num_bytes = sprintf(response_message.buffer,"%f\r\n",sdr_int->getRXFreq(cur_chan_info).getDouble());
        else if(command.substr(0,6) == "TXFREQ")
            response_message.num_bytes = sprintf(response_message.buffer,"%f\r\n",sdr_int->getTXFreq(cur_chan_info).getDouble());
        else if(command.substr(0,6) == "RXGAIN")
            response_message.num_bytes = sprintf(response_message.buffer,"%f\r\n",sdr_int->getRXGain(cur_chan_info).getDouble());
        else if(command.substr(0,6) == "TXGAIN")
            response_message.num_bytes = sprintf(response_message.buffer,"%f\r\n",sdr_int->getTXGain(cur_chan_info).getDouble());
        else if(command.substr(0,6) == "RXRATE")
            response_message.num_bytes = sprintf(response_message.buffer,"%d\r\n",(int)(sdr_int->getRXRate(cur_chan_info).getDouble()+0.5));
        else if(command.substr(0,6) == "TXRATE")
            response_message.num_bytes = sprintf(response_message.buffer,"%d\r\n",(int)(sdr_int->getTXRate(cur_chan_info).getDouble()+0.5));

        //Send off the response
        if(response_message.num_bytes > 0)
            dataToLowerLevel(&response_message,1);
    }

}

0 个答案:

没有答案