2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file library_loader_unix.cpp Implementation of the LibraryLoader for Linux / MacOS */
10 #include "../../stdafx.h"
14 #include "../../library_loader.h"
16 #include "../../safeguards.h"
18 /* Emscripten cannot dynamically load other files. */
19 #if defined(__EMSCRIPTEN__)
21 void *LibraryLoader::OpenLibrary(const std::string
&)
23 this->error
= "Dynamic loading is not supported on this platform.";
27 void LibraryLoader::CloseLibrary()
31 void *LibraryLoader::GetSymbol(const std::string
&)
33 this->error
= "Dynamic loading is not supported on this platform.";
39 void *LibraryLoader::OpenLibrary(const std::string
&filename
)
41 void *h
= dlopen(filename
.c_str(), RTLD_NOW
| RTLD_LOCAL
);
43 this->error
= dlerror();
49 void LibraryLoader::CloseLibrary()
51 dlclose(this->handle
);
54 void *LibraryLoader::GetSymbol(const std::string
&symbol_name
)
56 void *p
= dlsym(this->handle
, symbol_name
.c_str());
58 this->error
= dlerror();
64 #endif /* __EMSCRIPTEN__ */