New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined References when using recommended linking option: Embedding Python in C++ #93358
Labels
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
Yes, the docs are out of date. This was changed in Python 3.8 -- see the 3.8 What's New: https://docs.python.org/3/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build Adding |
This comment was marked as off-topic.
This comment was marked as off-topic.
erlend-aasland
added a commit
to erlend-aasland/cpython
that referenced
this issue
Oct 25, 2022
erlend-aasland
added a commit
that referenced
this issue
Oct 29, 2022
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Oct 29, 2022
…nGH-98649) (cherry picked from commit e063c23) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Oct 29, 2022
…nGH-98649) (cherry picked from commit e063c23) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
miss-islington
added a commit
that referenced
this issue
Oct 29, 2022
miss-islington
added a commit
that referenced
this issue
Oct 29, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v-volatus commentedMay 30, 2022
•
edited
Documentation
URL: https://docs.python.org/3/extending/embedding.html
System: Ubuntu 22.04 using Python 3.10
Problem:
Using the recommended linking option
/opt/bin/python3.10-config --ldflags
leads to undefined references when compiling.command used in terminal:
g++ $(python3.10-config --cflags ) -o 'test.o' 'test.cpp' $(python3.10-config --ldflags)
Output of
python3.10-config --ldflags
:-L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lcrypt -ldl -lm -lm
Solution:
Adding the option
--embed
solves the issue. By this,-lpython3.10
is also given to the compiler.command used in terminal:
g++ $(python3.10-config --cflags ) -o 'test.o' 'test.cpp' $(python3.10-config --embed --ldflags)
output of
python3.10-config --embed --ldflags
:-L/usr/lib/python3.10/config-3.10-x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lpython3.10 -lcrypt -ldl -lm -lm
test.cpp:
The text was updated successfully, but these errors were encountered: