#include "mod.h"
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

int main() {
	mod* modObj;
	mod* (*newModFunc)(void);
	int retVal;
	void *handle;

	printf("DSO Example in C++ - Before loading module..\n");
	fflush(NULL);

	handle = dlopen ("./libmod.so.0.0.0", RTLD_LAZY);
	newModFunc = (mod* (*)()) dlsym(handle, "newObj");

	modObj = (*newModFunc)();

	retVal = modObj->doit(99);

	dlclose(handle);

	printf("After closing module. Got retVal: %d\n", retVal);
	fflush(NULL);

	return 0;
}
