Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is system dependent, but you'll have to ensure that the symbols in the DLL containing the definitions of the member functions and static member data correctly exports the symbols, and that the DLL using them correctly imports them. Under Linux, this means using the <code>-E</code> option when linking the executable (if the symbols are defined in the executable); under Windows, you usually have to use conditionally compiled compiler extensions, see <code>__declspec</code>; Microsoft compilers do not support DLL's in standard C++.</p> <p>EDIT:</p> <p>Here's an example that works on my system (VC 2010):</p> <p>In A.h:</p> <pre><code>#ifndef A_h_20111228AYCcNClDUzvxOX7ua19Fb9y5 #define A_h_20111228AYCcNClDUzvxOX7ua19Fb9y5 #include &lt;ostream&gt; #ifdef DLL_A #define A_EXPORT __declspec(dllexport) #else #define A_EXPORT __declspec(dllimport) #endif class A_EXPORT InA { static std::ostream* ourDest; public: static void setDest( std::ostream&amp; dest ); static std::ostream* getStream() { return ourDest; } }; #endif </code></pre> <p>In A.cpp:</p> <pre><code>#include "A.h" std::ostream* InA::ourDest = NULL; void InA::setDest( std::ostream&amp; dest ) { ourDest = &amp;dest; } </code></pre> <p>In main.cpp:</p> <pre><code>#include &lt;iostream&gt; #include "A.h" int main() { InA::setDest( std::cout ); std::cout &lt;&lt; InA::getStream() &lt;&lt; std::endl; return 0; } </code></pre> <p>Compiled and linked with:</p> <pre><code>cl /EHs /LDd /DDLL_A A.cpp cl /EHs /MDd main.cpp A.lib </code></pre> <p>As I understand it (I'm more a Unix person), all of the .cpp which become part of the dll should have /DDLL_A in the command line which invokes the compiler; none of the others should. In Visual Studios, this is usually achieved by using separate projects for each dll and each executable. In the properties for the project, there's an entry ConfigurationProperties&rarr;C/C++&rarr;Preprocessor&rarr;Preprocessor Definitions; just add <code>DLL_A</code> there (but only in the one project that generates <code>A.ddl</code>).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload