tags:

views:

42

answers:

2

I don't know why but I thought I could statically link a function from an Import Library. It would seem I am the only one who has ever tried because I can't for the life of me find a similar post. Is there a way to selectively static link functions from a dynamically linked project without creating a new project and/or recompiling it as static? The module itself communicates over an interface and I'm not really big on exporting functions. I just want to static link the code to create the object....

how bad would it be to turn this into a macro?

IClassFactory* CF = NULL;
hr = CoGetClassObject (
    CLSID_CF,
    CLSCTX_INPROC_SERVER,
    NULL,
    IID_IClassFactory,
    (void**)&CF );

Interface* Instance = NULL;
hr = CF->CreateInstance (
    NULL,
    IID_Interface,
    (void**)&Instance );
+1  A: 

Static linking and import libraries dont go together. An import library is used for helping the linker figure out that the functions you call are in a DLL.

If you want static linking (assuming you have the code available) then reconfigure-recompile the DLL project to a static library.

renick
"....without creating a new project and/or recompiling it as static?"-me.....So no!
PrettyFlower
+1  A: 

If this is your own project (or you have source code and are willing to modify it), you could use inline functions for the functions you don't want to dynamically link.

R Samuel Klatchko
This is my own project and thank you ....
PrettyFlower