<div>hi</div>
<div>i've done what you told be (not to define de -D..) and i do have a .lib too but the problem of the link with the dll still exist.</div>
<div>maybe it's my fault </div>
<div>there is my code in the three directories(i'm using visual 8 2005 and cmake 2.6)</div>
<div> </div>
<div><strong><u>In the project directory :</u></strong></div>
<div>cmake_minimum_required(VERSION 2.6)</div>
<div># The name of our project is "HELLO". CMakeLists files in this project can<br># refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and<br># to the root binary directory of the project as ${HELLO_BINARY_DIR}.<br>
project (HELLO)<br>set(CMAKE_USE_RELATIVE_PATH "true")<br>SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) <br>SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) <br>subdirs(Hello Demo)</div>
<div> </div>
<div><strong><u>In the hello directory (containing a hello.h and hello.cpp and is a shared library):</u></strong></div>
<div>cmake_minimum_required(VERSION 2.6)<br># Create a library called "Hello" which includes the source file "hello.cxx".<br># The extension is already found. Any number of sources could be listed here.<br>
#Project(Hello) #ajouté<br>#ADD_DEFINITIONS(-DHello_DLL_EXPORT) #ajuté<br>add_library (Hello SHARED hello.cxx)</div>
<div> </div>
<div><strong><u>In demo directory:</u></strong></div>
<div>cmake_minimum_required(VERSION 2.6)</div>
<div># Make sure the compiler can find include files from our Hello library.<br>include_directories (${HELLO_SOURCE_DIR}/Hello)</div>
<div># Make sure the linker can find the Hello library once it is built.<br>link_directories (${HELLO_BINARY_DIR}/Hello)</div>
<div># Add executable called "helloDemo" that is built from the source files<br># "demo.cxx" and "demo_b.cxx". The extensions are automatically found.<br>add_executable (helloDemo demo.cxx demo_b.cxx )</div>
<div><br># Link the executable to the Hello library.<br>target_link_libraries (helloDemo Hello)</div>
<div>if(MSVC_VERSION)<br> set_target_properties(Hello PROPERTIES<br> LINK_FLAGS " /INCREMENTAL:NO /MANIFEST /NOLOGO"<br> #COMPILE_FLAGS "-DHELLO_EXPORTS" #ajouté in last a verif demin<br> )<br>endif(MSVC_VERSION)<br>
</div>
<div> </div>
<div>thanks for all<br><br></div>
<div class="gmail_quote">2008/6/10 Martin Apel <<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a>>:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">you have probably used declspec(export) for both cases: Compiling AND using the DLL.<br>In my example you have to compile your DLL with a define -DBase_EXPORTS, which causes the<br>
SPCK_BASE_EXPORT to resolve to declspec(export). When you USE the DLL somewhere, you must not define<br>this item, so SPCK_BASE_EXPORT will resolve to declspec(import).<br><br>Hope this helps.<br><br>Martin<br><br>Ingrid Kemgoum wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="Ih2E3d">hi,<br>i've taken your advice on the __declspec stuff and test it on a hello world project. i do have a .lib now but with a warning<br>"<br>hello.cxx<br><br>..\..\CMakeExample\Hello\hello.cxx(5) : warning C4273: 'Hello::Print' : inconsistent dll linkage<br>
<br>h:\workspace\cmakeexample\cmakeexample\hello\hello.h(18) : see previous definition of 'Print'<br><br>is that normal? anyway there is a problem: the application fail to find the .exe and the .dll though i fixed those paths in the CMakeLists.txt.<br>
<br>what could be the problem?<br><br>thanks for help<br><br>Ingrid<br><br> <br><br><br></div>2008/6/10 Martin Apel <<a href="mailto:martin.apel@simpack.de" target="_blank">martin.apel@simpack.de</a> <mailto:<a href="mailto:martin.apel@simpack.de" target="_blank">martin.apel@simpack.de</a>>>:
<div class="Ih2E3d"><br><br> Ingrid Kemgoum wrote:<br><br> hi and sorry to disturb<br> (i'm french and my english is not that good)<br></div> but i've seen on <a href="http://cmake.org/" target="_blank">cmake.org</a> <<a href="http://cmake.org/" target="_blank">http://cmake.org/</a>><br>
<<a href="http://cmake.org/" target="_blank">http://cmake.org</a> <<a href="http://cmake.org/" target="_blank">http://cmake.org/</a>>> that i'm having the
<div>
<div></div>
<div class="Wj3C7c"><br> same problem as you did.<br><br> i'm building a c++ project and from a shared library i only<br> have the .dll (not the .lib)<br> i dont understand explanations on cmake so could you please<br>
give me some?<br> thanks in advance and regards<br> Ingrid<br><br> Hi Ingrid,<br><br> on Windows you have to tell the compiler/linker, which symbols<br> should be exported from a DLL. There is a Microsoft extension to C++<br>
using a declspec(export) and declspec(import) prefix for DLL<br> functions. There's another possibility to use a so-called<br> .def-file to tell the compiler,<br> which symbols to export. If you have not told the compiler using<br>
one of the two ways, no symbols are exported and thus no .lib file<br> generated.<br> Please google for the explanation of the declspec keyword, it is<br> somewhat beyond my available time to explain it in detail. What I<br>
did looks roughly as follows:<br><br> #ifdef WIN32<br> #ifdef Base_EXPORTS<br> #define SPCK_BASE_EXPORT __declspec(dllexport)<br> #else<br> #define SPCK_BASE_EXPORT __declspec(dllimport)<br> #endif<br> #else<br>
#define SPCK_BASE_EXPORT<br> #endif<br><br> class SPCK_BASE_EXPORT Transformer<br> {<br> ...<br> };<br><br> Hope this helps,<br><br> Martin<br> -- <br><br></div></div></blockquote><br><br>-- <br><br>Martin Apel Tel: 0049 8153 9288-47<br>
Software Architect E-Mail: <a href="mailto:martin.apel@simpack.de" target="_blank">martin.apel@simpack.de</a><br><br>INTEC GmbH Tel: 0049 8153 9288-0<br>
Argelsrieder Feld 13 Fax: 0049 8153 9288-11<br>82234 Wessling E-Mail: <a href="mailto:intec@simpack.de" target="_blank">intec@simpack.de</a><br>Germany URL: <a href="http://www.simpack.com/" target="_blank">http://www.simpack.com</a><br>
<br></blockquote></div><br>