Skip to content

Failure when compiling with static libs #7192

@efifogel

Description

@efifogel

Issue Details

Every program that uses CGAL and is linked with static lib creashes

Source Code

Below is a simple test case and a small script that compiles and links the program with static libraries.
The script, naturally, must be edited. One can also use the attached CMakeLists.txt.
It fails on version 5.4 but works properly on version 5.3.
More precisely, it fails on commit:
5072518, Thu Jul 29 14:31:10 2021 +0200
but works fine with the one before that, namely:
bdba6ee

I get:
[ola] test > ./mytest
s: 4 4 1 5
r1: 3 2 3 3
before 0
xp: 3 4.33333
terminate called after throwing an instance of 'std::system_error'
what(): Unknown error -1
Aborted (core dumped)

When the program is compiled with shared libraries it works fine.

Environment

  • Operating system: Ubuntu 20.04
  • Compiler: g++ 9.4.0
  • Release or debug mode:
  • Specific flags used (if any):
  • CGAL version: started somewhere between 5.3 and 5.4
  • Boost version: irrelevant, but 1.79
  • Other libraries versions if used (Eigen, TBB, etc.): it is probably irrelevant, cmake (3.25.1), boost (1.79), gmp (6.2.0), and mpfr (4.0.2)

CMakeLists.txt

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
int main() {
  using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
  using Pt = Kernel::Point_2;

  Kernel kernel;
  const auto ctr_ray = kernel.construct_ray_2_object();
  const auto ctr_seg = kernel.construct_segment_2_object();
  const auto intersect = kernel.intersect_2_object();

  auto s = ctr_seg(Pt(4,4), Pt(1,5));
  auto r1 = ctr_ray(Pt(3,2), Pt(3,3));

  const auto eq = kernel.equal_2_object();
  std::cout << "s: " << s << std::endl;
  std::cout << "r1: " << r1 << std::endl;
  auto res = intersect(s, r1);
  if (! res) {
    std::cout << "No intersection\n";
    return -1;
  }
  const Pt* xp = boost::get<Pt>(&*res);
  if (! xp) {
    std::cout << "No point intersection\n";
    return -1;
  }
  std::cout << "before 0\n";
  std::cout << "xp: " << *xp << std::endl;
  auto rc = eq(*xp, *xp);
  std::cout << "rc: " << rc << std::endl;
  std::cout << "after 1\n";
  return 1;
}
g++ mytest.cpp -o mytest \
-static-libgcc -static-libstdc++ -static \
-DCGAL_USE_GMPXX=1 \
-isystem /home/efif/trees/cgal/cgal_dev/Installation/include \
-isystem /home/efif/trees/cgal/cgal_dev/STL_Extension/include \
-isystem /home/efif/trees/cgal/cgal_dev/Interval_support/include \
-isystem /home/efif/trees/cgal/cgal_dev/Stream_support/include \
-isystem /home/efif/trees/cgal/cgal_dev/Profiling_tools/include \
-isystem /home/efif/trees/cgal/cgal_dev/Cartesian_kernel/include \
-isystem /home/efif/trees/cgal/cgal_dev/Homogeneous_kernel/include \
-isystem /home/efif/trees/cgal/cgal_dev/Arithmetic_kernel/include \
-isystem /home/efif/trees/cgal/cgal_dev/Filtered_kernel/include \
-isystem /home/efif/trees/cgal/cgal_dev/Kernel_23/include \
-isystem /home/efif/trees/cgal/cgal_dev/Number_types/include \
-isystem /home/efif/trees/cgal/cgal_dev/Modular_arithmetic/include \
-isystem /home/efif/trees/cgal/cgal_dev/Algebraic_foundations/include \
-isystem /home/efif/trees/cgal/cgal_dev/Distance_2/include \
-isystem /home/efif/trees/cgal/cgal_dev/Distance_3/include \
-isystem /home/efif/trees/cgal/cgal_dev/Intersections_2/include \
-isystem /home/efif/trees/cgal/cgal_dev/Intersections_3/include \
-isystem /home/efif/trees/cgal/cgal_dev/Arrangement_on_surface_2/include \
-isystem /home/efif/trees/cgal/cgal_dev/Kernel_d/include \
/usr/lib/x86_64-linux-gnu/libgmpxx.a \
/usr/lib/x86_64-linux-gnu/libmpfr.a \
/usr/lib/x86_64-linux-gnu/libgmp.a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions