in reply to Device::USB gives "Use of uninitialized value in concatenation" error

What do you think the "error" means?

Did you add "use diagnostics;" to get a more verbose "error" message?

Do you have defined $ENV{LIBUSB_LIBDIR} ? Try getting rid of that (not defining it)

  • Comment on Re: Device::USB gives "Use of uninitialized value in concatenation" error

Replies are listed 'Best First'.
Re^2: Device::USB gives "Use of uninitialized value in concatenation" error
by holandes777 (Scribe) on Dec 10, 2013 at 23:46 UTC

    I think the error means the module is trying to perform a concatenation and one of the variables it is attempting to use is undefined. This is definitely the case with $ENV{LIBUSB_LIBDIR}, it is undefined.

    Device::USB is a cpan module, rather than trying to get rid of the variable I think I should ascertain what its value should be

    root@gk-kubuntu-dev:~/dav/Nevada# find / -name libusb* /lib/firmware/carl9170fw/extra/libusb-zeropacket.diff /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4 /lib/x86_64-linux-gnu/libusb-0.1.so.4 /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0 /lib/x86_64-linux-gnu/libusb-1.0.so.0 /var/cache/apt/archives/libusb-1.0-0-dbg_2%3a1.0.16-3_amd64.deb /var/cache/apt/archives/libusb-1.0-0-dev_2%3a1.0.16-3_amd64.deb /var/cache/apt/archives/libusb-1.0-doc_2%3a1.0.16-3_all.deb /var/lib/dpkg/info/libusb-0.1-4:amd64.shlibs /var/lib/dpkg/info/libusb-1.0-0-dbg:amd64.list /var/lib/dpkg/info/libusb-1.0-0:amd64.md5sums /var/lib/dpkg/info/libusb-0.1-4:amd64.symbols /var/lib/dpkg/info/libusb-1.0-0:amd64.postrm /var/lib/dpkg/info/libusbmuxd2.symbols /var/lib/dpkg/info/libusb-0.1-4:amd64.postrm /var/lib/dpkg/info/libusb-1.0-0:amd64.postinst /var/lib/dpkg/info/libusbmuxd2.postinst /var/lib/dpkg/info/libusb-1.0-0:amd64.shlibs /var/lib/dpkg/info/libusb-0.1-4:amd64.postinst /var/lib/dpkg/info/libusbmuxd2.md5sums /var/lib/dpkg/info/libusb-1.0-doc.list /var/lib/dpkg/info/libusbmuxd2.postrm /var/lib/dpkg/info/libusb-1.0-0-dev:amd64.list /var/lib/dpkg/info/libusb-1.0-doc.md5sums /var/lib/dpkg/info/libusb-1.0-0-dev:amd64.md5sums /var/lib/dpkg/info/libusb-1.0-0:amd64.list /var/lib/dpkg/info/libusb-1.0-0:amd64.symbols /var/lib/dpkg/info/libusb-1.0-0-dbg:amd64.md5sums /var/lib/dpkg/info/libusbmuxd2.shlibs /var/lib/dpkg/info/libusb-0.1-4:amd64.list /var/lib/dpkg/info/libusbmuxd2.list /var/lib/dpkg/info/libusb-0.1-4:amd64.md5sums /usr/share/doc-base/libusb-1.0-doc /usr/share/doc/libusb-1.0-0 /usr/share/doc/libusb-1.0-0-dev /usr/share/doc/libusb-0.1-4 /usr/share/doc/libusb-1.0-doc /usr/share/doc/libusb-1.0-doc/html/libusb_8h_source.html /usr/share/doc/libusb-1.0-0-dbg /usr/share/doc/libusbmuxd2 /usr/lib/libusbmuxd.so.1.0.8 /usr/lib/libusbmuxd.so.2 /usr/lib/x86_64-linux-gnu/libusb-1.0.so /usr/lib/x86_64-linux-gnu/libusb-1.0.a /usr/lib/x86_64-linux-gnu/pkgconfig/libusb-1.0.pc /usr/lib/debug/lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0 /usr/include/libusb-1.0 /usr/include/libusb-1.0/libusb.h

    I chose /lib/x86_64-linux-gnu/ and /usr/include/ and assigned the values to $ENV{LIBUSB_LIBDIR}, neither of which worked.

    Is it possible that there a missing symlink someplace that should point to libusb(somethingorother)? The code from USB.pm is as follows:

    9 use Inline ( 10 C => "DATA", 11 ($ENV{LIBUSB_LIBDIR} 12 ? ( LIBS => "-L\"$ENV{LIBUSB_LIBDIR}\" " . 13 ($^O eq 'MSWin32' ? ' -llibusb -L\"$ENV{W +INDDK}\\lib\\crt\\i386\" -lmsvcrt ' : '-lusb') ) 14 : ( LIBS => '-lusb', ) 15 ), 16 ($ENV{LIBUSB_INCDIR} ? ( INC => "-I\"$ENV{LIBUSB_INCDIR}\ +"" ) : () ), 17 NAME => 'Device::USB', 18 VERSION => '0.35', 19 CCFLAGS => "$Config{ccflags} $ENV{CFLAGS} $ENV{CPPFLAGS}" +, 20 LDDLFLAGS => "$Config{lddlflags} $ENV{LDFLAGS}", 21 ); 22 23 Inline->init();

    I don't recognize what it is. Is it bash code to set up the environment? This is fascinating: I commented out lines 11,12,13,14,15 and the error persists. What is most interesting is that in that section the only concatenation operator is on line 12, and even commented out the error persists. This indicates the error is elsewhere, bu there are no further concatenations in the USB.pm file.

      My guess would be that it's complaining about undefined CFLAGS / CPPFLAGS / LDFLAGS environment variables (see line 19 and 20). Line numbers reported are not always precise when a statement stretches over multiple lines.

      Try setting those env variables to nothing, i.e. export CFLAGS= etc., and see what happens...

        9 use Inline ( 10 C => "DATA", 11 ($ENV{LIBUSB_LIBDIR} 12 ? ( LIBS => "-L\"$ENV{LIBUSB_LIBDIR}\" " . 13 ($^O eq 'MSWin32' ? ' -llibusb -L\"$ENV{W +INDDK}\\lib\\crt\\i386\" -lmsvcrt ' : '-lusb') ) 14 : ( LIBS => '-lusb', ) 15 ), 16 ($ENV{LIBUSB_INCDIR} ? ( INC => "-I\"$ENV{LIBUSB_INCDIR}\ +"" ) : () ), 17 NAME => 'Device::USB', 18 VERSION => '0.35', 19 CCFLAGS => "$Config{ccflags} $ENV{CFLAGS} $ENV{CPPFLAGS}" +, 20 LDDLFLAGS => "$Config{lddlflags} $ENV{LDFLAGS}", 21 ); 22 print "CCFLAGS =>|$Config{ccflags}|$ENV{CFLAGS}|$ENV{CPPFLAGS}|\n +"; 23 print "LDDLFLAGS =>|$Config{lddlflags}|$ENV{LDFLAGS}|\n";

        this gave the following errors and output:

        root@gk-kubuntu-dev:~/dav/Nevada# perl kk.pl Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 10. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 10. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 10. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 22. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 22. CCFLAGS =>|-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno- +strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FIL +E_OFFSET_BITS=64||| Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 23. LDDLFLAGS =>|-shared -L/usr/local/lib -fstack-protector||

        This indicates $ENV{CFLAGS},$ENV{CPPFLAGS} and $ENV{LDFLAGS} are uninitialized. I'll need to determine what they are supposed to be. There is not much useful I can find. I wonder why the package did not set the variables it needed. Could it be the botched cpan install? Frankly I have no idea what those things should be. I will try defining them as '' or some value

        9 $ENV{CFLAGS} = 'A'; 10 $ENV{CPPFLAGS} = 'B'; 11 $ENV{LDFLAGS} = 'C'; 12 $ENV{LIBUSB_LIBDIR} = 'D'; 13 $ENV{WINDDK} = 'E'; 14 $ENV{LIBUSB__INCDIR} = 'F'; 15 use Inline ( 16 C => "DATA", 17 ($ENV{LIBUSB_LIBDIR} 18 ? ( LIBS => "-L\"$ENV{LIBUSB_LIBDIR}\" " . 19 ($^O eq 'MSWin32' ? ' -llibusb -L\"$ENV{W +INDDK}\\lib\\crt\\i386\" -lmsvcrt ' : '-lusb') ) 20 : ( LIBS => '-lusb', ) 21 ), 22 ($ENV{LIBUSB_INCDIR} ? ( INC => "-I\"$ENV{LIBUSB_INCDIR}\ +"" ) : () ), 23 NAME => 'Device::USB', 24 VERSION => '0.35', 25 CCFLAGS => "$Config{ccflags} $ENV{CFLAGS} $ENV{CPPFLAGS}" +, 26 LDDLFLAGS => "$Config{lddlflags} $ENV{LDFLAGS}", 27 ); 28 print "CCFLAGS =>|$Config{ccflags}|$ENV{CFLAGS}|$ENV{CPPFLAGS}|\n +"; 29 print "LDDLFLAGS =>|$Config{lddlflags}|$ENV{LDFLAGS}|\n";

        gives the following errors and output

        Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 16. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 16. Use of uninitialized value in concatenation (.) or string at /usr/lib/ +perl5/Device/USB.pm line 16. CCFLAGS =>|-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno- +strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FIL +E_OFFSET_BITS=64|A|B| LDDLFLAGS =>|-shared -L/usr/local/lib -fstack-protector|C|

        from what I can tell, every ENV variable is assigned something, Why are there still 3 concatenation errors?