thenoob94 Posted April 19, 2023 Report Share Posted April 19, 2023 os: Debian I've written a c Function and compiled it to a shared object. I call the function in labview and it executes just fine. The function modifies a ".cti" file. When I want to execute the function a second time it fails because labview still takes ownership of the process even after it terminates. When I run the function without labview this error doesn't occur.. This is my function: extern "C"{ int InitSDK(); } int InitSDK() { string ctiPath; string genicamPath; string genicamCachePath; string clProtocolPath; #if defined (WIN32) char buffer[1024] = { 0 }; int res = GetEnvironmentVariableA("GENICAM_GENTL64_PATH", buffer, sizeof(buffer)); if (0 == res) return false; ctiPath = string(buffer); memset(buffer, 0, sizeof(buffer)); res = GetEnvironmentVariableA("SVS_GENICAM_ROOT", buffer, sizeof(buffer)); if (0 == res) return false; genicamPath = string(buffer); memset(buffer, 0, sizeof(buffer)); res = GetEnvironmentVariableA("SVS_GENICAM_CACHE", buffer, sizeof(buffer)); if (0 == res) return false; genicamCachePath = string(buffer); memset(buffer, 0, sizeof(buffer)); res = GetEnvironmentVariableA("SVS_GENICAM_CLPROTOCOL", buffer, sizeof(buffer)); if (0 == res) return false; clProtocolPath = string(buffer); SV_RETURN ret = SVLibInit(ctiPath.c_str(), genicamPath.c_str(), genicamCachePath.c_str(), clProtocolPath.c_str()); #elif defined(__linux__) ctiPath ="./"; SV_RETURN ret = SVLibInit(ctiPath.c_str(), NULL, NULL, NULL); #elif defined(__APPLE__) && defined(__MACH__) ctiPath = "/Library/Frameworks/SVGenSDK.framework/Versions/2.5.8/Libraries/cti"; SV_RETURN ret = SVLibInit(ctiPath.c_str(), NULL, NULL, NULL); #endif if (SV_ERROR_SUCCESS != ret) { printf("SVLibInit Failed! :%d", ret); return -1; } printf("Init worked \n"); return 0; } Quote Link to comment
Rolf Kalbermatter Posted June 17, 2023 Report Share Posted June 17, 2023 (edited) Your problem likely is that SVLibInit() opens a handle to your file(s) and you never release them. Windows (Linux too) will clean up unclosed handles/fileids when a process exits but not before that. So you should also have a function SVLibUninit() or similar that will then release all the resources, and of course call it from LabVIEW when you are done with your software. Once that happens, you can access those files from other processes too, without needing to close LabVIEW. Edited June 17, 2023 by Rolf Kalbermatter Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.