[freetds] gethostbyname_r fails if statically linked

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Fri Mar 10 03:03:02 EST 2006


> 
> Has anyone one ever tried to statically link a program that 
> accesses both MySQL and unixODBC.   The reason I ask is that 
> the gethostbyname_r function acts strange of seg faults
> when my program is linked statically, dynamically it works 

Mmm.... how did you link freetds statically?
gethostname require some additional libraries (like nssswitch) to work,
did you have these libraries and configurations (are you running a
chrooted environment?)

> find, as do the isql and iusql programs.   The call to 
> gethostbyname_r in question is deep inside freetds in the 
> threadsafe.c source.  If my program is statically linked it 
> always returns NULL, and h_errno is never changed.  All 

gethostbyname_r is a system function (libc) if it return NULL FreeTDS
fail connection. However it should not seg fault... where does the
program seg fault?

> programs and code are compiled on the system in question 
> freetds, unixODBC, and my program.  My thinking is that 
> somehow the dlopened tds library is somehow accessing a copy 
> of gethostbyname_r that is statically linked into my program, 
> instead of one that is dynamically available.   Maybe somehow 
> there are too different libraries with the same function, and 
> my program gets a different one (maybe because of MySQL) when 
> linked statically.
> 

dlopened?? Are you mixing static and dynamic linking together??

freddy77



More information about the FreeTDS mailing list