Here's the function prototype declaration defined in utils.hpp (NON OOP, so not in any class)
static void create_xy_table(const k4a_calibration_t *calibration, k4a_image_t xy_table);
static void generate_point_cloud(const k4a_image_t depth_image,
                                 const k4a_image_t xy_table,
                                 k4a_image_t point_cloud,
                                 int *point_count);
static void write_point_cloud(const char *file_name, const k4a_image_t point_cloud, int point_count);
And I have their definitions in utils.cpp which includes utils.hpp.
When I call use any of the function at main function in main.cpp, I get the following error:
/tmp/ccFcMfYB.o: In function `main':
main.cpp:(.text+0x208): undefined reference to 
`create_xy_table(_k4a_calibration_t const*, _k4a_image_t*)
Compilation command:
g++ -o build/testtest src/main.cpp src/utils.cpp -I./include -lk4a
Defining all functions as not static and compiling works perfectly!! I can't wrap my head around this.
- What exactly is happening?
- What should one do to properly include / link if one needs to define and link static functions?
My System Config: gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
EDIT: Here's my function definition in utils.cpp:
static void create_xy_table(const k4a_calibration_t *calibration, k4a_image_t xy_table)
{
    k4a_float2_t *table_data = (k4a_float2_t *)(void *)k4a_image_get_buffer(xy_table);
    int width = calibration->depth_camera_calibration.resolution_width;
    int height = calibration->depth_camera_calibration.resolution_height;
    k4a_float2_t p;
    k4a_float3_t ray;
    int valid;
    for (int y = 0, idx = 0; y < height; y++)
    {
        p.xy.y = (float)y;
        for (int x = 0; x < width; x++, idx++)
        {
            p.xy.x = (float)x;
            k4a_calibration_2d_to_3d(
                calibration, &p, 1.f, K4A_CALIBRATION_TYPE_DEPTH, K4A_CALIBRATION_TYPE_DEPTH, &ray, &valid);
            if (valid)
            {
                table_data[idx].xy.x = ray.xyz.x;
                table_data[idx].xy.y = ray.xyz.y;
            }
            else
            {
                table_data[idx].xy.x = nanf("");
                table_data[idx].xy.y = nanf("");
            }
        }
    }
}
EDIT2:
Here is how I have done things in main.cpp.
k4a_calibration_t calibration;
k4a_image_t xy_table = NULL;
/*
Calibration initialization codes here
*/
create_xy_table(&calibration, xy_table);
 
     
    