Page 1 of 1

link the

Posted: Thu Aug 19, 2010 11:36 am
by esp-engineering
Hello all,

I link the into my project with

void *handle;

// open dll-handle
handle = dlopen("/home/pstark/workspace/TestDxfLib/src/", TLD_LAZY);
if (!handle) {
std::cerr << "Cannot open library: " << dlerror() << '\n';
return 1;
Unitl here everything is working well,
but how can i now acces to the function in(const char*, DL_creationInterface*)

I try to do it with the following Code snippet:

//create the MyDxf which is from the DL_creationInterface
MyDxf* dxf;
dxf = new MyDxf();

// define return type
typedef bool (*in_t)(const char*, MyDxf*);

// reset errors

// open handle
in_t in = (in_t) dlsym(handle, "in");
const char *dlsym_error = dlerror();
if (dlsym_error) {
std::cerr << "Cannot load symbol : " << dlsym_error << '\n';
return 1;

// call procedure

if(!in("/home/pstark/workspace/TestDxfLib/Debug/MP_spirale-0.dxf", dxf)){
std::cout<<"konnte file nicht laden!"<<"\n";
return 1;

// close dll-handle

The error is that he cannot found the in() funktion.

Has anybody done/try that bevor?
the source files where compiled with g++-4.2
on a Ubuntu 9.04 System

greets Peter