[CMake] Cmake 2.2.2 with Visual Studio 6. .lib? .dll?
David Cole
david.cole at kitware.com
Tue Nov 29 10:51:25 EST 2005
If (BUILD_SHARED_LIBS AND WIN32) then you need to decorate at least one
function, class or global variable with __declspec(dllexport) when
building with VS or nothing will be exported from the resulting DLL.
(And if nothing is exported, VS will not produce a .lib file...)
To do this "100% properly" you need to configure a header file such that
you know the value of BUILD_SHARED_LIBS within your C++ code.
See how VTK does this for each of its dll's...
For example, see the definition of VTK_COMMON_EXPORT (and all the other
VTK_*_EXPORT macros) in VTK/Common/vtkWin32Header.h...
http://public.kitware.com/cgi-bin/viewcvs.cgi/Common/vtkWin32Header.h?view=markup
VTK_BUILD_SHARED_LIBS comes from the configured header file (from the
CMake BUILD_SHARED_LIBS setting)
vtkCommon_EXPORTS is automatically defined by CMake when building source
files into vtkCommon.dll on WIN32, undefined otherwise (when building
other VTK dll's or other clients of vtkCommon.dll, for example)
Alternatively, you could investigate using a def file to explicitly list
your exports, although the source code only approach seems more
maintainable to me long term...
David
Daniel Tourde wrote:
>Hello,
>
>Thanks for your answer. I basically created a test project with Kdevelop 3.2.1
>under Linux. I slightly modified the CMakeLists.txt file according to the
>tips given by Alexander Neundorf and Filipe Sousa (see the few mails
>exchanged a few days ago, on the mailing list). Otherwise, I did not change
>anything. My idea is to prove the concept: Kdevelop project -> M$ VS6 via
>cmake 2.2.2.
>
>If you want, I can send you the project in itself (two short C++ files, in
>fact). There is nothing strange: A library and a program written to use that
>library (the whole things producing a "Hello world!")
>
>The dll gets built. I cannot give you much details, I am a Unixian, so to
>say... :) but I can assure you that there is no associated .lib.
>
>
> Daniel
>
>
>
>>>...When VS tries to link a test program to the new
>>>library it looks for a .lib that it does not find because there is .dll.
>>>
>>>How am I supposed to solve this problem?
>>>
>>>
>>There should be an import lib built when the dll is built. If there
>>isn't one, then there are probably no exports from that dll. In which
>>case, there's no use linking to it. Something is wrong with the process
>>that built the dll if the corresponding import lib is not there.
>>
>>How does the dll in question get built? (Or, if it's not built, how was
>>it installed?) There should be a .lib file associated with the dll if
>>it's intended for you to link exe's or other dll's to it...
>>
>>HTH,
>>David
>>
>>
>
>
>
More information about the CMake
mailing list