Subject: Re: ld confusion
To: James K.Lowden <jklowden@speakeasy.org>
From: Frederick Bruckman <fredb@immanent.net>
List: netbsd-help
Date: 05/23/2002 21:06:59
On Thu, 23 May 2002, James K.Lowden wrote:
> I'm trying to install perl's DBD::mysql driver (database/p5-DBD-mysql) on
> my 1.4.2 generic box. It won't build with the patch, and it won't run
> without it. I'm not sure if I have a problem with ld, perl, or the perl
> script, and I'd be very glad for any perls of wisdom.
>
> patch/patch-aa looks like this:
>
> + } elsif ($Config::Config{'osname'} eq 'netbsd') {
> + # We need to link with -Wl,-R if we're on NetBSD
> + $linkwith = "-Wl,-R$libdir";
>
> I don't understand and can't find a -W anything for ld in info.
"-Wl" is a "gcc" option, which passes the following argument to the
linker. Since you're linking directly with "ld", you could just change
that to "-R$libdir", then run "make distinfo", to regenerate the
patch's checksum. The normal thing, nowadays, is to link always with
"gcc"; making the package do so on NetBSD-a.out would be the real fix.
> The build breaks with the patch:
>
> rm -f ../blib/arch/auto/DBD/mysql/mysql.so
> LD_RUN_PATH="/usr/pkg/lib/mysql:/usr/lib" ld -Bshareable -R/usr/pkg/lib
> -L/usr/pkg/lib dbdimp.o mysql.o -L/usr/pkg/lib/mysql
> -Wl,-R/usr/pkg/lib/mysql -o ../blib/arch/auto/DBD/mysql/mysql.so
> -L/usr/pkg/lib/perl5/5.6.1/i386-netbsd/CORE
> -R/usr/pkg/lib/perl5/5.6.1/i386-netbsd/CORE -lperl -L/usr/pkg/lib/mysql
> -lmysqlclient -lm -lz
> ld: invalid command option `-Wl,-R/usr/pkg/lib/mysql'
>
> Thinking the patch may mumble n/a for 1.4.2, I renamed it, make clean;
> make install. All goes well. Then, running the script (not mine; I'm
> seeing if I can get LXR to run on my webserver), perl complains:
>
> /usr/libexec/ld.so: perl: libmysqlclient.so.10.0: No such file or
> directory
>
> Even though that looks like a lie to me:
>
> # ls -l /usr/pkg/lib/*my*
> total 546
> -rw-r--r-- 1 root wheel 128970 May 23 20:23 libmysqlclient.a
> -rwxr-xr-x 1 root wheel 777 May 23 20:23 libmysqlclient.la
> -rwxr-xr-x 1 root wheel 128259 May 23 20:23 libmysqlclient.so.10.0
That's kind of tricky, the way you presented that. We're actually
looking at the contents of "/usr/pkg/lib/mysql". In order to have the
run-time linker find the file there, it has to be told to look there.
There are other ways to do that, but the best way is to pass the "-R"
argument to the NetBSD-a.out linker.
> I tried running "ldconfig" all by itself to rescan or whatever it does, no
> joy.
That could only work if the path were in "/etc/ld.so.conf", or if you
passed the "-m" argument, but don't do either -- best to use "-R".
Frederick