Jump to content
  • Advertisement
Sign in to follow this  
emileej

Importing a class at runtime

This topic is 5408 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'd like my application to load a compiled class from an external file into memory and call a function from it, giving the this pointer as parameter so that the loaded class may call some functions from its parent class. The loaded class will only communicate with the rest of the application via function calls to the parent class so I shouldn't have any memory errors like referring to global variables directly, but are there any other issues that I should be aware of? And how is this done best? (aka. have any of you dont this before?)

Share this post


Link to post
Share on other sites
Advertisement
well you didn't mention which language your using, i'll assume c++ dynamic class loading is a breeze in some other lanaguage they support as standard but not the case for c++ you'll have to write one this can help you or use third-party library such as this.

Share this post


Link to post
Share on other sites
Woops! My bad. Yeh I am indeed using C++.
I just went over the first article quickly and noticed that Linux is mentioned. This isn't platform specific is it?

Share this post


Link to post
Share on other sites
The 4 dl*() functions are linux specific, but the general principle still holds under windows. The equivalent windows functions are

dlopen() = LoadLibrary()
dlsym() = GetProcAddress()
dlerror() = GetLastError()
dlclose() = FreeLibrary()

Check out MSDN for more details on these functions.

Share this post


Link to post
Share on other sites
The idea was to have the compiled class in an external file, copy it to the memory and then use it. I have used dll's many times before but thats now what I want in this case.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!