Hello Everybody

And that's my Problem:
I've got a class 'CReadData' which opens a shared library under Linux and then calls a method named 'init' from that library, passing a pointer to itself as an argument.

The 'init' function then instantiates the class 'ReaderPlugin', which is implemented in the shared library, and passes the pointer to the 'CReadData' object on to the constructor of 'ReaderPlugin'.

The constructor calls the method 'registerPlugin' of the class 'CReadData' using the pointer it got from 'init' and passes a pointer to itself.

When this 'registerPlugin' method is called, a segmentation fault happens.
I've modified 'registerPlugin' in almost every way. I've removed the templates, removed the argument, made it static in the 'CReadData' class and even run the program on multiple systems with different architectures. All with no success.

Here's the code:

Code:
// CReadData.cpp

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include "CReadData.h"
#include "ReaderInterface.h"

	void *handle, (*fptr)(CReadData*);
	ReaderPlugin* rp;
	
	template <class plugin>
	void CReadData::registerPlugin(plugin p) {
		printf("bar");
	} 

	CReadData::CReadData() {
	}

	int CReadData::openPlugin(const char* plugin) {
	
		this->handle = dlopen(plugin, RTLD_NOW);
		
		*(void **)(&fptr) = dlsym(handle, "init");
		(*fptr)(this);
		
	}
	
	void CReadData::closePlugin() {
		dlclose(this->handle);
	}
Code:
// CReadData.h

class CReadData {

	public:
		CReadData();
		template <class plugin>
		void registerPlugin(plugin p);
		int openPlugin (const char* plugin);
		void closePlugin();
		
	private:
		void *handle;
		
};

Code:
// testPlugin.cpp

#include <stdio.h>
#include <stdlib.h>
#include "CReadData.h"
#include "ReaderInterface.h"

ReaderPlugin::ReaderPlugin(CReadData* read) {
	read->registerPlugin<ReaderPlugin*>(this); // This line seems to cause the error
}

ReaderPlugin* rp;

extern "C" void init(CReadData* read) {
	printf("foo");
	rp = new ReaderPlugin(read);
}
Code:
// ReaderInterface.h

class ReaderPlugin {

	public:
		ReaderPlugin(CReadData* read);
		void getData();
};
I guess i made a common mistake here, but i couldn't find anything on Google.

So thanks in advance...