main.cpp
Created with C++BuilderX
#include <iostream>
#ifdef __WIN32__
	#include <windows.h>
#else
	#include <dlfcn.h>
#endif
int main() {
	std::cerr << "Initiating...\n";
	std::cerr << "Loading plugin: ";
#ifdef __WIN32__
	HMODULE plg = LoadLibrary(".\\plugin.dll");
#else
	void *plg = dlopen("./plugin.so", RTLD_LAZY);
#endif
	if (plg == 0) {
		std::cerr << "failed: ";
#ifdef __WIN32__
		std::cerr << GetLastError();
#else
		std::cerr << dlerror();
#endif
		std::cerr << std::endl;
		return EXIT_FAILURE;
	} else {
		std::cerr << "ok.\n";
	}
	std::cerr << "Reading symbol: ";
#ifdef __WIN32__
	bool (*f)() = (bool (*)())GetProcAddress(plg, TEXT("onInit"));
#else
	bool (*f)() = (bool (*)())dlsym(plg, "onInit");
#endif
	if (f == 0) {
		std::cerr << "failed: ";
#ifdef __WIN32__
		std::cerr << GetLastError();
#else
		std::cerr << dlerror();
#endif
		std::cerr << std::endl;
		return EXIT_FAILURE;
	} else {
		std::cerr << "ok.\n";
	}
	bool ret = f();
	if (ret == true) {
		std::cerr << "ret = true\n";
	} else {
		std::cerr << "ret = false\n";
	}
};


main.cpp
Created with C++BuilderX