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

Aligning an already installed version of librdkafka with Alien::Librdkafka fails #17

Open
ghost opened this issue Oct 12, 2021 · 4 comments

Comments

@ghost
Copy link

ghost commented Oct 12, 2021

Hello!

I successfully compiled the latest version (1.8.2) of librdkafka. But getting this into the perl context fails. What I did:

server1:~ # perl -MCPAN -e 'shell'
cpan[1]> install Alien::Librdkafka
[...]
# perl                               5.026001
# Alien::Base                        2.42
# Alien::Build                       2.42
# Alien::Build::MM                   2.42
# Alien::Build::Plugin::Probe::Vcpkg 2.42
# ExtUtils::MakeMaker                7.24
# Test2::V0                          0.000141
# Test::Alien                        2.42
# version                            0.9917
#
#
#
t/00_diag.t ........... ok
t/alien_librdkafka.t .. #
#
#
# Alien::Librdkafka->version      = 1.8.2
# Alien::Librdkafka->cflags       = -I/usr/local/include
# Alien::Librdkafka->libs         = -L/usr/local/lib -lrdkafka
# Alien::Librdkafka->dynamic_libs = /usr/local/lib/librdkafka.so.1
#
#
t/alien_librdkafka.t .. 1/?
# Failed test 'xs'
# at t/alien_librdkafka.t line 26.
#   XSLoader failed
#     Can't load '/root/.cpan/build/Alien-Librdkafka-1.05-0/_alien/tmp/test-alien-48ZAg8/auto/librdkafka/librdkafka.so' for module librdkafka: librdkafka.so.1: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.26.1/x86_64-linux-thread-multi/DynaLoader.pm line 193.
#  at /usr/lib/perl5/site_perl/5.26.1/Test/Alien.pm line 422.
# Compilation failed in require at /usr/lib/perl5/site_perl/5.26.1/Test/Alien.pm line 422.
# BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.26.1/Test/Alien.pm line 422.
t/alien_librdkafka.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests
        (less 1 skipped subtest: 3 okay)

Test Summary Report
-------------------
t/alien_librdkafka.t (Wstat: 256 Tests: 5 Failed: 1)
  Failed test:  2
  Non-zero exit status: 1
Files=2, Tests=6,  1 wallclock secs ( 0.04 usr  0.02 sys +  1.02 cusr  0.15 csys =  1.23 CPU)
Result: FAIL
Failed 1/2 test programs. 1/6 subtests failed.
make: *** [Makefile:911: test_dynamic] Error 1
  PLICEASE/Alien-Librdkafka-1.05.tar.gz
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports PLICEASE/Alien-Librdkafka-1.05.tar.gz
Failed during this command:
 PLICEASE/Alien-Librdkafka-1.05.tar.gz        : make_test NO

Would be nice if someone could comment on this...

@plicease
Copy link
Member

Looks like it is compiling the toy XS okay, but failing when it tries to load it. This can happen if the .so file is not in the system search path.

@ghost
Copy link
Author

ghost commented Oct 14, 2021

Hello Graham, thanks for looking into this. Maybe one step back. Based on the Description section of your github page, an already existing librdkafka is used by Alien::Librdkafka instead of downloading and compiling it. Based on the output above, is this the case?

From this output from above, the installation via perl -MCPAN -e 'shell' seems to be looking at the right place.

# Alien::Librdkafka->libs         = -L/usr/local/lib -lrdkafka
# Alien::Librdkafka->dynamic_libs = /usr/local/lib/librdkafka.so.1

And the library is there

# find /usr | grep librdkafka.so | xargs ls -l
lrwxrwxrwx 1 root root      15 Oct 14 09:57 /usr/local/lib/librdkafka.so -> librdkafka.so.1
-rwxr-xr-x 1 root root 9130552 Oct 14 09:57 /usr/local/lib/librdkafka.so.1

Is there a way to manually execute the step(s) that is/are failing to dig into this further?

@plicease
Copy link
Member

You can get more detail by running prove in verbose mode:

prove -bvm t/alien_librdkafka.t

I think thought that this is a configuration problem with the system. I understand the .so file is in /usr/local/lib, otherwise the link step wouldn't work. It's breaking when the XS shared library is being loaded. The search for dynamic libs (librdkafka.so.1) doesn't have anything to do with the compiler or linker flags, and is unfortunately platform dependent.

On Linux and some other platforms you can use LD_LIBRARY_PATH to explicitly add directories to the search path, but I recommend using that only to troubleshoot. If you let me know exactly what OS (and which distribution if Linux) I might be able to point you in the right direction.

@ghost
Copy link
Author

ghost commented Oct 14, 2021

Hey Graham,

it works...

The system I am using is SLES15SP3.

I reverted my VM to the original state and installed librdkafka-v1.8.0.

# ll /usr/local/lib/librdkafka.so*
lrwxrwxrwx 1 root root      15 Oct 14 20:10 /usr/local/lib/librdkafka.so -> librdkafka.so.1
-rwxr-xr-x 1 root root 9130552 Oct 14 20:10 /usr/local/lib/librdkafka.so.1

I then installed Alien::Librdkafka, which again failed.

Then I ran

server1:~/.cpan/build/Alien-Librdkafka-1.05-0 # prove -bvm t/alien_librdkafka.t
t/alien_librdkafka.t ..
#
#
#
# Alien::Librdkafka->version      = 1.8.0
# Alien::Librdkafka->cflags       = -DOPENSSL_LOAD_CONF -I/usr/local/include
# Alien::Librdkafka->libs         = -L/usr/local/lib -lrdkafka
# Alien::Librdkafka->dynamic_libs = /usr/local/lib/librdkafka.so.1
#
#
ok 1 - Alien::Librdkafka responds to: cflags libs dynamic_libs bin_dir
not ok 2 - xs

# Failed test 'xs'
# at t/alien_librdkafka.t line 26.
#   XSLoader failed
#     Can't load '/root/.cpan/build/Alien-Librdkafka-1.05-0/_alien/tmp/test-alien-hPQ4xr/auto/librdkafka/librdkafka.so' for module librdkafka: librdkafka.so.1: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.26.1/x86_64-linux-thread-multi/DynaLoader.pm line 193.
#  at /usr/lib/perl5/site_perl/5.26.1/Test/Alien.pm line 422.
# Compilation failed in require at /usr/lib/perl5/site_perl/5.26.1/Test/Alien.pm line 422.
# BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.26.1/Test/Alien.pm line 422.
ok 3 - xs subtest {
    1..0 # SKIP subtest requires xs success
}
ok 4 - ffi # skip Test requires FFI::Platypus 0.12
ok 5 - ffi subtest {
    1..0 # SKIP subtest requires ffi success
}
1..5
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests
        (less 1 skipped subtest: 3 okay)

Test Summary Report
-------------------
t/alien_librdkafka.t (Wstat: 256 Tests: 5 Failed: 1)
  Failed test:  2
  Non-zero exit status: 1
Files=1, Tests=5,  1 wallclock secs ( 0.05 usr  0.00 sys +  0.58 cusr  0.14 csys =  0.77 CPU)
Result: FAIL

I then configured LD_LIBRARY_PATH=/usr/local/lib.

export LD_LIBRARY_PATH=/usr/local/lib
prove -bvm t/alien_librdkafka.t
t/alien_librdkafka.t ..
#
#
#
# Alien::Librdkafka->version      = 1.8.0
# Alien::Librdkafka->cflags       = -DOPENSSL_LOAD_CONF -I/usr/local/include
# Alien::Librdkafka->libs         = -L/usr/local/lib -lrdkafka
# Alien::Librdkafka->dynamic_libs = /usr/local/lib/librdkafka.so.1
#
#
ok 1 - Alien::Librdkafka responds to: cflags libs dynamic_libs bin_dir
ok 2 - xs
ok 3 - xs subtest {
    ok 1 - library version is at least 0.9.3
    # version = 1.8.0
    1..1
}
ok 4 - ffi # skip Test requires FFI::Platypus 0.12
ok 5 - ffi subtest {
    1..0 # SKIP subtest requires ffi success
}
1..5
ok
All tests successful.
Files=1, Tests=5,  1 wallclock secs ( 0.04 usr  0.02 sys +  0.73 cusr  0.12 csys =  0.91 CPU)
Result: PASS

I went ahead and reran perl -MCPAN -e 'shell' with LD_LIBRARY_PATH and installed Alien::Librdkafka, which worked fine as well.

My perl application then started without LD_LIBRARY_PATH being set.

Thanks a lot for your help!

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

No branches or pull requests

1 participant