libpostal icon indicating copy to clipboard operation
libpostal copied to clipboard

Can't run the example in README on Ubuntu 22.04.1 LTS

Open andreyuhai opened this issue 2 years ago • 0 comments

Hi! 👋

What problem we had

We actually wanted to use Libpostal through NIFs, in Erlang/Elixir. There's a library created for that SweetIQ/expostal and that library basically compiles some C functions using libpostal so we can use them in Elixir.

However on alpine, we had some problems using that library even though it was working fine locally on macOS and the error we got from the library is:

13:18:25.439 [error] Process #PID<0.202.0> raised an exception
** (MatchError) no match of right hand side value: {:error, {:load_failed, 'Failed to load NIF library: \'Error relocating /foobar/_build/dev/lib/expostal/priv/expostal.so: libpostal_setup_parser: symbol not found\''}}
    (expostal 0.2.0) lib/expostal.ex:13: Expostal.init/0
    (kernel 8.5) code_server.erl:1317: anonymous fn/1 in :code_server.handle_on_load/5

What I've done so far

After trying to find out what could be wrong, just to see if I could run the example, I've compiled & installed libpostal from source on an Ubuntu 22.04.1 LTS container and created a file which had the example code in the README. After compiling the file when I wanted to run it, I got

root@52ff9160133d:~# gcc -I/usr/local/include/ -shared foo.c
root@52ff9160133d:~# ./a.out
Segmentation fault

I might've compiled it wrong as it's been quite a while since I touched anything C, but I wanted to ask for help here.

root@52ff9160133d:~# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.2.0-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-gBFGDP/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-gBFGDP/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1)

andreyuhai avatar Oct 05 '22 11:10 andreyuhai