Skip to content

Conversation

@jcfr
Copy link
Contributor

@jcfr jcfr commented Aug 16, 2025

DCMTK no longer unconditionally test or link against nsl and socket. These libraries are now only considered on pre-11.4 Solaris systems, where functions such as gethostbyname were historically provided outside libc.

On modern systems (Linux, BSD, macOS, Solaris >= 11.4), networking APIs (gethostbyname, getaddrinfo, socket, etc.) are provided directly by libc, so linking -lnsl or -lsocket is unnecessary.

This streamlines integration of DCMTK into external projects by removing dependencies on libraries that may directly or indirectly pull in a different OpenSSL version than the one bundled with the application.

Background:

  • Solaris historically required -lsocket -lnsl for basic networking.
  • Since Solaris 11.4, libnsl functionality has been folded into libc.

Verification:

  • Confirmed that no libnsl-only symbols are referenced in DCMTK by grepping sources against the exported symbol set of libnsl.

References:

DCMTK no longer unconditionally test or link against `nsl` and `socket`.
These libraries are now only considered on pre-11.4 Solaris systems,
where functions such as `gethostbyname` were historically provided
outside libc.

On modern systems (Linux, BSD, macOS, Solaris >= 11.4), networking APIs
(`gethostbyname`, `getaddrinfo`, `socket`, etc.) are provided directly
by libc, so linking `-lnsl` or `-lsocket` is unnecessary.

This streamlines integration of DCMTK into external projects by removing
dependencies on libraries that may directly or indirectly pull in a
different OpenSSL version than the one bundled with the application.

Background:
- Solaris historically required `-lsocket -lnsl` for basic networking.
- Since Solaris 11.4, `libnsl` functionality has been folded into libc.

Verification:
- Confirmed that no `libnsl`-only symbols are referenced in DCMTK by
  grepping sources against the exported symbol set of `libnsl`.

References:
* https://man7.org/linux/man-pages/man3/gethostbyname.3.html
* https://man7.org/linux/man-pages/man3/getaddrinfo.3.html
* https://man7.org/linux/man-pages/man2/socket.2.html
* https://docs.oracle.com/cd/E88353_01/html/E37842/libnsl-3lib.html
@jcfr
Copy link
Contributor Author

jcfr commented Aug 16, 2025

For reference, the following was used to check that no libnsl-only symbols are referenced in DCMTK by grepping sources against the exported symbol set of libnsl:

cd /path/to/src/dcmtk
for func in $(readelf -C --wide --dynamic -s /usr/lib/x86_64-linux-gnu/libnsl.so.2.0.1 | \
    grep -v ' UND ' |  \
    grep " FUNC " | \
    awk '{print $NF}' | \
    sed -E 's/(.+)@@.+/\1/');
do
  ack "$func"
done

@jcfr
Copy link
Contributor Author

jcfr commented Aug 16, 2025

Copy link

@pieper pieper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@michaelonken
Copy link
Member

@eichelberg Marco, since you are our Solaris guy, maybe this is something for you.

@eichelberg eichelberg closed this Aug 19, 2025
@eichelberg
Copy link
Member

Merged into DCMTK's testing branch.

michaelonken pushed a commit to michaelonken/dcmtk that referenced this pull request Aug 19, 2025
DCMTK no longer unconditionally tests or links against `nsl` and `socket`.
These libraries are now only considered on pre-11.4 Solaris systems,
where functions such as `gethostbyname` were historically provided
outside libc. This avoids dependencies on libraries that may directly
or indirectly pull in a different OpenSSL version.

Thanks to Jean-Christophe Fillion-Robin <[email protected]>
for the pull request.

This closes GitHub PR DCMTK#125.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants