This is the code:
#include <iostream> #include <HAPI/HAPI.h> #include <HAPI/HAPI_Common.h> void CheckHAPIError(HAPI_Result result, const HAPI_Session& session) { if (result != HAPI_RESULT_SUCCESS) { int bufferLength; HAPI_GetStatusStringBufLength(&session, HAPI_STATUS_CALL_RESULT, HAPI_STATUSVERBOSITY_ERRORS, &bufferLength); char* statusString = new char[bufferLength]; HAPI_GetStatusString(&session, HAPI_STATUS_CALL_RESULT, statusString, bufferLength); std::cerr << "HAPI error: " << statusString << std::endl; delete[] statusString; exit(1); } } int main() { std::cout << "Initializing Houdini Engine session..." << std::endl; HAPI_Session session; HAPI_CookOptions cookOptions = HAPI_CookOptions_Create(); HAPI_Result result; result = HAPI_CreateInProcessSession(&session); std::cout << "HAPI_CreateInProcessSession result: " << result << std::endl; CheckHAPIError(result, session); result = HAPI_Initialize(&session, &cookOptions, true, -1, nullptr, nullptr, nullptr, nullptr, nullptr); std::cout << "HAPI_Initialize result: " << result << std::endl; CheckHAPIError(result, session); std::cout << "Cleaning up Houdini Engine session..." << std::endl; result = HAPI_Cleanup(&session); std::cout << "HAPI_Cleanup result: " << result << std::endl; CheckHAPIError(result, session); std::cout << "Finished successfully." << std::endl; return 0; }
This builds without an issue.
When the program is ran, this is its output:
Initializing Houdini Engine session...
HAPI_CreateInProcessSession result: 0
HAPI_Initialize result: 0
Cleaning up Houdini Engine session...
HAPI_Cleanup result: 0
Finished successfully.
Then this exception happens (See attachment).
The exception is thrown from libPDGD.dll.
Have I forgot to do clean up something in my code snippet?