VS static libs in shared lib with def file: alternative to dllexport?

749 views Asked by At

I'm building a dll with static libs (all C++) and a Module Definition File (.def) generated from all symbols contained in those static libs (dumpbin.exe /LINKERMEMBERS).

If I build my static libs as is, link it in my dll, some symbols are missing (ie inline functions), so I have to dllexport in the static libs to force the explicit instantiation of symbols, but the export has some unwanted side effects when I staticly compile programs with those static libs (without the dll) (warning 4217 and 4049 which are legitimate, a .exp file and all symbols exported in the .exe program itself).

So, my question is:

Does stackoverlow know a VS2010 (or VS2012) magic attribute or declspec to force the instantiation of a symbol without exporting it (but no noinline) ? or how to remove exports of my static libs (keeping the symbols) ?

PS: I need to use the same static libs for either the dll creation or for simple static linking to gain a lot of compilation time.

EDIT: This is tricky, I hope it will help to help me:

               libD.def gen from libS.lib's symbols
                so libD will dllexport Func()
             +----------------------------------+
             |                                  V
+----------------+                            +-------------+
|    libS.lib    |    static link libS.lib    |  libD.dll   |
|                |--------------------------->|( dllexport  |
|dllexport Func()|                            |   Func()  ) |
+----------------+      +-------------+       +-------------+
        |               |   libP.lib  |             |
        | static link   |  dllimport  |             | dyn link
        | libS.lib      |    Func()   |             |
        |               +-------------+             |
        V                |  static   |              V
+----------------+       |   link    |        +-------------+
|     a.exe      |<------+           +------->|   b.exe     |
|                |                            | dllimport   |
|     Func()     |                            |   Func()    |
+----------------+                  dllimport +-------------+
!!- will have exported                Func()        OK
    Func() in the .exe
!!- will warn about
    Func() localy defined
    but imported

NOTE: weird things happen: a.exe will export Func() even if "func.h" doesn't dllexport it (I thing because of the dllexport compiled in libS.lib), but I have to explicitly generate a def file to dllexport Func() in libD.dll ...

0

There are 0 answers