View Issue Details

IDProjectCategoryView StatusLast Update
0000600Other Unix PortBugpublic2022-05-14 16:41
Reporterkomh Assigned Topsmedley  
PriorityhighSeverityblockReproducibilityalways
Status closedResolutionfixed 
Summary0000600: CMake does not produce a DLL correctly
DescriptionHi/2.

CMake v2.8.12.1 does not produce a DLL correctly. It generates a DLL, but does not export any symbols at all.
TagsNo tags attached.
Attached Files
export.diff (1,971 bytes)   
diff -uNr  os2.cmake.org os2.cmake
--- os2.cmake.org	2012-05-18 15:15:20.000000000 +0900
+++ os2.cmake	2014-02-24 10:41:18.000000000 +0900
@@ -39,9 +43,9 @@
   "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")

 SET(CMAKE_C_CREATE_SHARED_LIBRARY
-  "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES> && emximp -o <TARGET_IMPLIB> <TARGET>")
+  "echo LIBRARY <TARGET> INITINSTANCE TERMINSTANCE > <TARGET>.def && echo DATA MULTIPLE NONSHARED >> <TARGET>.def && echo EXPORTS >> <TARGET>.def && emxexp <OBJECTS> >> <TARGET>.def && <CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES> <TARGET>.def && emximp -o <TARGET_IMPLIB> <TARGET>")
 SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
-  "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES> && emximp -o <TARGET_IMPLIB> <TARGET>")
+  "echo LIBRARY <TARGET> INITINSTANCE TERMINSTANCE > <TARGET>.def && echo DATA MULTIPLE NONSHARED >> <TARGET>.def && echo EXPORTS >> <TARGET>.def && emxexp <OBJECTS> >> <TARGET>.def && <CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES> <TARGET>.def && emximp -o <TARGET_IMPLIB> <TARGET>")

 SET(CMAKE_C_LINK_EXECUTABLE
   "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")

export.diff (1,971 bytes)   
0001-Fix-header-check-for-DART.patch (905 bytes)   
From 4d63d863546b94856c68bd1777df798d51061f26 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Sat, 15 Mar 2014 21:17:41 +0900
Subject: [PATCH 1/2] Fix header check for DART

---
 fluidsynth/CMakeLists.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fluidsynth/CMakeLists.txt b/fluidsynth/CMakeLists.txt
index 004b022..0232e3a 100644
--- a/fluidsynth/CMakeLists.txt
+++ b/fluidsynth/CMakeLists.txt
@@ -181,7 +181,7 @@ if ( ${CMAKE_SYSTEM} MATCHES "OS2" )
   set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Zbin-files" )
   set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Zbin-files" )
   if ( enable-dart )
-    check_include_file ( os2me.h HAVE_DART_H )
+    check_include_files ( "os2.h;os2me.h" HAVE_DART_H )
     set ( DART_SUPPORT ${HAVE_DART_H} )
     unset ( DART_INCLUDE_DIRS CACHE )
   endif ( enable-dart )
-- 
1.7.3.2

0002-Set-output-name-correctly-for-OS-2.patch (1,002 bytes)   
From daea5477bfbafed17ecc4f7ed113c8d48175ea32 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Sat, 15 Mar 2014 21:18:45 +0900
Subject: [PATCH 2/2] Set output name correctly for OS/2

OS/2 has a DLL name length limit up to 8 characters.
---
 fluidsynth/src/CMakeLists.txt |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/fluidsynth/src/CMakeLists.txt b/fluidsynth/src/CMakeLists.txt
index 94464e4..e60037a 100644
--- a/fluidsynth/src/CMakeLists.txt
+++ b/fluidsynth/src/CMakeLists.txt
@@ -264,6 +264,14 @@ if ( MACOSX_FRAMEWORK )
         VERSION ${LIB_VERSION_INFO}
         SOVERSION ${LIB_VERSION_CURRENT}
     )
+elseif ( OS2 )
+    set_target_properties ( libfluidsynth
+      PROPERTIES
+        OUTPUT_NAME "fluidsyn"
+        ARCHIVE_OUTPUT_NAME "fluidsynth"
+        VERSION ${LIB_VERSION_INFO}
+        SOVERSION ${LIB_VERSION_CURRENT}
+    )
 else ( MACOSX_FRAMEWORK )
   set_target_properties ( libfluidsynth
     PROPERTIES
-- 
1.7.3.2

0001-Use-_dll.a-as-OS-2-import-library-suffix.patch (868 bytes)   
From 05989a93b3ecdc1025994190debcc5fd1d022c4d Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Thu, 21 Jan 2016 21:40:38 +0900
Subject: [PATCH] Use '_dll.a' as OS/2 import library suffix

    modified:   Modules/Platform/os2.cmake
---
 Modules/Platform/os2.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Modules/Platform/os2.cmake b/Modules/Platform/os2.cmake
index 3a795fb..bd1de6e 100644
--- a/Modules/Platform/os2.cmake
+++ b/Modules/Platform/os2.cmake
@@ -7,7 +7,7 @@ SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
 SET(CMAKE_SHARED_MODULE_PREFIX "")
 SET(CMAKE_SHARED_MODULE_SUFFIX ".dll")
 SET(CMAKE_IMPORT_LIBRARY_PREFIX "")
-SET(CMAKE_IMPORT_LIBRARY_SUFFIX ".a")
+SET(CMAKE_IMPORT_LIBRARY_SUFFIX "_dll.a")
 # no pic for gcc on OS/2
 SET(CMAKE_C_COMPILE_OPTIONS_PIC "")
 SET(CMAKE_CXX_COMPILE_OPTIONS_PIC "")
-- 
2.7.0

0001-Restrict-a-DLL-name-up-to-8-characters.patch (1,417 bytes)   
From fd2582ccd88d4341930fc2a3515743dd0880c21b Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Thu, 21 Jan 2016 21:44:39 +0900
Subject: [PATCH] Restrict a DLL name up to 8 characters

    modified:   Source/cmGeneratorTarget.cxx
---
 Source/cmGeneratorTarget.cxx | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 194cd88..a7bec11 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3004,13 +3004,26 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config,
   // Append the per-configuration postfix.
   outBase += configPostfix?configPostfix:"";
 
+#ifdef __OS2__
+  if((this->GetType() == cmTarget::SHARED_LIBRARY ||
+      this->GetType() == cmTarget::MODULE_LIBRARY) && !implib &&
+      outBase.length() > 8)
+    outBase.erase(8);
+#endif
+
   // Name shared libraries with their version number on some platforms.
   if(const char* soversion = this->GetProperty("SOVERSION"))
     {
     if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib &&
        this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION"))
       {
+#ifndef __OS2__
       outBase += "-";
+#else
+      int len = std::string(soversion).length();
+      if(outBase.length() + len > 8)
+        outBase.erase(8 - len);
+#endif
       outBase += soversion;
       }
     }
-- 
2.7.0

0001-Use-kdllar-to-generate-DLLs-and-import-libraries.patch (2,887 bytes)   
From 8a0b203b7309d8bf539739a23fce06a658b1074a Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Thu, 21 Jan 2016 21:43:47 +0900
Subject: [PATCH] Use kdllar to generate DLLs and import libraries

    modified:   Modules/Platform/os2.cmake
---
 Modules/Platform/os2.cmake | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Modules/Platform/os2.cmake b/Modules/Platform/os2.cmake
index f7db22a..8869310 100644
--- a/Modules/Platform/os2.cmake
+++ b/Modules/Platform/os2.cmake
@@ -40,14 +40,14 @@ SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1)
 #  "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
 
 SET(CMAKE_C_CREATE_SHARED_MODULE
-  "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
+  "kdllar -cc <CMAKE_C_COMPILER> -nokeepdef <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> -o <TARGET> -implib <TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
 SET(CMAKE_CXX_CREATE_SHARED_MODULE
-  "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
+  "kdllar -cc <CMAKE_CXX_COMPILER> -nokeepdef <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> -o <TARGET> -implib <TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
 
 SET(CMAKE_C_CREATE_SHARED_LIBRARY
-  "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES> && emximp -o <TARGET_IMPLIB> <TARGET>")
+  "kdllar -cc <CMAKE_C_COMPILER> -nokeepdef <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> -implib <TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
 SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
-  "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES> && emximp -o <TARGET_IMPLIB> <TARGET>")
+  "kdllar -cc <CMAKE_CXX_COMPILER> -nokeepdef <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> -implib <TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
 
 SET(CMAKE_C_LINK_EXECUTABLE
   "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
-- 
2.7.0

0001-Use-multi-lined-response-file-on-OS-2.patch (1,353 bytes)   
From 4e9ed995adf9b60599185fef46f79fa7f282e1ca Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Thu, 21 Jan 2016 21:48:34 +0900
Subject: [PATCH] Use multi-lined response file on OS/2

gcc can understand a single-lined response file. But, some external
OS/2 tools, such as kdllar, cannot a single-lined response file.

However, replacing a space with LF is not enough. Some files can have
a space in its name. Later, there is need to investigate this problem.

    modified:   Source/cmMakefileTargetGenerator.cxx
---
 Source/cmMakefileTargetGenerator.cxx | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index b278087..309d205 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1638,7 +1638,14 @@ cmMakefileTargetGenerator
   responseFileNameFull += name;
   cmGeneratedFileStream responseStream(responseFileNameFull.c_str());
   responseStream.SetCopyIfDifferent(true);
+#ifndef __OS2__
   responseStream << options << "\n";
+#else
+  std::string opts = options;
+  for(int pos = 0; (pos = opts.find(' ', pos)) != opts.npos; ++pos)
+    opts[pos] = '\n';
+  responseStream << opts << "\n";
+#endif
 
   // Add a dependency so the target will rebuild when the set of
   // objects changes.
-- 
2.7.0

Activities

komh

2014-02-24 12:43

reporter   ~0002680

I attach a patch.

But this does not work because emxexp does not understand the response file which CMake makes. emxexp expects that a response file consists of an argument per a line. However, CMake generates a respose file consisting of all arguments in one line.

I think, this should be fixed first, or some wrappers should be introduced to convert a line to an argument per a line.

Of course, I think, the fix is better.

psmedley

2014-03-13 19:19

administrator   ~0002692

do you have an example project built with cmake I can test with?

psmedley

2014-03-13 19:29

administrator   ~0002694

looks like cmake support def files on windows - might be able to recycle some code ;)

komh

2014-03-18 19:17

reporter   ~0002703

fluidsynth: git://git.code.sf.net/p/fluidsynth/code-git

And I attach patches for it.

It requires glib-2.0. What I' using is glib-2.12.4-rc1-multithreaded(ftp://ftp.netlabs.org/pub/gcc/contrib/libs/glib-2.12.4-rc1-multithreaded.zip).

For pthread, I've set CMAKE_LIBRARY_PATH.

set CMAKE_LIBRARY_PATH=f:/usr/lib;%CMAKE_LIBRARY_PATH%

komh

2016-01-23 19:01

reporter   ~0003094

Hi/2.

I add patches for DLL generation.

Review, please...

komh

2016-01-23 19:04

reporter   ~0003095

To generate DLL and implib, I used my kdllar at hobbes.

    http://hobbes.nmsu.edu/download/pub/os2/dev/util/kdllar100.zip

komh

2016-01-23 19:07

reporter   ~0003097

Sorry, I missed one more patch.

psmedley

2016-01-24 07:35

administrator   ~0003103

Will dllar also work for DLL creation? I understand that kdllar may do some things better, but my preference would be to not depend on 3rd party libs/tools for DLL creation. PS thanks for all the cmake patches, I'll try incorporate them locally asap.

komh

2016-01-24 17:36

reporter   ~0003104

I agree with you. If possible, it would be better to remove 3rd party apps dependencies.

Unfortunately, however, dllar does not support a response file nor creation of implib having different name from a dll name.

Then, we should implement a dll creation with a traditional way used by the attached export.diff. That is, create .def file with echo + emxexp, link with the .def file and create implib with emximp. Fortunatley, now DLL name is restricted up to 8 characters in CMake itself. So this way will also work.

Ah, additionaly, it is needed to clean the created .def file after dll creation.

psmedley

2022-05-14 16:40

administrator   ~0004285

I no longer maintain cmake

Issue History

Date Modified Username Field Change
2014-02-24 12:33 komh New Issue
2014-02-24 12:36 komh File Added: export.diff
2014-02-24 12:43 komh Note Added: 0002680
2014-03-13 19:19 psmedley Note Added: 0002692
2014-03-13 19:29 psmedley Note Added: 0002694
2014-03-18 19:17 komh Note Added: 0002703
2014-03-18 19:18 komh File Added: 0001-Fix-header-check-for-DART.patch
2014-03-18 19:18 komh File Added: 0002-Set-output-name-correctly-for-OS-2.patch
2016-01-23 19:01 komh Note Added: 0003094
2016-01-23 19:02 komh File Added: 0001-Use-_dll.a-as-OS-2-import-library-suffix.patch
2016-01-23 19:02 komh File Added: 0001-Restrict-a-DLL-name-up-to-8-characters.patch
2016-01-23 19:03 komh File Added: 0001-Use-kdllar-to-generate-DLLs-and-import-libraries.patch
2016-01-23 19:04 komh Note Added: 0003095
2016-01-23 19:07 komh File Added: 0001-Use-multi-lined-response-file-on-OS-2.patch
2016-01-23 19:07 komh Note Added: 0003097
2016-01-24 07:35 psmedley Note Added: 0003103
2016-01-24 17:36 komh Note Added: 0003104
2022-05-14 16:40 psmedley Assigned To => psmedley
2022-05-14 16:40 psmedley Status new => resolved
2022-05-14 16:40 psmedley Resolution open => fixed
2022-05-14 16:40 psmedley Note Added: 0004285
2022-05-14 16:41 psmedley Status resolved => closed