<br><tt><font size=2>&quot;Yuri V. Timenkov&quot; &lt;ytimenkov@parallels.com&gt;
wrote on 08/19/2008 03:26:34 PM:<br>
<br>
&gt; On Tuesday 19 August 2008 17:10:56 Jos.van.den.Oever@panalytical.com
wrote:<br>
&gt; &gt; &quot;Yuri V. Timenkov&quot; &lt;ytimenkov@parallels.com&gt;
wrote on 08/19/2008 02:05:04<br>
&gt; &gt;<br>
&gt; &gt; PM:<br>
&gt; &gt; &gt; Are following posts solve your problem?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; http://www.cmake.org/pipermail/cmake/2008-July/023099.html<br>
&gt; &gt; &gt; http://www.cmake.org/pipermail/cmake/2006-September/011100.html<br>
&gt; &gt; &gt; http://www.cmake.org/pipermail/cmake/2005-February/006080.html<br>
&gt; &gt;<br>
&gt; &gt; Yes they do. The tricky point was having to know that the symbol<br>
&gt; &gt; ${LIBRARYNAME}_EXPORTS is set when building the library.<br>
&gt; &gt; Then adding something along these lines in the header file solves
the<br>
&gt; &gt; problem:<br>
&gt; &gt;<br>
&gt; &gt; #ifdef _WIN32<br>
&gt; &gt; # &nbsp;ifdef testc2_EXPORTS<br>
&gt; &gt; # &nbsp; &nbsp;define WHATEVER __declspec( dllexport )<br>
&gt; &gt; # &nbsp;else<br>
&gt; &gt; # &nbsp; &nbsp;define WHATEVER __declspec( dllimport )<br>
&gt; &gt; # &nbsp;endif<br>
&gt; &gt; #else<br>
&gt; &gt; # &nbsp;define WHATEVER<br>
&gt; &gt; #endif<br>
&gt; &gt;<br>
&gt; &gt; WHATEVER float LibC2Func();<br>
&gt; &gt;<br>
&gt; &gt; So now I can get a simple project with one dll and one exe to
compile, but<br>
&gt; &gt; I still do not understand which program determines whether the
.exe should<br>
&gt; &gt; link to a .lib or a .dll. Does the Microsoft Visual Studio compiler<br>
&gt; &gt; determine this or does CMake inspect the header files?<br>
&gt; &gt; I find it strange that the linking command depends on the contents
of the<br>
&gt; &gt; header files. Is there a reason for this?<br>
&gt; This is VS tricks. Studio generates 2 files: one import library (.<br>
&gt; lib) and one <br>
&gt; - dynamic library (.dll). gcc (and mingw family) exports all symbols
by <br>
&gt; default, VS doesn't export anything by default. And if your dll doesn't
&nbsp;<br>
&gt; export anything, VS simply doesn't generate import library (for example,
if <br>
&gt; you generate resource-only dll). The only thing cmake knows is when
you using <br>
&gt; VS generator, library extension to link with -- is .lib. And when
you use <br>
&gt; __declspec( dllexport ), cl.exe puts special marks in objects indicating
that <br>
&gt; this symbol should be exported or imported. Also, VS can tell linker
to add <br>
&gt; some library, as it boost does with #pragma's.<br>
&gt; <br>
&gt; Really, this is well-known issue for VS developers (&quot;Where is
my .lib file??? <br>
&gt; &gt;:-(&quot;), especially if you copy project and header files and
forgot change <br>
&gt; defines. But because CMake makes migration to windows very smooth,
this <br>
&gt; question appears near every month in this list as cmake on VS/Windows
newbie <br>
&gt; question.<br>
</font></tt>
<br><tt><font size=2>Perhaps it's a idea to add an entry to http://www.cmake.org/Wiki/CMake_FAQ
then.</font></tt>
<br><tt><font size=2>Something that says: If there is no __declspec( dllexport
) in your header, only a dll and no lib is generated.</font></tt>
<br><tt><font size=2>CMake only tells the linker about the .lib, so if
__declspec( dllexport ) is not there linking fails even though there is
a .dll file.</font></tt>
<br>
<br><tt><font size=2>Thanks,</font></tt>
<br><tt><font size=2>Jos <br>
</font></tt><font size=2 face="Verdana"> &nbsp;<br>
 &nbsp;<b><br>
Jos van den Oever </b>- SW Engineering <br>
 &nbsp;</font>
<table width=100%>
<tr valign=top>
<td width=32%><font size=1 face="Verdana">PANalytical <br>
Lelyweg 1 <br>
7602 EA Almelo <br>
The Netherlands </font>
<td width=67%><font size=1 face="Verdana">T &nbsp; +31 (0)546 528<br>
F &nbsp; +31 (0)546 534598<br>
Jos.van.den.Oever@panalytical.com<br>
www.PANalytical.com</font></table>
<br><font size=2 face="Verdana"><br>
</font>
<table width=100%>
<tr>
<td width=48% bgcolor=#ff8d40><font size=2 face="Verdana">&nbsp;</font><font size=2 color=white face="Verdana"><b>PANalytical</b></font>
<td width=51% bgcolor=#ff8d40>
<div align=right><font size=2 color=white face="Verdana"><b>The Analytical
X-ray Company </b></font><font size=3>&nbsp;</font></div>
<tr valign=top>
<td colspan=2><font size=1 color=#808080 face="Verdana"><br>
The information contained in this message is confidential and may be legally
privileged. The message is intended solely for the addressee(s). If you
are not the intended recipient, you are hereby notified that any use, dissemination,
or reproduction is strictly prohibited and may be unlawful. If you are
not the intended recipient, please contact the sender by return e-mail
and destroy all copies of the original message.</font></table>
<br>
<br>
<br>