Hi,
I hope this is the right place to ask.
I’m trying to add a new rangefinder, which uses a proprietary static library. Creating a new dummy rangefinder under libraries/AP_Rangefinder works fine, as does linking it to the existing code so it can be selected, but when I modify the code to call the static library I’m getting compilation errors.
The code includes:
- libraries/AP_RangeFinder/AP_RangeFinder_ISA500.cpp:
...
#include <AP_HAL/AP_HAL.h>
#include "AP_RangeFinder_ISA500.h"
#include <AP_SerialManager/AP_SerialManager.h>
#include "ISA500/IslComms.h"
#include <GCS_MAVLink/GCS.h>
...
AP_RangeFinder_ISA500::AP_RangeFinder_ISA500(RangeFinder::RangeFinder_State &_state, AP_SerialManager &serial_manager) :
AP_RangeFinder_Backend(_state) {
gcs().send_text(MAV_SEVERITY_INFO, "ISA library version: %d ", IslComms::GetVersion());
...
- libraries/AP_RangeFinder/AP_RangeFinder_ISA500.h:
...
#include "RangeFinder.h"
#include "RangeFinder_Backend.h"
#include "ISA500/IslComms.h"
...
- libraries/AP_RangeFinder/ISA500/IslComms.h:
...
class IslComms
{
public:
IslComms();
~IslComms();
static uint8_t* GetVersion();
static void Run(int32_t deltaMs);
static void ProcessNewData(IslDevice* device, uint8_t* data, int32_t length);
static IslDevice* AddDevice(IslDevice::devicePid_t type, void(*TransmitData)(uint8_t* data, int32_t length));
static IslDevice* AddMultidropDevice(IslDevice::devicePid_t type, IslDevice* device);
static void DeleteDevice(IslDevice* device);
};
...
- libraries/AP_RangeFinder/ISA500/IslComms.a - a static library, that I have no access to the code for
When I compile, it continues for a while and then gives a number of errors of the form:
/home/andrew/ardupilot/build/px4-v2/lib/bin/libarducopter.a(AP_RangeFinder_ISA500.cpp.0.o): In function `AP_RangeFinder_ISA500::AP_RangeFinder_ISA500(RangeFinder::RangeFinder_State&, AP_SerialManager&)':
/home/andrew/ardupilot/build/px4-v2/../../libraries/AP_RangeFinder/AP_RangeFinder_ISA500.cpp:55: undefined reference to `IslComms::GetVersion()'
(Where ‘IslComms::GetVersion()’ is a function in IslComms.h and IslComms.a; each of the errors corresponds to a different call to a library function)
Things I’ve tried:
- Editing wscript to add the following in def configure(cfg):
cfg.env.append_value("LINKFLAGS", ["-Llibraries/AP_RangeFinder/ISA500/", "-l:IslComms.a"])
- Editing Tools/ardupilotwaf/boards.py to add the following to env.CXXFLAGS:
class px4(Board):
...
def configure_env(self, cfg, env):
...
env.CXXFLAGS += [
...
'-L/home/andrew/ardupilot/libraries/AP_RangeFinder/ISA500',
'-l:IslComms.a',
]
- Looking through various other build files to see if I can find where I should be linking it
But nothing has changed the result.
In case it helps, I’m using ArduCopter on a Pixhawk. If I comment out the calls to the static library then everything seems to compile fine.
Does anyone have any suggestions for things I can try?
Many thanks