Class Access From Libraries
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.
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.
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.
The reason I ask this is because I've heard (and read a bit) that on other platforms you can only use C.
#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.
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.
sam.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement