Undefined Symbol issue with Bazel and external library

Hello everyone,
I’m writing some code to manage a GPS sensor that relies on its own sdk.
This is what I did:

I created a new package in ISACC_ROOT/packages /Sensor/ with it’s Sensor.hpp and Sensor.cpp and BUILD file.
There is a folder in ISAAC_ROOT/packages/Sensor/SensorSDK that contains several folders and subfolders with .h and .c to manage the sensor.

The BUILD file I wrote looks like this:

load("//engine/build:isaac.bzl", "isaac_cc_module")

    name = "Sensor",
    srcs = ["Sensor.cpp"],
    hdrs = ["Sensor.hpp"],
    deps = [":SensorSDK"]

name = "SensorSDK",
    srcs = glob(["SensorSDK/**/*.c", "SensorSDK/**/*.h"]),
    includes = ["SensorSDK/library/include/", "SensorSDK/library/user_functions/", "SensorSDK/utilities/include/"]

Everything seems to compile, however when I try to run any app that includes this module, I get an undefined symbol at runtime. The undefined symbol is one of the functions of the SDK so this seems a linking problem, but I have no clues on what I’m doing wrong.

Thanks for your help!

Hi, @d.desimone

It’s a little hard to pinpoint the issue here as we don’t see the exact error message, neither the SDK you are using.
Here are several things to try:
1, Make sure the symbol needed is actually provided in SensorSDK;
2, Double check the symbol with nm -d libSensor_module.so;
3, Make sure the symbol is referenced with proper mangling, as C++ usually mangle the symbols while C code does not.


Hi @yangl,
thanks for your help! It was indeed a mangling problem, and using some “extern C” here and there in the sensorSDK solved the issue.
Thanks again for your suggestions!