Table of Contents
include/nilorea/n_module.h
Load a shared library at runtime and find its symbols. More...
Detailed Description
Load a shared library at runtime and find its symbols.
Author: Castagnier Mickael
Version: 1.0
Date: 24/09/2026
A plugin host, or a program that uses a driver only when one is installed, opens a library by path or name, looks up entry points by name, and closes it. POSIX does that with dlopen/dlsym/dlclose, Windows with LoadLibrary/GetProcAddress/FreeLibrary; this module is the one place that knows which, so a caller has no platform branch of its own.
Failure to open is not logged above LOG_DEBUG: a program probing for an optional library tries several names and expects most to be absent. What the system said about the last failure is kept per thread and returned by n_module_error().
On Linux with a glibc older than 2.34 the program must link -ldl; the library's Makefile adds it.
Source code
/*
* Nilorea Library
* Copyright (C) 2005-2026 Castagnier Mickael
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __NILOREA_MODULE__
#define __NILOREA_MODULE__
#ifdef __cplusplus
extern "C" {
#endif
#include "nilorea/n_common.h"
#define N_MODULE_ERROR_MAX 512
typedef struct N_MODULE N_MODULE;
N_MODULE* n_module_open(const char* path);
void* n_module_symbol(N_MODULE* module, const char* name);
int n_module_close(N_MODULE** module);
const char* n_module_error(void);
const char* n_module_extension(void);
#ifdef __cplusplus
}
#endif
#endif /* __NILOREA_MODULE__ */
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB