Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDIT:</strong> Sure I'm wrong as the answer of <em>jcopenha</em> is the answer. The linker complains about the missing constructor and destructor that you don't export in the DLL. However the rest is still valid.</p> <p>[...]</p> <p>You should have two build targets (or projects, depending on the environment you use).</p> <p>First target will build the DLL. The files this target will need to be built are, based on what you report:</p> <pre><code>currency.hpp allccy.hpp </code></pre> <p>and probably the implementation of the base class "currency". You must have defined SANPROJ_EXPORTS in the preprocessor defines in order to use the currency.hpp file as a definition of the functions exported by your DLL. This target will produce a .DLL file and probably (depends on configuration) a .lib file. It may also generate other files like a text representation of the exports of the library (a .DEF file).</p> <p>Then, you need to build your application (the second target/project): the header file you need is just simply the same of the library for the #include part. Just be sure to NOT define SANPROJ_EXPORTS or the compiler will try to export again the simbols instead of importing them. Then you need to add the following settings to the compiler and linker:</p> <ul> <li><p>Add to the include path the directory containing the .hpp header.</p></li> <li><p>Add to the libraries path of the linker (lib) the directory containing the .lib file.</p></li> <li><p>Tell the linker to also link against the .lib you just created (add the full name of your lib file, assuming the DLL is named "currency" probably it will be "currency.lib".</p></li> </ul> <p>Where and how to add this settings depends on the toolchain/environment and compiler you are using.</p> <p>In the end, be sure that the compiled executable will be able to find the DLL in the project folder or in a system directory (in the PATH) or it will not start. Just copy the DLL with a post-build step if you have the executable in a different folder than the one used to build the DLL.</p> <p>The fact that removing the _dllimport part will build the project is probably due to the compiler finding the header AND the implementation of the functions you meant to export, and building all of them statically into the executable.</p> <p>Assuming you are not in the .NET "managed world", and that we are talking about Windows, there are some more points to look at if you want to distribute your library, but this is another answer.</p>
 

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