1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
Description: Build shared library.
Build a shared library instead of a static library. ZIMPL leaves some symbols
undefined, namely those listed in src/zimpl/xlpglue.h. They take advantage of
the fact that linking with a static library only pulls in the referenced
symbols to avoid referring to the xlp symbols in certain cases, for example,
in the scip test suite. Since Fedora wants shared libraries, we have to give
those symbols weak dummy definitions to avoid unresolved symbols at link time
Author: Jerry James <loganjerry@gmail.com>
Origin: https://src.fedoraproject.org/rpms/zimpl/blob/rawhide/f/zimpl-shared.patch
Forwarded: not-needed
Last-Update: 2026-01-26
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,8 +49,6 @@
# use C99 standard
set(CMAKE_C_STANDARD 99)
-set(CMAKE_C_VISIBILITY_PRESET hidden)
-set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
option(ZLIB "use ZLIB" ON)
option(SANITIZE_ADDRESS "should the address sanitizer be enabled in debug mode if available" OFF)
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -119,12 +119,10 @@
endif()
#create zimpl with pic
-add_library(libzimpl-pic STATIC ${libsources})
-set_target_properties(libzimpl-pic PROPERTIES POSITION_INDEPENDENT_CODE on)
-target_link_libraries(libzimpl-pic ${libs})
-
-#create zimpl without pic
-add_library(libzimpl STATIC ${libsources})
+add_library(libzimpl SHARED ${libsources})
+set_target_properties(libzimpl PROPERTIES
+ POSITION_INDEPENDENT_CODE on
+ VERSION 0.0.0 SOVERSION 0)
target_link_libraries(libzimpl ${libs})
#create zimpl binary
@@ -141,16 +139,13 @@
set_target_properties(libzimpl PROPERTIES
OUTPUT_NAME "zimpl")
-set_target_properties(libzimpl-pic PROPERTIES
- OUTPUT_NAME "zimpl-pic")
-
include(GNUInstallDirs)
# install the header files of zimpl
install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/zimpl)
# install the binary and the library to appropriate locations and add them to an export group
-install(TARGETS libzimpl zimpl libzimpl-pic EXPORT zimpl-targets
+install(TARGETS libzimpl zimpl EXPORT zimpl-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@@ -164,7 +159,7 @@
install(FILES ${PROJECT_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/zimpl)
# Add library targets to the build-tree export set
-export(TARGETS libzimpl libzimpl-pic
+export(TARGETS libzimpl
FILE "${CMAKE_BINARY_DIR}/zimpl-targets.cmake")
#configure the config file for the build tree
--- a/src/zimpl/zimpllib.c
+++ b/src/zimpl/zimpllib.c
@@ -455,3 +455,66 @@
return ret;
}
+
+// Dummy weak definitions to avoid unresolved symbols
+Lps * __attribute__((weak)) xlp_alloc(char const* name, bool need_startval, void* user_data)
+{
+ abort();
+}
+
+void __attribute__((weak)) xlp_free(Lps* lp)
+{
+ abort();
+}
+
+bool __attribute__((weak)) xlp_conname_exists(Lps const* lp, char const* conname)
+{
+ abort();
+}
+
+bool __attribute__((weak)) xlp_addcon_term(Lps* lp, char const* name, ConType type,
+ Numb const* lhs, Numb const* rhs, unsigned int flags, Term const* term)
+{
+ abort();
+}
+
+Var* __attribute__((weak)) xlp_addvar(Lps* lp, char const* name, VarClass usevarclass,
+ Bound const* lower, Bound const* upper, Numb const* priority, Numb const* startval)
+{
+ abort();
+}
+
+int __attribute__((weak)) xlp_addsos_term(Lps* lp, char const* name, SosType type, Numb const* priority, Term const* term)
+{
+ abort();
+}
+
+char const* __attribute__((weak)) xlp_getvarname(Lps const* lp, Var const* var)
+{
+ abort();
+}
+
+VarClass __attribute__((weak)) xlp_getclass(Lps const* lp, Var const* var)
+{
+ abort();
+}
+
+Bound* __attribute__((weak)) xlp_getlower(Lps const* lp, Var const* var)
+{
+ abort();
+}
+
+Bound* __attribute__((weak)) xlp_getupper(Lps const* lp, Var const* var)
+{
+ abort();
+}
+
+bool __attribute__((weak)) xlp_setobj(Lps* lp, char const* name, bool minimize)
+{
+ abort();
+}
+
+void __attribute__((weak)) xlp_addtoobj(Lps* lp, Term const* term)
+{
+ abort();
+}
--- a/zimpl-config.cmake.in
+++ b/zimpl-config.cmake.in
@@ -3,7 +3,7 @@
endif()
set(ZIMPL_LIBRARIES libzimpl)
-set(ZIMPL_PIC_LIBRARIES libzimpl-pic)
+set(ZIMPL_PIC_LIBRARIES libzimpl)
set(ZIMPL_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
set(ZIMPL_FOUND TRUE)
|