Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-DBUILD_SHARED_LIBS=ON does not build dynamic libs #61

Open
barracuda156 opened this issue Sep 9, 2024 · 1 comment
Open

-DBUILD_SHARED_LIBS=ON does not build dynamic libs #61

barracuda156 opened this issue Sep 9, 2024 · 1 comment
Assignees

Comments

@barracuda156
Copy link

How to build libpapilo as a dynamic lib? Standard -DBUILD_SHARED_LIBS=ON fails to have an effect, only static libs get built:

Port libpapilo @2.3.0_0+gfortran contains:
  /opt/local/include/papilo/CMakeConfig.hpp
  /opt/local/include/papilo/Config.hpp
  /opt/local/include/papilo/core/Components.hpp
  /opt/local/include/papilo/core/ConstraintMatrix.hpp
  /opt/local/include/papilo/core/MatrixBuffer.hpp
  /opt/local/include/papilo/core/Objective.hpp
  /opt/local/include/papilo/core/Presolve.hpp
  /opt/local/include/papilo/core/PresolveMethod.hpp
  /opt/local/include/papilo/core/PresolveOptions.hpp
  /opt/local/include/papilo/core/ProbingView.hpp
  /opt/local/include/papilo/core/Problem.hpp
  /opt/local/include/papilo/core/ProblemBuilder.hpp
  /opt/local/include/papilo/core/ProblemFlag.hpp
  /opt/local/include/papilo/core/ProblemUpdate.hpp
  /opt/local/include/papilo/core/Reductions.hpp
  /opt/local/include/papilo/core/RowFlags.hpp
  /opt/local/include/papilo/core/SingleRow.hpp
  /opt/local/include/papilo/core/Solution.hpp
  /opt/local/include/papilo/core/SparseStorage.hpp
  /opt/local/include/papilo/core/Statistics.hpp
  /opt/local/include/papilo/core/SymmetryStorage.hpp
  /opt/local/include/papilo/core/VariableDomains.hpp
  /opt/local/include/papilo/core/postsolve/BoundStorage.hpp
  /opt/local/include/papilo/core/postsolve/Postsolve.hpp
  /opt/local/include/papilo/core/postsolve/PostsolveStatus.hpp
  /opt/local/include/papilo/core/postsolve/PostsolveStorage.hpp
  /opt/local/include/papilo/core/postsolve/PostsolveType.hpp
  /opt/local/include/papilo/core/postsolve/ReductionType.hpp
  /opt/local/include/papilo/core/postsolve/SavedRow.hpp
  /opt/local/include/papilo/external/fmt/chrono.h
  /opt/local/include/papilo/external/fmt/color.h
  /opt/local/include/papilo/external/fmt/compile.h
  /opt/local/include/papilo/external/fmt/core.h
  /opt/local/include/papilo/external/fmt/format-inl.h
  /opt/local/include/papilo/external/fmt/format.h
  /opt/local/include/papilo/external/fmt/locale.h
  /opt/local/include/papilo/external/fmt/os.h
  /opt/local/include/papilo/external/fmt/ostream.h
  /opt/local/include/papilo/external/fmt/posix.h
  /opt/local/include/papilo/external/fmt/printf.h
  /opt/local/include/papilo/external/fmt/ranges.h
  /opt/local/include/papilo/external/lusol/clusol.h
  /opt/local/include/papilo/external/pdqsort/pdqsort.h
  /opt/local/include/papilo/external/ska/bytell_hash_map.hpp
  /opt/local/include/papilo/external/ska/flat_hash_map.hpp
  /opt/local/include/papilo/external/ska/unordered_map.hpp
  /opt/local/include/papilo/interfaces/GlopInterface.hpp
  /opt/local/include/papilo/interfaces/GurobiInterface.hpp
  /opt/local/include/papilo/interfaces/HighsInterface.hpp
  /opt/local/include/papilo/interfaces/RoundingsatInterface.hpp
  /opt/local/include/papilo/interfaces/ScipInterface.hpp
  /opt/local/include/papilo/interfaces/SolverInterface.hpp
  /opt/local/include/papilo/interfaces/SoplexInterface.hpp
  /opt/local/include/papilo/io/BoundType.hpp
  /opt/local/include/papilo/io/Message.hpp
  /opt/local/include/papilo/io/MpsParser.hpp
  /opt/local/include/papilo/io/MpsWriter.hpp
  /opt/local/include/papilo/io/OpbParser.hpp
  /opt/local/include/papilo/io/OpbWriter.hpp
  /opt/local/include/papilo/io/ParseKey.hpp
  /opt/local/include/papilo/io/Parser.hpp
  /opt/local/include/papilo/io/SolParser.hpp
  /opt/local/include/papilo/io/SolWriter.hpp
  /opt/local/include/papilo/misc/Alloc.hpp
  /opt/local/include/papilo/misc/Array.hpp
  /opt/local/include/papilo/misc/DependentRows.hpp
  /opt/local/include/papilo/misc/Flags.hpp
  /opt/local/include/papilo/misc/Hash.hpp
  /opt/local/include/papilo/misc/MultiPrecision.hpp
  /opt/local/include/papilo/misc/Num.hpp
  /opt/local/include/papilo/misc/NumericalStatistics.hpp
  /opt/local/include/papilo/misc/OptionsParser.hpp
  /opt/local/include/papilo/misc/ParameterSet.hpp
  /opt/local/include/papilo/misc/PrimalDualSolValidation.hpp
  /opt/local/include/papilo/misc/Signature.hpp
  /opt/local/include/papilo/misc/StableSum.hpp
  /opt/local/include/papilo/misc/String.hpp
  /opt/local/include/papilo/misc/Timer.hpp
  /opt/local/include/papilo/misc/Validation.hpp
  /opt/local/include/papilo/misc/Vec.hpp
  /opt/local/include/papilo/misc/VectorUtils.hpp
  /opt/local/include/papilo/misc/VersionLogger.hpp
  /opt/local/include/papilo/misc/Wrappers.hpp
  /opt/local/include/papilo/misc/compress_vector.hpp
  /opt/local/include/papilo/misc/fmt.hpp
  /opt/local/include/papilo/misc/tbb.hpp
  /opt/local/include/papilo/presolvers/CoefficientStrengthening.hpp
  /opt/local/include/papilo/presolvers/ConstraintPropagation.hpp
  /opt/local/include/papilo/presolvers/DominatedCols.hpp
  /opt/local/include/papilo/presolvers/DualFix.hpp
  /opt/local/include/papilo/presolvers/DualInfer.hpp
  /opt/local/include/papilo/presolvers/FixContinuous.hpp
  /opt/local/include/papilo/presolvers/FreeVarSubstitution.hpp
  /opt/local/include/papilo/presolvers/ImplIntDetection.hpp
  /opt/local/include/papilo/presolvers/ParallelColDetection.hpp
  /opt/local/include/papilo/presolvers/ParallelRowDetection.hpp
  /opt/local/include/papilo/presolvers/Probing.hpp
  /opt/local/include/papilo/presolvers/SimpleProbing.hpp
  /opt/local/include/papilo/presolvers/SimpleSubstitution.hpp
  /opt/local/include/papilo/presolvers/SimplifyInequalities.hpp
  /opt/local/include/papilo/presolvers/SingletonCols.hpp
  /opt/local/include/papilo/presolvers/SingletonStuffing.hpp
  /opt/local/include/papilo/presolvers/Sparsify.hpp
  /opt/local/include/papilo/verification/ArgumentType.hpp
  /opt/local/include/papilo/verification/CertificateInterface.hpp
  /opt/local/include/papilo/verification/EmptyCertificate.hpp
  /opt/local/include/papilo/verification/VeriPb.hpp
  /opt/local/lib/cmake/papilo/FindTBB.cmake
  /opt/local/lib/cmake/papilo/papilo-config-version.cmake
  /opt/local/lib/cmake/papilo/papilo-config.cmake
  /opt/local/lib/cmake/papilo/papilo-targets-macports.cmake
  /opt/local/lib/cmake/papilo/papilo-targets.cmake
  /opt/local/lib/libclusol.a
  /opt/local/lib/libpapilo-core.a

P. S. Original issue: lgottwald/PaPILO#56

@alexhoen alexhoen self-assigned this Sep 16, 2024
@svigerske
Copy link
Member

svigerske commented Sep 21, 2024

libpapilo is a library with an API that lets you set up an LP or MIP and get it solved via SCIP and SoPlex, as far as I see. It is only build if SCIP and SoPlex are found. However, for this library, -DBUILD_SHARED_LIBS=ON should have an effect.

But libpapilo-core and libclusol are defined to be always build as static libraries. I don't know the history, e.g., whether these libs were initially meant not to be installed. Also, I'm not sure whether the classes in methods in libpapilo-core were even meant to be part of a public API. They are no attributes in the source that declare what should be visible in a shared/dynamic library. By default, all symbols there have visibility=hidden, which is ok for static libs, but makes them unusable in shared libs. Therefore, if you need to build these as shared libs, you will have to remove this too:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,8 +29,6 @@ include(GNUInstallDirs)
 
 # path to e.g. findGMP module
 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules/)
-set(CMAKE_CXX_VISIBILITY_PRESET hidden)
-set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
 # disable fused floating point contraction to enhance reproducibility across compilers and architectures
@@ -211,7 +209,7 @@ endif()
 if(CMAKE_Fortran_COMPILER AND BLAS_FOUND)
    enable_language(Fortran)
 
-   add_library(clusol STATIC
+   add_library(clusol
       src/papilo/external/lusol/src/lusol6b.f
       src/papilo/external/lusol/src/lusol7b.f
       src/papilo/external/lusol/src/lusol8b.f
@@ -257,7 +255,7 @@ else()
    set(PAPILO_USE_STANDARD_HASHMAP 1)
 endif()
 
-add_library(papilo-core STATIC
+add_library(papilo-core
    src/papilo/core/VariableDomains.cpp
    src/papilo/core/SparseStorage.cpp
    src/papilo/core/ConstraintMatrix.cpp

I can then get these libs are shared libs when setting -DBUILD_SHARED_LIBS=ON on my Linux system.
I have some doubt that it would be sufficient to build usable Windows DLLs though, since there nothing is exported in a DLL unless it got an explicit dllexport attribute (or via .def file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants