Package: libboost-regex-dev
Version: 1.74.0.3
Severity: normal
X-Debbugs-Cc: fbora...@gmail.com

Dear Maintainer,

I wanted compile fat dynamic library with all its dependencies linked static 
and hidden symbols.

Let demonstrate on example:

```CMake
set(Boost_VERBOSE ON)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED COMPONENTS regex)

# library
add_library(lib_r SHARED lib_r.cc)
target_link_libraries(lib_r PRIVATE Boost::regex)

# executable
add_executable(test_r main_r.cc)
target_link_libraries(test_r PRIVATE lib_r)
```

with `set(Boost_USE_STATIC_LIBS ON)` is find static version of library

```
-- Found boost_regex 1.74.0 at 
/usr/lib/x86_64-linux-gnu/cmake/boost_regex-1.74.0
--   [ ] libboost_regex.so.1.74.0
--   [x] libboost_regex.a
```

and linking of shared library fails on:
```
[ 50%] Linking CXX shared library liblib_r.so
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_regex.a(regex.o): warning: 
relocation against `_ZTVN5boost10wrapexceptISt11logic_errorEE' in read-only 
section `.text.unlikely'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libboost_regex.a(instances.o): 
relocation R_X86_64_PC32 against symbol 
`_ZTVSt15basic_streambufIcSt11char_traitsIcEE@@GLIBCXX_3.4' can not be used 
when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
```

full example: https://github.com/fboranek/boost-static

I think that even static library `libboost_regex.a` should be built with 
position independent code flag `-PIC`. I try the same for `Boost::thread` with 
the same result, so it apply probably on whole boost.

I try compile boost directly
```
./bootstrap.sh --with-libraries=regex
./b2 link=static runtime-link=shared
```

and replace `Boost::regex` by `boost/stage/lib/libboost_regex.a` and library 
and executable is liked witout issue. In light of this it seems the problem 
with packaging. I clone latest boost repo.

BR,
Frantisek

-- System Information:
Debian Release: 12.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-25-amd64 (SMP w/24 CPU threads)
Locale: LANG=C, LC_CTYPE=C (charmap=UTF-8) (ignored: LC_ALL set to C.UTF-8), 
LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages libboost-regex-dev depends on:
ii  libboost-regex1.74-dev  1.74.0+ds1-21

libboost-regex-dev recommends no packages.

libboost-regex-dev suggests no packages.

-- no debconf information

Reply via email to