Although my issue is related to building Python, it could be considered generic. I have built Python with a custom TclTk
installation, using --with-tcltk-includes
and --with-tcltk-libs
. Say I passed /foo/bar/spam
path to the latter. The problem is, when I use strace
to check where the binary looks for its shared libraries, I see /foo/bar/spam
in the search path, although I do not want that because this application will be shipped and this path does not exist anywhere else beyond my own machine. So I want to use it just during the build, but not as a search path for the generated binary. Any ideas?
Asked
Active
Viewed 21 times
0

luizbarcelos
- 686
- 5
- 17
-
1Use static linking? – MattDMo Sep 02 '21 at 16:54
-
Thanks for your answer! That would probably do, is it possible to static link a specific library using `LDFLAGS`? – luizbarcelos Sep 02 '21 at 17:03
1 Answers
0
Static linking is probably your best bet, because you likely can't guarantee that your customers will have any of the other required libraries (like sqlite3
, for example) either. Just don't pass the flag --enable-shared
to ./configure
and it will build a statically-linked lib by default.
Unfortunately, I don't see a way with the standard options to build a partial-static/partial dynamic lib. That doesn't mean it isn't possible with some creative tinkering with the Makefile
, but conceptually I'm not sure how it would work anyway.

MattDMo
- 100,794
- 21
- 241
- 231
-
I agree with the overall direction you are going but, although I have not tried your solution yet, some other threads suggest that building Python statically requires a bit more work (consider checking this [thread](https://stackoverflow.com/questions/1150373/compile-the-python-interpreter-statically) and [this](https://wiki.python.org/moin/BuildStatically) Python wiki post on building statically). What do you think? – luizbarcelos Sep 02 '21 at 18:40
-
@luizbarcelos [This](https://stackoverflow.com/q/1150373) question you linked (haha) and most of its answers are from 2009 (one is from 2015), and I suspect the Python wiki entry is from about that era, as well. Things have changed a LOT since then. I just downloaded the 3.9.7 source on my Linux server, ran `./configure --prefix=$HOME && make` and it produced the `python` binary and a `libpython3.9.a` statically-linked library. No fuss, no bother. Maybe I'll update the Python wiki page at some point... – MattDMo Sep 04 '21 at 20:20