C API works but CPP API doesn't work

I’m working in windows, and I can compile and run test samples with C API very well, but I get error when working with C++ API.

I tried to put them together to test, and still, C API works but CPP API doesn’t.

//These lines can get succeed.
size_t number_of_devices = 0;
hailo_pcie_device_info_t pcie_device_info[8];
status = hailo_scan_pcie_devices(pcie_device_info, 8, &number_of_devices);
hailo_status s = hailo_create_hef_file(&hef, hef_path.c_str());

//But the cpp functions cannot succeed. it cannot get any device by this line
auto all_devices = Device::scan_pcie();

//and raise exception when create hel by this line
auto hef_exp = Hef::create(hef_path);

Can you please help me out?

hey @dliu

are you using the hailort namespace ? because the Hef is in it .

please check out this example to know how to use it correctly Hailo-Application-Code-Examples/runtime/cpp/detection/async_yolov5/multi_async.cpp at b23e4f3454247900e634bf8be638683c723d5ccb · hailo-ai/Hailo-Application-Code-Examples · GitHub

or you can check any other cpp example here


Hi @omria

Yes I used the namespace, otherwise I won’t be able to compile the solution.

And I’m using the sample code exactly, and get crashed in cpp API.


Hi @dliu,
Since ABI compatability is more sensitive on C++ from C, our reccomendation is to compile libhailort from sources on your specific system, if you want to use the C++ API.
Another option is to use hte C-API, while the rest of the application in C++, like in this example:
Kaiwei0323/Yolov8-Capsules-Tablets-Detection (github.com)

In Windows, the Hailo C++ API creates many errors.

The first erros is the can’t “#include<hailort.hpp>” , which can be resolved by understanding the error code message and correcting some of the relevant source codes.

The second error is the style code that works with the gcc compiler, and some codes do not work in the Visual Studio Windows environment.

If you correct that part, there is a third error.

The third error may not work or obtain an incorrect value for unknown reasons, even if the previous two errors are corrected so that they can be compiled.

To address this, I greate suggest to use the C API.

It is very clean, safe, and fast.

good luck.

last, I made a program that uses hailo-8 multi-chips in a Windows environment, which works very well and is about to go on sale.

hailo-8 is a very good product.