@@ -206,6 +206,8 @@ inline void InitApi() {
206206 Generators::SetLogBool (" ort_lib" , true );
207207 }
208208
209+ OrtApiBaseFn ort_api_base_fn{};
210+
209211#if defined(__linux__) || defined(MACOS_USE_DLOPEN)
210212 // If the GenAI library links against the onnxruntime library, it will have a dependency on a specific
211213 // version of OrtGetApiBase.
@@ -257,18 +259,21 @@ inline void InitApi() {
257259 throw std::runtime_error (std::string (" Failed to load onnxruntime. Set ORTGENAI_LOG_ORT_LIB envvar to enable detailed logging." ));
258260 }
259261
260- OrtApiBaseFn ort_api_base_fn = (OrtApiBaseFn)dlsym (ort_lib_handle, " OrtGetApiBase" );
262+ ort_api_base_fn = (OrtApiBaseFn)dlsym (ort_lib_handle, " OrtGetApiBase" );
261263 if (ort_api_base_fn == nullptr ) {
262264 char * err = dlerror ();
263265 throw std::runtime_error (std::string (" Failed to load symbol OrtGetApiBase: " ) + (err != nullptr ? err : " Unknown" ));
264266 }
265267
266268 InitApiWithDynamicFn (ort_api_base_fn);
267269#else // defined(__linux__) || defined(MACOS_USE_DLOPEN)
268- api = OrtGetApiBase ()->GetApi (ORT_API_VERSION);
270+ ort_api_base_fn = &OrtGetApiBase;
271+ api = ort_api_base_fn ()->GetApi (ORT_API_VERSION);
269272 if (!api)
270273 throw std::runtime_error (" Onnxruntime is installed but is too old, please install a newer version" );
271274#endif // defined(__linux__) || defined(MACOS_USE_DLOPEN)
275+
276+ LOG_INFO (" ORT Version: %s. %s" , ort_api_base_fn ()->GetVersionString (), api->GetBuildInfoString ());
272277}
273278
274279/* * \brief All C++ methods that can fail will throw an exception of this type
0 commit comments