Jump to content
  • Advertisement
Sign in to follow this  
Zorbfish

Class Access From Libraries

This topic is 4850 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

Is there any equivalent to a Windows static library on other platforms? I would like to have access to C++ classes without a creator function. If the above is not possible, then is the only way to reach a C++ class on other platforms through a creator function? I cannot find a definite yes or no answer through google. The majority of results just link to DLL articles/tutorials that demonstrate access through a creator function, but never mention static libraries.

Share this post


Link to post
Share on other sites
Advertisement
Yes there are equivalents to static libraries on other platforms. *nix uses archives, .a files, that are more or less identical to static .lib files. Though I'm not sure what you mean by access to C++ classes without a creator function.

Share this post


Link to post
Share on other sites
Bad choice of words I guess. What I'm trying to say is can I link to a static library, included the related headers, and have the ability declare instances of classes without having to create a function to return an instance.


#pragma comment(lib, "foo.lib")
#include "foo.h"

int main(int argc, char* argv[]) {
Foo foo; // where Foo is in foo.lib

// instead of using a creator to get at it
Foo* foo = CreateFoo();

return 0;
}


The reason I ask this is because I've heard (and read a bit) that on other platforms you can only use C.

Share this post


Link to post
Share on other sites
You don't have to do anything fancy with a static library on any platform, because a static library is really just a collection of pre-compiled translation units (cpp files).

sam.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
well, rest assured that on other platforms you can compile a static library file and do exactly what you want.

in fact, as far as i know, the windows DLL system is even worse that most dynamic library systems for creating things, managing memory, etc.

but anyways. on gcc, you'd compile to a .a file and then link it in. they don't have pragmas like you have for your windows program, but you just put it on the link line in your makefile/project whatever.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!