@@ -97,21 +97,24 @@ unique_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
9797#endif
9898 throw runtime_error (ss.str ());
9999 }
100- function<const char *()> get_ngraph_version_string =
101- reinterpret_cast <const char * (*)()>(DLSYM (handle, " get_ngraph_version_string" ));
102- if (!get_ngraph_version_string)
103- {
104- CLOSE_LIBRARY (handle);
105- throw runtime_error (" Backend '" + type +
106- " ' does not implement get_ngraph_version_string" );
107- }
108100
101+ #ifndef _WIN32
102+ dlerror (); // Clear any pending errors
103+ #endif
109104 function<runtime::Backend*(const char *)> new_backend =
110105 reinterpret_cast <runtime::Backend* (*)(const char *)>(DLSYM (handle, " new_backend" ));
111106 if (!new_backend)
112107 {
108+ string error;
109+ #ifndef _WIN32
110+ const char * err = dlerror ();
111+ error = (err ? err : " " );
112+ #endif
113113 CLOSE_LIBRARY (handle);
114- throw runtime_error (" Backend '" + type + " ' does not implement new_backend" );
114+ throw runtime_error (
115+ " Failed to find symbol 'get_backend_constructor_pointer' in backend "
116+ " library.\n Error='" +
117+ error + " '" );
115118 }
116119
117120 backend = new_backend (config.c_str ());
@@ -156,12 +159,23 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
156159 string library_name = lib_prefix + to_lower (type) + " _backend" + lib_suffix;
157160 string my_directory = file_util::get_directory (find_my_file ());
158161 string library_path = file_util::path_join (my_directory, library_name);
162+ string error;
159163#ifdef _WIN32
160164 SetDllDirectory ((LPCSTR)my_directory.c_str ());
161165 handle = LoadLibrary (library_path.c_str ());
162166#else
167+ dlerror (); // Clear any pending errors
163168 handle = dlopen (library_path.c_str (), RTLD_NOW | RTLD_GLOBAL);
169+ const char * err = dlerror ();
170+ error = (err ? err : " " );
164171#endif
172+ if (!handle)
173+ {
174+ stringstream ss;
175+ ss << " Unable to find backend '" << type << " ' as file '" << library_path << " '" ;
176+ ss << " \n Open error message '" << error << " '" ;
177+ throw runtime_error (ss.str ());
178+ }
165179 return handle;
166180}
167181
0 commit comments