Skip to content
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

Error "undefined symbol: PL_new_atom" when reading files #10

morxa opened this issue Jan 24, 2017 · 2 comments

Error "undefined symbol: PL_new_atom" when reading files #10

morxa opened this issue Jan 24, 2017 · 2 comments


Copy link

morxa commented Jan 24, 2017

When reading files, I always get the following error:

python3: symbol lookup error: /usr/lib64/swipl-7.2.3/lib/x86_64-linux/ undefined symbol: PL_new_atom

How to reproduce

  1. Copy the following into

    read_file(Filename, Strings) :-
      open(Filename, read, Stream),
      read_stream_string(Stream, Strings),
    read_stream_string(Stream, Strings) :-
      read_line_to_string(Stream, String),
      ( String == end_of_file -> Strings = []
        read_stream_string(Stream, RStrings),
        Strings = [String|RStrings]
  2. Copy the following to

    from pyswip.prolog import Prolog
    from pyswip.core import *
    prolog = Prolog()
    list(prolog.query('read_file("", S)'))
  3. Run python3, which will produce the output:

    python3: symbol lookup error: /usr/lib64/swipl-7.2.3/lib/x86_64-linux/ undefined symbol: PL_new_atom


PL_new_atom is defined in, but is not linked against libswipl. As a workaround, can be LD_PRELOADed:

$ export LD_PRELOAD=/usr/lib64/swipl-7.2.3/lib/x86_64-linux/
$ python3

After preloading the shared lib, the error disappears (and #9 occurs). This show that this is indeed a problem with linking.

I'm not sure if this is an error on the pyswip side or the swipl side, but I assume if you always load, then the error will disappear.

This is on Fedora 25 with SWi-Prolog 7.2.3.

@morxa morxa changed the title undefined symbol: PL_new_atom when reading files Error "undefined symbol: PL_new_atom" when reading files Jan 24, 2017
Copy link

jannikb commented Mar 17, 2018

I had a similiar issue while loading the odbc library on ubuntu 16.04 and swi-prolog 7.6.4:
'$open_shared_object'/3: /usr/lib/swi-prolog/lib/amd64/ undefined symbol: PL_get_long

The workaround with LD_PRELOAD also worked for me with an adjusted path:
export LD_PRELOAD=/usr/lib/

@yuce yuce closed this as completed in 1d560cc May 24, 2018
yuce added a commit that referenced this issue May 24, 2018
Copy link

yuce commented May 24, 2018

Thanks @morxa. The test case you provided was very useful. Passing mode=RTLD_GLOBAL to library loader fixed this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants