pyd icon indicating copy to clipboard operation
pyd copied to clipboard

ldc can't link embedded python properly on ubuntu

Open ariovistus opened this issue 10 years ago • 12 comments
trafficstars

and probably anywhere Py_ENABLE_SHARED is false. symptom: ImportError: /usr/lib/python3/dist-packages/numpy/core/multiarray.cpython-32mu.so: undefined symbol: PyExc_SystemError

ramification: can't use numpy and other extensions

solution: insert -rdynamic early in the link flags. unfortunately, ldc rearranges flag order, and exposes no way to override.

other solution: go back to gcc for link command. please no.

ariovistus avatar Nov 11 '15 05:11 ariovistus

Is -rdynamic the only possible workaround? Quick googling shows that many solve this problem just by adding dlopen("libpython<PYTHON_VERSION>.so.1", RTLD_LAZY | RTLD_GLOBAL); before Py_Initialize()

lomereiter avatar May 31 '16 06:05 lomereiter

LDC has recently changed the linker flag order behavior. Please try again, and otherwise open an issue with LDC, thanks!

JohanEngelen avatar Dec 18 '17 19:12 JohanEngelen

I assume this would be in 1.6?

ariovistus avatar Dec 18 '17 20:12 ariovistus

Yes indeed, 1.6.0 has what I meant. I may be remembering things wrong. But we had a discussion and some changes related to linking flags and their order (but perhaps only related to the flags in ldc.conf)

JohanEngelen avatar Dec 18 '17 21:12 JohanEngelen

Ok. will check it out when I get some time.

ariovistus avatar Dec 18 '17 21:12 ariovistus

there wouldn't happen to be a quicker way to install than build from source, would there? on 16.04, apt-get serves 0.17.1

ariovistus avatar Dec 19 '17 01:12 ariovistus

curl -fsS https://dlang.org/install.sh | bash -s install ldc

JohanEngelen avatar Dec 19 '17 07:12 JohanEngelen

https://dlang.org/download.html

JohanEngelen avatar Dec 19 '17 07:12 JohanEngelen

@JohanEngelen FYI: We can do it even a bit shorter: curl i.dlang.io | bash -s ldc

Since yesterday we also have a documentation page for the installer: https://dlang.org/install.html

wilzbach avatar Dec 19 '17 07:12 wilzbach

Looks like ubuntu stopped building python with Py_ENABLE_SHARED=false, so this might not be much of an issue anymore.

ariovistus avatar Dec 19 '17 15:12 ariovistus

@wilzbach

FYI: We can do it even a bit shorter: curl i.dlang.io | bash -s ldc

Brevity here is useless, and harms intelligibility. The original one at least makes it clear that you are downloading a shell script, and that you are installing ldc.

The installer page is very nice. (link needs to be added to the top menu!)

JohanEngelen avatar Dec 20 '17 19:12 JohanEngelen

ubuntu 12.04 has an appropriate python build. With pyd from master and ldc 1.6.0, the following code is sufficient to trigger the aforementioned symptom:

auto context = new InterpContext();
context.py_stmts("import numpy");

This issue has been collecting dust long enough that I do not remember how to get link to work with -rdynamic. Will need to play with it.

ariovistus avatar Dec 21 '17 06:12 ariovistus