Skip to content

Linking c/c++ executable to shared libs #638

Answered by rgommers
ericgtkb asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ericgtkb, thanks for the clear example.

My first thought is that it's probably better to do one of two things:

  1. make mylib a static library and link it into the executable
  2. install both the shared library and the executable inside site-packages/myproj in the same subdirectory. Then add a [project.scripts] entrypoint in pyproject.toml to call the executable

(1) is an easier and smaller change than (2) if that's acceptable. If you do need the shared library installed, then you need (2). Both are portable also to Windows, while setting an RPATH is not. I'm also not even sure if the relative path from {bindir} to site-packages is constant for all possible install schemes.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@rgommers
Comment options

@ericgtkb
Comment options

@Yashdate10
Comment options

Answer selected by ericgtkb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants