0

i'm currently working on a project where i want to use the Azure Kinect SDK in java. To the best of my knowledge there is no Azure Kinect library for java. So I'm trying to build a bridge between the Azure Kinect library in C++ to Java using JNI.

This is my C++ file called cCode.cpp:

#include "processingXJava_MyClass.h"
#include <iostream>
#include <D:\Dokumente\Hochschule\Bachelorarbeit\Eclipse\processingXJava\src\microsoft.azure.kinect.sensor.1.4.1\build\native\include\k4a\k4a.h>


using namespace std;

JNIEXPORT void JNICALL Java_processingXJava_MyClass_helloC
  (JNIEnv *env, jclass cls){
        std::cout << "Hallo Hallo" << std::endl;

        uint32_t count = k4a_device_get_installed_count();
        
        k4a_device_t device = NULL;
        k4a_device_open(K4A_DEVICE_DEFAULT, &device);

        size_t serial_size = 0;
        k4a_device_get_serialnum(device, NULL, &serial_size);

        char* serial = (char*)(malloc(serial_size));
        k4a_device_get_serialnum(device, serial, &serial_size);



        cout << serial;



    }

I've got the Azure Kinect Package from this site: https://www.nuget.org/packages/Microsoft.Azure.Kinect.Sensor/

The next step is to compile the C++ file. I use the following command to do that: cl -I"C:\Program Files\Java\jdk1.8.0_201\include" -I"C:\Program Files\Java\jdk1.8.0_201\include\win32" -I"D:\Dokumente\Hochschule\Bachelorarbeit\Eclipse\processingXJava\src\microsoft.azure.kinect.sensor.1.4.1\build\native\include\k4a" -LD "cCode.cpp" -Fe"cCode.dll"

When i execute this i get a "LNK2019: unresolved external symbol" error.

Any ideas how to solve this problem?

Druepter
  • 21
  • 3
  • this is a linker error, most likely it is missing some library to link. Usually with g++ you'd pass it via -lsomelib... I see you have "cCode.dll" which you specify with -Fe. I'm not familiar with these cli options... But look for a library which you have to link. EDIT: i see you include k4a.h, but you probably also have to link against this library. – Maxim Chetrusca Aug 04 '21 at 21:22

0 Answers0