I am developing in unreal engine 4 for CARLA simulation. Undefined symbol error pops up during the run-time. Following is my code:
DataStructure.h
    #pragma once
    #include <cstdint>
    #include <vector>
    namespace carla {
    namespace sensor {
    namespace s11n {
        class DataStructure{
            friend class LidarMeasurement;
            public:    
            typedef struct{
              uint8_t distance[2];
              uint8_t reflectivity;      
            }data_point;
            typedef struct{
              uint8_t flag[2];
              uint8_t Azimuth[2];
              std::vector<data_point> points;
            }data_block;
            typedef struct{
              uint8_t UDP[42];
              std::vector<data_block> data;
              uint32_t time_stamp;
              uint16_t factory;
            }data_packet;
            static data_point current_data_point;
            static data_block current_data_block;
            static data_packet current_data_packet;
            static std::vector<data_packet> packets_from_current_frame;
            static uint16_t number_of_packets_this_frame;
            public:
            static void fill_block(float azi, float reflectivity, float distance);
            static void fill_packet();     
        };
    }
    }
    }
DataStructure.cpp
#include<stdint.h>
#include "carla/sensor/s11n/DataStructure.h"
namespace carla {
namespace sensor {
namespace s11n {
    DataStructure::data_point DataStructure::current_data_point;
    DataStructure::data_block DataStructure::current_data_block;
    DataStructure::data_packet DataStructure::current_data_packet;
    static uint16_t block_itr = 0;
    static uint16_t packet_itr = 0;
    std::vector<DataStructure::data_packet> DataStructure::packets_from_current_frame;
    void DataStructure::fill_block(float azi, float reflectivity, float distance){
        if(block_itr == 0){
            current_data_block.points.clear();
            current_data_block.flag[0] = 0xFF;
            current_data_block.flag[1] = 0xEE;
            uint16_t azimuth = static_cast<uint16_t>(azi * 100);
            current_data_block.Azimuth[1] = (azimuth & 0xFF00) >> 0x08;
            current_data_block.Azimuth[0] = (azimuth & 0x00FF);
        }
        uint16_t dist = static_cast<uint16_t>((distance * 100)/2); 
        current_data_point.distance[0] = static_cast<uint8_t>(dist % 0x100);
        current_data_point.distance[1] = static_cast<uint8_t>(dist / 0x100);
        current_data_point.reflectivity = static_cast<uint8_t>(reflectivity * 255);
        current_data_block.points.push_back(current_data_point);
        block_itr ++;
        if(block_itr == 32){
            DataStructure::fill_packet();
            block_itr = 0;
        }
    }
    void DataStructure::fill_packet(){
        if(packet_itr == 0){
            current_data_packet.data.clear();
            current_data_packet.factory = 0x2222;
        }
        current_data_packet.data.push_back(current_data_block);
        packet_itr ++;
        if(packet_itr == 12){
            packet_itr = 0;
            packets_from_current_frame.push_back(current_data_packet);
        }
    }
}
}
}
Error message:
/home/carla_static/UnrealEngine_4.22/Engine/Binaries/Linux/UE4Editor: symbol lookup error: /home/carla_static/carla/Unreal/CarlaUE4/Plugins/Carla/Binaries/Linux/libUE4Editor-Carla.so: undefined symbol: _ZN5carla6sensor4s11n13DataStructure10fill_blockEfff
This error pops up when I try to use fill_block function in LidarMeasurement class.
Also is it possible to complete the code without cpp? If possible, how can I declare and define static variables?
I performed following steps:
- Added .cpp and .h files (No errors with make Libcarla.Client.Debug)
- After adding the files I deleted binaries and make rebuildto build all modules
- Launched UE4 (make launch) and run python client
I am using - Ubuntu : 18.04 - Carla 0.9.6 - UE 4.22
