<div dir="ltr"><div><div><div>Then I would suggest something like<br><br>if(CYGWIN)<br>  set(libType SHARED)<br>else()<br>  set(libType MODULE)<br></div>endif()<br><br></div>add_library(TheProblematicOne ${libType} ...)<br><br></div>Petr<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 18, 2016 at 9:59 AM, Sam Habiel <span dir="ltr"><<a href="mailto:sam.habiel@gmail.com" target="_blank">sam.habiel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><a href="https://cmake.org/cmake/help/v3.0/command/add_library.html" target="_blank">https://cmake.org/cmake/help/v3.0/command/add_library.html</a><div><br></div><div>The module library (libgtmshr) is dlopened from the main exe. It's not supposed to be linked, except for Cygwin.<div><div class="h5"><br><br>On Thursday, February 18, 2016, Mueller-Roemer, Johannes Sebastian <<a href="mailto:Johannes.Sebastian.Mueller-Roemer@igd.fraunhofer.de" target="_blank">Johannes.Sebastian.Mueller-Roemer@igd.fraunhofer.de</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Why are you trying to link a MODULE? The add_library should be changed to SHARED not MODULE.<br>
<br>
--<br>
Johannes S. Mueller-Roemer, MSc<br>
Wiss. Mitarbeiter - Interactive Engineering Technologies (IET)<br>
<br>
Fraunhofer-Institut für Graphische Datenverarbeitung IGD<br>
Fraunhoferstr. 5  |  64283 Darmstadt  |  Germany<br>
Tel <a href="tel:%2B49%206151%20155-606" value="+496151155606" target="_blank">+49 6151 155-606</a>  |  Fax <a href="tel:%2B49%206151%20155-139" value="+496151155139" target="_blank">+49 6151 155-139</a><br>
<a>johannes.mueller-roemer@igd.fraunhofer.de</a>  |  <a href="http://www.igd.fraunhofer.de" target="_blank">www.igd.fraunhofer.de</a><br>
<br>
<br>
-----Original Message-----<br>
From: CMake [mailto:<a>cmake-bounces@cmake.org</a>] On Behalf Of Sam Habiel<br>
Sent: Thursday, February 18, 2016 09:45<br>
To: <a>cmake@cmake.org</a><br>
Subject: [CMake] Can't get CMake to use an import library generated from a MODULE target<br>
<br>
Rather than email one of the folks at Kitware, I decided to join the CMake mailing list... Hello all for those who remember me.<br>
<br>
I apologize for the long email.<br>
<br>
A few of us have been trying to port GT.M<br>
(<a href="https://www.fisglobal.com/Solutions/Services/Database-Engine" target="_blank">https://www.fisglobal.com/Solutions/Services/Database-Engine</a>) to Cygwin, 1. to get it running on Windows 2. as an exercise to prepare for harder ports, the Raspberry Pi being the holy grail here. That's the background.<br>
<br>
The problem we are having is familiar to many; but not initially to me. See the heading "Shared libraries with Windows/MinGW" in this<br>
article: <a href="http://gernotklingler.com/blog/creating-using-shared-libraries-different-compilers-different-operating-systems/" target="_blank">http://gernotklingler.com/blog/creating-using-shared-libraries-different-compilers-different-operating-systems/</a>.<br>
<br>
CMakeLists.txt:<br>
<a href="https://github.com/shabiel/fis-gtm/blob/cygwin/CMakeLists.txt" target="_blank">https://github.com/shabiel/fis-gtm/blob/cygwin/CMakeLists.txt</a><br>
<br>
The error:<br>
[ 88%] Linking C shared module plugin/cyggtmcrypt_gcrypt_AES256CFB.dll<br>
CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/sr_unix/gtmcrypt_util.c.o:<br>
In function `gc_load_gtmshr_symbols':<br>
/home/sam/fis-gtm-cygwin/sr_unix/gtmcrypt_util.c:100: undefined reference to `gtm_malloc'<br>
/home/sam/fis-gtm-cygwin/sr_unix/gtmcrypt_util.c:101: undefined reference to `gtm_free'<br>
collect2: error: ld returned 1 exit status<br>
CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/build.make:202: recipe for target 'plugin/cyggtmcrypt_gcrypt_AES256CFB.dll' failed<br>
make[2]: *** [plugin/cyggtmcrypt_gcrypt_AES256CFB.dll] Error 1<br>
CMakeFiles/Makefile2:891: recipe for target 'CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/all' failed<br>
make[1]: *** [CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/all] Error 2<br>
Makefile:116: recipe for target 'all' failed<br>
make: *** [all] Error 2<br>
<br>
Here's the link command (I turned CMAKE_VERBOSE_MAKEFILE=ON):<br>
/usr/bin/cc   -march=i586 -fsigned-char -Wmissing-prototypes<br>
-Wreturn-type -Wpointer-sign -fno-omit-frame-pointer -g -DDEBUG -shared -Wl,--enable-auto-import -o plugin/cyggtmcrypt_gcrypt_AES256CFB.dll<br>
-Wl,--major-image-version,0,--minor-image-version,0<br>
CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/sr_unix/gtmcrypt_ref.c.o<br>
CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/sr_unix/gtmcrypt_pk_ref.c.o<br>
CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/sr_unix/gtmcrypt_dbk_ref.c.o<br>
CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/sr_unix/gtmcrypt_sym_ref.c.o<br>
CMakeFiles/libgtmcrypt_gcrypt_AES256CFB.so.dir/sr_unix/gtmcrypt_util.c.o<br>
-lgpg-error -lgpgme -lgcrypt /usr/local/lib/libconfig.dll.a<br>
<br>
What is missing is that there needs to be either a link to cyggtmshr.dll, or a way for CMake to know to generate a libgtmshr_import.lib and add it to the link command.<br>
<br>
So here is what I tried:<br>
1. Using the GenerateExportHeader functionality of CMake on libgtmshr.<br>
If I do that, it doesn't seem to generate the import library; but it sure does generate an export header, which I don't need. Here it is:<br>
include(GenerateExportHeader)<br>
generate_export_header(libgtmshr<br>
    BASE_NAME libgtmshr<br>
    EXPORT_MACRO_NAME libgtmshr_EXPORTS<br>
    EXPORT_FILE_NAME  libgtmshr_EXPORTS.h<br>
    STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)<br>
<br>
2. Explicitly adding a libgtmshr as a dependency on line <a href="https://github.com/shabiel/fis-gtm/blob/cygwin/CMakeLists.txt#L531" target="_blank">https://github.com/shabiel/fis-gtm/blob/cygwin/CMakeLists.txt#L531</a>,<br>
but only for Cygwin. I get this error message:<br>
CMake Error at CMakeLists.txt:542 (target_link_libraries):<br>
  Target "libgtmshr" of type MODULE_LIBRARY may not be linked into another<br>
  target.  One may link only to STATIC or SHARED libraries, or to executables<br>
  with the ENABLE_EXPORTS property set.<br>
<br>
The GT.M developer familiar with CMake suggested me to use LINK_FLAGS and have CMake use the file by us hardcoding it in; which I am okay doing, but I thought I would check to see if there is an alternative way of doing this.<br>
<br>
I also tried the suggestions here:<br>
"<a href="https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/" target="_blank">https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/</a>"<br>
to no avail.<br>
<br>
Last, but not least:<br>
<br>
sam@horus ~/fis-gtm-cygwin<br>
$ cmake --version<br>
cmake version 3.4.3<br>
<br>
CMake suite maintained and supported by Kitware (<a href="http://kitware.com/cmake" target="_blank">kitware.com/cmake</a>).<br>
<br>
sam@horus ~/fis-gtm-cygwin<br>
$ uname -a<br>
CYGWIN_NT-10.0-WOW horus 2.2.0(0.289/5/3) 2015-08-03 12:49 i686 Cygwin<br>
<br>
--<br>
Sam Habiel, Pharm.D.<br>
VISTA Expertise Network<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</blockquote></div></div></div><div class="HOEnZb"><div class="h5"><br><br>-- <br>Sam Habiel, Pharm.D.<br>VISTA Expertise Network<br>
</div></div><br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>