Bug #7974 symbol not found: strndup (./libmyodbc3_r.so)
Submitted: 17 Jan 2005 22:26 Modified: 15 Mar 2007 20:35
Reporter: Steven Xie Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:3.51.12 OS:Solaris (Solaris 2.8)
Assigned to: Kent Boortz CPU Architecture:Any

[17 Jan 2005 22:26] Steven Xie
Description:
 ldd -r libmyodbc3_r.so
        libmysqlclient_r.so.14 =>        /mpathix/mysql-4.18a/lib/mysql/libmysqlclient_r.so.14
        librt.so.1 =>    /usr/lib/librt.so.1
        libcrypt_i.so.1 =>       /usr/lib/libcrypt_i.so.1
        libgen.so.1 =>   /usr/lib/libgen.so.1
        libsocket.so.1 =>        /usr/lib/libsocket.so.1
        libnsl.so.1 =>   /usr/lib/libnsl.so.1
        libm.so.1 =>     /usr/lib/libm.so.1
        libpthread.so.1 =>       /usr/lib/libpthread.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        libthread.so.1 =>        /usr/lib/libthread.so.1
        libz.so.1 =>     /usr/lib/libz.so.1
        libodbcinst.so.1 =>      /mpathix/unixODBC-2.2.10/lib/libodbcinst.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libgcc_s.so.1 =>         /mpathix/gcc-3.3.2/lib/libgcc_s.so.1
        libaio.so.1 =>   /usr/lib/libaio.so.1
        libmp.so.2 =>    /usr/lib/libmp.so.2
        symbol not found: strndup               (./libmyodbc3_r.so)

How to repeat:
build on  solaris 2.8 
link error.

Suggested fix:
#if defined(SOLARIS)||defined(__APPLE__) || defined(WIN32) || defined(_FORTEC_)
char *strndup( const char *s, size_t n )
{
    size_t nAvail;
    char *p;
                                                                                                                                                             
    if ( !s )
        return 0;
                                                                                                                                                             
    nAvail = min( strlen(s) + 1, n + 1 );
    p      = malloc( nAvail );
    memcpy( p, s, nAvail );
    p[nAvail - 1] = '\0';
                                                                                                                                                             
/*
printf( "[PAH][%s][%d] nAvail=%d p=(%s)\n", __FILE__, __LINE__, nAvail, p );
*/
    return p;
}
#endif
[21 Oct 2005 14:53] Mark Matthews
We build on Solaris-2.8, and 3.51.12 compiles there. Please either use our binary, or pull the sources for 3.51.12 and compile to see if this issue still exists.
[22 Nov 2005 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[23 Jun 2006 11:26] Sveta Smirnova
We have duplicate: http://bugs.mysql.com/bug.php?id=19549
And I can repeat it on my Solaris 10:

bash-3.00# uname -a
SunOS RiRy 5.10 Generic i86pc i386 i86pc Solaris
bash-3.00# cc -V
cc: Sun C 5.8 2005/10/13
[23 Jun 2006 19:53] Sveta Smirnova
Forgot to add: I can repeat it using mysql-connector-odbc-3.51.12
[15 Mar 2007 20:35] Kent Boortz
Thank you for your bug report. This issue has been fixed in
the latest released version of that product, which you can
download at

  http://www.mysql.com/downloads/