Solaris 2.7 run time linking problem

Solaris 2.7 run time linking problem

am 02.02.2003 05:48:46 von Steve Sapovits

I posted this to PerlMonks and an earlier version to the DBI mailing
list. Any ideas?
----

I have a problem on Solaris 2.7 that's stumped me. I have rather
large Perl installations on 2 Solaris boxes: 1 Solaris 2.7; the
other 2.8. Each has over 250 CPAN modules loaded, as well as a
number of prerequisite libraries. Both use GNU (gcc) build
environments. Both appear to be using the same versions of all
software.

Friday, I went to install DBD::mysql. I already had this loaded
on the 2.8 box. I built it there against a recent Solaris binary
download of mysql. No problems ... all tests pass, etc. On the
2.7 box I'm stuck. Everything builds okay but all the tests yield
errors like this:

t/00base............install_driver(mysql) failed: Can't load 'blib/arch/auto/DBD
/mysql/mysql.so' for module DBD::mysql: ld.so.1: /usr/local/bin/perl: fatal:
relocation error: file blib/arch/auto/DBD/mysql/mysql.so: symbol
mysql_real_escape_string: referenced symbol not found at
/usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 206.
at (eval 1) line 3
Compilation failed in require at (eval 1) line 3.
Perhaps a required shared library or dll isn't installed where expected

Basically it looks like at run-time the mysql client library is missing
in action. I've been building freeware for some time so I checked all
the obvious things: missing shared libraries, unset LD_LIBRARY_PATH,
etc. This one is not obvious. Plus all the other modules I've built
(including 2 other DBD:: modules) have not hit this problem. My basic
conclusion is that the linker is happy it can find everything at build
time but the run time linker is not so happy. I added debug to DynaLoader
nd @dl_library_path is set correctly. Runnning the Solaris ldd command
against the created mysql.so shows all the libraries it thinks it wants
are there, however the mysql client lib is not in that list on either
machine. Instead, the build on both machines (good and bad) shows this
sort of set-up to find the mysql client lib:

Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_RUN_PATH="/usr/local/lib/mysql:/usr/lib" /usr/local/bin/perl myld g
+cc -G -L/
usr/local/lib dbdimp.o mysql.o -o blib/arch/auto/DBD/mysql/mysql.so
+ -L/usr/lo
cal/lib/mysql -lmysqlclient -lcrypt -lgen -lsocket -lnsl -lm
chmod 755 blib/arch/auto/DBD/mysql/mysql.so
cp mysql.bs blib/arch/auto/DBD/mysql/mysql.bs
chmod 644 blib/arch/auto/DBD/mysql/mysql.bs
Manifying blib/man3/DBD::mysql.3
Manifying blib/man3/DBD::mysql::INSTALL.3
Manifying blib/man3/Bundle::DBD::mysql.3
Manifying blib/man3/Mysql.3

I'm not exactly sure what that means ... I assume it's setting things
up so DynaLoader finds the libs at run time. The standard mysql
downloads only provide a static library so I'm not sure how that works
but it does on the 2.8 box -- there are no mysql .so files to be found
there and everything is happy.

I've tried using source builds of mysql -- which do have the .so shared
libs; tried about a half dozen older versions of DBD::mysql; rebuilt
everything including Perl with a new gcc to make sure I matched the other
machine, etc. I've found numerous Google references to similar problems
which all point to the things I mention here. Anyone have any other ideas
(besides a bullet to the head)? Both boxes are running 5.6.1 Perl.

Two things I started looking into that I'm not all that familiar with: gcc
has spec files that provide linker defaults; Solaris has a crle command that
controls linker options. Interestingly enough, that command is on both the
2.7 and 2.8 box but only the 2.8 box has a man page entry and the
directory/file structure that man page describes.

I also posted to the DBI mailing list (no response).

--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com



------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2014@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 21:48:09 von Jochen Wiedmann

Quoting Steve Sapovits :

> relocation error: file blib/arch/auto/DBD/mysql/mysql.so: symbol
> mysql_real_escape_string: referenced symbol not found at

This could indicate a problem with the version of MySQL you
are using: The current driver requires a version with the
"mysql_real_escape_string" function (do not remember which
version introduced that).

If I may be right, try installing a new version (the client
libraries are sufficient and you may use the configure
option --without-server).


Good luck,

Jochen

------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2015@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 21:48:09 von Jochen Wiedmann

Quoting Steve Sapovits :

> relocation error: file blib/arch/auto/DBD/mysql/mysql.so: symbol
> mysql_real_escape_string: referenced symbol not found at

This could indicate a problem with the version of MySQL you
are using: The current driver requires a version with the
"mysql_real_escape_string" function (do not remember which
version introduced that).

If I may be right, try installing a new version (the client
libraries are sufficient and you may use the configure
option --without-server).


Good luck,

Jochen

------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2015@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 22:04:53 von Steve Sapovits

Jochen Wiedmann wrote:

> This could indicate a problem with the version of MySQL you
> are using: The current driver requires a version with the
> "mysql_real_escape_string" function (do not remember which
> version introduced that).
>
> If I may be right, try installing a new version (the client
> libraries are sufficient and you may use the configure
> option --without-server).

I checked and that function is in all versions I tried.
Plus, I get other unresolved references in other tests.
Basically, it doesn't see the MySQL client libs at all,
no matter how I try building/linking the DBD::mysql piece.

I suspect it's an issue of Solaris 5.7 not having the
right link options to pull all the correct objects into
the mysql.so shared object DBD::mysql creates at build
time. But I've tried about everything I know of there
and no luck ...


--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com
Work: 610-491-7087
Mobile: 610-574-7706
Pager: 877-239-4017


------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2016@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 22:04:53 von Steve Sapovits

Jochen Wiedmann wrote:

> This could indicate a problem with the version of MySQL you
> are using: The current driver requires a version with the
> "mysql_real_escape_string" function (do not remember which
> version introduced that).
>
> If I may be right, try installing a new version (the client
> libraries are sufficient and you may use the configure
> option --without-server).

I checked and that function is in all versions I tried.
Plus, I get other unresolved references in other tests.
Basically, it doesn't see the MySQL client libs at all,
no matter how I try building/linking the DBD::mysql piece.

I suspect it's an issue of Solaris 5.7 not having the
right link options to pull all the correct objects into
the mysql.so shared object DBD::mysql creates at build
time. But I've tried about everything I know of there
and no luck ...


--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com
Work: 610-491-7087
Mobile: 610-574-7706
Pager: 877-239-4017


------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2016@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 22:12:08 von Jochen Wiedmann

Quoting Steve Sapovits :

> I suspect it's an issue of Solaris 5.7 not having the
> right link options to pull all the correct objects into
> the mysql.so shared object DBD::mysql creates at build
> time. But I've tried about everything I know of there
> and no luck ...

Try using a static library.

------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2017@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 22:12:08 von Jochen Wiedmann

Quoting Steve Sapovits :

> I suspect it's an issue of Solaris 5.7 not having the
> right link options to pull all the correct objects into
> the mysql.so shared object DBD::mysql creates at build
> time. But I've tried about everything I know of there
> and no luck ...

Try using a static library.

------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2017@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 22:15:51 von Steve Sapovits

Jochen Wiedmann wrote:

> Try using a static library.

I started down this path a bit. But I think to do that I have
to build the DBD::mysql piece into the Perl binary itself. Not
something I really want to do -- I need to be able to easily
upgrade, etc. Very frustrating since it works out of the box
on Solaris 2.8 systems and since other DynaLoader loaded pieces
for other Perl modules work okay. I've been comparing the makes
and have not found any obvious differences.

--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com


------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2018@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 22:15:51 von Steve Sapovits

Jochen Wiedmann wrote:

> Try using a static library.

I started down this path a bit. But I think to do that I have
to build the DBD::mysql piece into the Perl binary itself. Not
something I really want to do -- I need to be able to easily
upgrade, etc. Very frustrating since it works out of the box
on Solaris 2.8 systems and since other DynaLoader loaded pieces
for other Perl modules work okay. I've been comparing the makes
and have not found any obvious differences.

--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com


------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2018@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 23:44:01 von Jochen Wiedmann

Quoting Steve Sapovits :

> I started down this path a bit. But I think to do that I have
> to build the DBD::mysql piece into the Perl binary itself. Not
> something I really want to do -- I need to be able to easily
> upgrade, etc. Very frustrating since it works out of the box
> on Solaris 2.8 systems and since other DynaLoader loaded pieces
> for other Perl modules work okay. I've been comparing the makes
> and have not found any obvious differences.

There is absolutely no reason to build a statically linked
Perl. The driver was even developed on Solaris in the
beginning.


Jochen

------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2019@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 02.02.2003 23:44:01 von Jochen Wiedmann

Quoting Steve Sapovits :

> I started down this path a bit. But I think to do that I have
> to build the DBD::mysql piece into the Perl binary itself. Not
> something I really want to do -- I need to be able to easily
> upgrade, etc. Very frustrating since it works out of the box
> on Solaris 2.8 systems and since other DynaLoader loaded pieces
> for other Perl modules work okay. I've been comparing the makes
> and have not found any obvious differences.

There is absolutely no reason to build a statically linked
Perl. The driver was even developed on Solaris in the
beginning.


Jochen

------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2019@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 03.02.2003 04:06:31 von Steve Sapovits

Jochen Wiedmann wrote:

> There is absolutely no reason to build a statically linked
> Perl. The driver was even developed on Solaris in the
> beginning.

Okay, so I obviously am missing something then. Any pointers
on how to get started down the static path? I looked for
'static' and all I found was some old commented out code in
the make ... nothing in the docs for example.

I'm talking about the DBD::mysql piece. I'm missing how that
can be static and then become part of a Perl program ... I
believe all other Perl modules I use that have a C code piece
build that piece as a shared library so it can be loaded
dynamically. Maybe I'm wrong about that though.

I am using a static mysqlclient.a -- I've tried that and the
shared version I built from source. The make assumes a static
mysqlclient.a by default and that's where most of my attempts
have been directed.

--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com



------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2020@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 03.02.2003 04:06:31 von Steve Sapovits

Jochen Wiedmann wrote:

> There is absolutely no reason to build a statically linked
> Perl. The driver was even developed on Solaris in the
> beginning.

Okay, so I obviously am missing something then. Any pointers
on how to get started down the static path? I looked for
'static' and all I found was some old commented out code in
the make ... nothing in the docs for example.

I'm talking about the DBD::mysql piece. I'm missing how that
can be static and then become part of a Perl program ... I
believe all other Perl modules I use that have a C code piece
build that piece as a shared library so it can be loaded
dynamically. Maybe I'm wrong about that though.

I am using a static mysqlclient.a -- I've tried that and the
shared version I built from source. The make assumes a static
mysqlclient.a by default and that's where most of my attempts
have been directed.

--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com



------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2020@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 03.02.2003 05:05:51 von Steve Sapovits

I wrote:

> Okay, so I obviously am missing something then. Any pointers
> on how to get started down the static path? I looked for
> 'static' and all I found was some old commented out code in
> the make ... nothing in the docs for example.

I got it. I was not approaching 'static' the right way.

Following some notes I found on the web, I had been modifying
mysql_config. The problem is, that was putting any changes in
as link options. What I needed to do was add the static
libmysqlclient.a library as one of the mysql.so objects. That
is, specify the .a so its objects are extracted and used to build
mysql.so, instead of making it a run time link dependency. I'm
not sure how Solaris 2.8 gets away with it the other way ...
there is no shared libmysqlclient.so there and it somehow does
use the static .a at run time. I think it may be a subtle linker
difference, where 2.8 sees that there's only a .a and pulls the
objects in regardless of where the -lmysqlclient option is found
on the command line. When I used 'nm' against the two mysql.so
libs created (2.8 and 2.7) it became obvious there was a linker
difference. On 2.7 the mysql functions were all UNDEF; not so
on 2.8. Same linker line on each.

So line 106 of the generated Makefile now looks like this:

OBJECT = $(O_FILES) /usr/local/mysql/lib/libmysqlclient.a

where it was:

OBJECT = $(O_FILES)

I'm not seeing how to incorporate this into Makefile.PL or if
there's something there I missed that generates this.

I did, by the way, find working static options to build mysql.a
instead of mysql.so. But the tests for those tried (as I thought)
to build a static perl executable linking that in, which failed.
That's not a path I wanted to go down anyway.

Maybe someone can figure out how to incorporate this or maybe
it's not worth it ... I'm okay knowing I can fix it. Moving
forward, my need to run on Solaris 2.7 should go away anyway.

Thanks for all feedback.

--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com



------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2021@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 03.02.2003 05:05:51 von Steve Sapovits

I wrote:

> Okay, so I obviously am missing something then. Any pointers
> on how to get started down the static path? I looked for
> 'static' and all I found was some old commented out code in
> the make ... nothing in the docs for example.

I got it. I was not approaching 'static' the right way.

Following some notes I found on the web, I had been modifying
mysql_config. The problem is, that was putting any changes in
as link options. What I needed to do was add the static
libmysqlclient.a library as one of the mysql.so objects. That
is, specify the .a so its objects are extracted and used to build
mysql.so, instead of making it a run time link dependency. I'm
not sure how Solaris 2.8 gets away with it the other way ...
there is no shared libmysqlclient.so there and it somehow does
use the static .a at run time. I think it may be a subtle linker
difference, where 2.8 sees that there's only a .a and pulls the
objects in regardless of where the -lmysqlclient option is found
on the command line. When I used 'nm' against the two mysql.so
libs created (2.8 and 2.7) it became obvious there was a linker
difference. On 2.7 the mysql functions were all UNDEF; not so
on 2.8. Same linker line on each.

So line 106 of the generated Makefile now looks like this:

OBJECT = $(O_FILES) /usr/local/mysql/lib/libmysqlclient.a

where it was:

OBJECT = $(O_FILES)

I'm not seeing how to incorporate this into Makefile.PL or if
there's something there I missed that generates this.

I did, by the way, find working static options to build mysql.a
instead of mysql.so. But the tests for those tried (as I thought)
to build a static perl executable linking that in, which failed.
That's not a path I wanted to go down anyway.

Maybe someone can figure out how to incorporate this or maybe
it's not worth it ... I'm okay knowing I can fix it. Moving
forward, my need to run on Solaris 2.7 should go away anyway.

Thanks for all feedback.

--
Steve Sapovits GSI Commerce, Inc. http://www.gsicommerce.com
Email: sapovitss@gsicommerce.com



------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2021@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 03.02.2003 07:30:05 von Jochen Wiedmann

Zitiere Steve Sapovits :

> I'm not seeing how to incorporate this into Makefile.PL or if
> there's something there I missed that generates this.

That's not my intention. Specifying options like the name
of the static library is exactly what mysql_config (or
the --libs options) are good for.

However, for the future, it might be helpful, if you could
publish a diff between your original mysql_config and the
current.


Regards,

Jochen

------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2022@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.

Re: Solaris 2.7 run time linking problem

am 03.02.2003 07:30:05 von Jochen Wiedmann

Zitiere Steve Sapovits :

> I'm not seeing how to incorporate this into Makefile.PL or if
> there's something there I missed that generates this.

That's not my intention. Specifying options like the name
of the static library is exactly what mysql_config (or
the --libs options) are good for.

However, for the future, it might be helpful, if you could
publish a diff between your original mysql_config and the
current.


Regards,

Jochen

------------------------------------------------------------ ---------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail msql-mysql-modules-thread2022@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail msql-mysql-modules-unsubscribe@lists.mysql.com instead.