Author Topic: using "dlopen and dlsym" export a class using C::B  (Read 3731 times)

Offline johnny

  • Single posting newcomer
  • *
  • Posts: 3
using "dlopen and dlsym" export a class using C::B
« on: December 18, 2009, 11:18:30 am »
hello...

Environiment:

OS:redhat linux
C::B version:8.02

Description:

while i using C::B to test the following case, we should link the static library, if so, the member of the class could be called successfully,
otherwise, "Undefined reference to "ClassA::Sum",pls help us to solve it.tks.

class ClassA
{

public:
     ClassA(){};
    ~ClassA(){};
    int Sum(int a, int b);
};
extern "C" ClassA* Create(){return new ClassA};


ClassA* tempA = (ClassA*)dlsym(dl_handle,"Create");
tempA->Sum(1,2);


Error Message:
Undefined reference to "ClassA::Sum"

Only i add the libClassA.a to "Link settings", thie project could be complied successfully,but i could not call this library dynamically.


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: using "dlopen and dlsym" export a class using C::B
« Reply #1 on: December 18, 2009, 11:35:41 am »
Only i add the libClassA.a to "Link settings", thie project could be complied successfully,but i could not call this library dynamically.
This is not related to Code::Blocks and thus violates our forum rules. This is *not* a general programming board. Try a C/C++ related forum.

Topic locked.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ