Author Topic: Dynamic Library Problem  (Read 4850 times)

Offline revanthedarth

  • Single posting newcomer
  • *
  • Posts: 2
Dynamic Library Problem
« on: January 28, 2011, 02:17:20 pm »
I have a huge project that works under Windows (VS 2008). I'm trying to port it to linux but i've encountered a problem in dynamic libraries.

I have a RendererOpenGL project that creates RendererOpenGL.so. But i cannot open that file using the code below:
Code
#include <dlfcn.h>
#include <cstdio>
int main()
{
void* libHandle;
libHandle=dlopen("./RendererOpenGL.so", RTLD_LAZY);
if(!libHandle)
{
printf("PROBLEM OPENING SO FILE!\n");
return 0;
}
printf("Bye...\n");
return 0;
}

I tried adding -shared to compiler flags or linker options, but nothing changed. And dlopen('RendererOpenGL.so", RTLD_LAZY) doesnt work either. I guess there is something wrong in the configuration.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Dynamic Library Problem
« Reply #1 on: January 28, 2011, 02:22:05 pm »
this question is not related to C::B, so I think you'd find a better forum to ask there.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline revanthedarth

  • Single posting newcomer
  • *
  • Posts: 2
Re: Dynamic Library Problem
« Reply #2 on: January 28, 2011, 02:25:09 pm »
It is. Creating a shared object works fine if i use g++ with -shared flag. But when I create a Dynamic Library with C::B, it doesn't create a valid output.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Dynamic Library Problem
« Reply #3 on: January 28, 2011, 02:30:41 pm »
It is. Creating a shared object works fine if i use g++ with -shared flag. But when I create a Dynamic Library with C::B, it doesn't create a valid output.
Believe me it works if the settings are correct.
Try the dynamic library wizard and compare the settings with your project.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7787
    • My Best Post
« Last Edit: January 28, 2011, 03:16:45 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org