public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* getaddrinfo is not statically compiled
@ 2010-04-28 11:15 bassis
  2010-04-28 11:26 ` Andrew Haley
  0 siblings, 1 reply; 10+ messages in thread
From: bassis @ 2010-04-28 11:15 UTC (permalink / raw)
  To: gcc-help


I have included the header netdb.h, where getaddrinfo is included, but gcc
issues this warning:

warning: Using 'getaddrinfo' in statically linked applications requires at
runtime the shared libraries from the glibc version used for linking

gcc -m32 -static -s -O2 -std=c99 -D_POSIX_C_SOURCE=200112L myprogram.c

How can I statically compile whatever file is missing ?

-- 
View this message in context: http://old.nabble.com/getaddrinfo-is-not-statically-compiled-tp28385701p28385701.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
  2010-04-28 11:15 getaddrinfo is not statically compiled bassis
@ 2010-04-28 11:26 ` Andrew Haley
  2010-04-28 14:52   ` bassis
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2010-04-28 11:26 UTC (permalink / raw)
  To: gcc-help

On 04/28/2010 08:35 AM, bassis wrote:
> 
> I have included the header netdb.h, where getaddrinfo is included, but gcc
> issues this warning:
> 
> warning: Using 'getaddrinfo' in statically linked applications requires at
> runtime the shared libraries from the glibc version used for linking
> 
> gcc -m32 -static -s -O2 -std=c99 -D_POSIX_C_SOURCE=200112L myprogram.c
> 
> How can I statically compile whatever file is missing ?

You can't.  The resolver library needs to load components dynamically,
and the mechanism used to do that requires that they must come from
the same glibc version as the code linked into the application.

You can either

a.  Package these libraries with your app, or
b.  Don't statically link with libc.

b. is far the best option, even if you statically link everything else.

Andrew.

http://people.redhat.com/drepper/no_static_linking.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
  2010-04-28 11:26 ` Andrew Haley
@ 2010-04-28 14:52   ` bassis
  2010-04-28 16:24     ` Andrew Haley
  2010-04-28 17:07     ` John (Eljay) Love-Jensen
  0 siblings, 2 replies; 10+ messages in thread
From: bassis @ 2010-04-28 14:52 UTC (permalink / raw)
  To: gcc-help



Andrew Haley wrote:
> 
> You can't.  The resolver library needs to load components dynamically,
> and the mechanism used to do that requires that they must come from
> the same glibc version as the code linked into the application.
> 
> You can either
> 
> a.  Package these libraries with your app, or
> b.  Don't statically link with libc.
> 
> b. is far the best option, even if you statically link everything else.
> 
> Andrew.
> 
> http://people.redhat.com/drepper/no_static_linking.html
> 
> 
Ok, so statically is not possible so I'm trying to do it shared. I want to
provide the needed shared libraries rather than use the target system libs
to avoid version differences:

According to ldd, my program needs these libs:
linux-gate.so.1 => (0xf7f47000) (made by kernel)
libc.so.6 => /lib32/libc.so.6 (0xf7ddf000) (points to libc-2.7.so)
/lib/ld-linux.so.2 (0xf7f48000) (points to ld-2.7.so)

I have successfully linked ld-2.7.so by compiling like this:

gcc -std=c99 -D_POSIX_C_SOURCE=200112L -O2 -m32 -s
-Wl,-dynamic-linker,ld-2.7.so myprogram.c

But I have not managed to successfuly link libc-2.7.so. How can I do that ?
-- 
View this message in context: http://old.nabble.com/getaddrinfo-is-not-statically-compiled-tp28385701p28387972.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
  2010-04-28 14:52   ` bassis
@ 2010-04-28 16:24     ` Andrew Haley
  2010-04-29 16:19       ` bassis
  2010-04-28 17:07     ` John (Eljay) Love-Jensen
  1 sibling, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2010-04-28 16:24 UTC (permalink / raw)
  To: bassis; +Cc: gcc-help

On 04/28/2010 02:57 PM, bassis wrote:
> 
> 
> Andrew Haley wrote:
>>
>> You can't.  The resolver library needs to load components dynamically,
>> and the mechanism used to do that requires that they must come from
>> the same glibc version as the code linked into the application.
>>
>> You can either
>>
>> a.  Package these libraries with your app, or
>> b.  Don't statically link with libc.
>>
>> b. is far the best option, even if you statically link everything else.
>>
>> Andrew.
>>
>> http://people.redhat.com/drepper/no_static_linking.html
>>
>>
> Ok, so statically is not possible so I'm trying to do it shared. I want to
> provide the needed shared libraries rather than use the target system libs
> to avoid version differences:

Which version differences do you want to avoid?

> According to ldd, my program needs these libs:
> linux-gate.so.1 => (0xf7f47000) (made by kernel)
> libc.so.6 => /lib32/libc.so.6 (0xf7ddf000) (points to libc-2.7.so)
> /lib/ld-linux.so.2 (0xf7f48000) (points to ld-2.7.so)

> I have successfully linked ld-2.7.so by compiling like this:
> 
> gcc -std=c99 -D_POSIX_C_SOURCE=200112L -O2 -m32 -s
> -Wl,-dynamic-linker,ld-2.7.so myprogram.c
> 
> But I have not managed to successfuly link libc-2.7.so. How can I do that ?

gcc liks with libc by default.  I don't know what you're asking.

If you really need getaddrinfo you can always shell out to an external
program.  I'm not sure that's a good idea, though.

Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
  2010-04-28 14:52   ` bassis
  2010-04-28 16:24     ` Andrew Haley
@ 2010-04-28 17:07     ` John (Eljay) Love-Jensen
  2010-04-29  8:18       ` bassis
  1 sibling, 1 reply; 10+ messages in thread
From: John (Eljay) Love-Jensen @ 2010-04-28 17:07 UTC (permalink / raw)
  To: bassis, GCC-help

> Ok, so statically is not possible so I'm trying to do it shared.

Good good.

> I want to provide the needed shared libraries rather than use the target
system libs to avoid version differences:

Hmmm.  How can you provide the needed shared libraries rather than the
target system libs, since the shared libraries themselves are intimately
tied to the specific system version?

Wouldn't you need to provide a whole set of shared libraries, which are
system version (major.minor.patch version) specific?

And wouldn't that make your application limited to known versions at release
time, that you provided those system specific versions of those particular
system specific shared libraries?  (Hence, making your application tighly
system version locked.)

As I understand the usual approach is to compile on (or cross-compile to)
the oldest system version (using the target system libs) you support, and
rely on the library versioning facility to be future compatible.

Sincerely,
--Eljay

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
  2010-04-28 17:07     ` John (Eljay) Love-Jensen
@ 2010-04-29  8:18       ` bassis
  0 siblings, 0 replies; 10+ messages in thread
From: bassis @ 2010-04-29  8:18 UTC (permalink / raw)
  To: gcc-help



John (Eljay) Love-Jensen wrote:
> 
> Hmmm.  How can you provide the needed shared libraries rather than the
> target system libs, since the shared libraries themselves are intimately
> tied to the specific system version?
> 
> Wouldn't you need to provide a whole set of shared libraries, which are
> system version (major.minor.patch version) specific?
> 
> And wouldn't that make your application limited to known versions at
> release
> time, that you provided those system specific versions of those particular
> system specific shared libraries?  (Hence, making your application tighly
> system version locked.)
> 
> As I understand the usual approach is to compile on (or cross-compile to)
> the oldest system version (using the target system libs) you support, and
> rely on the library versioning facility to be future compatible.
> 
> Sincerely,
> --Eljay
> 
> 
> 
Not sure if I understand you. All I want is to run my program in CentOS but
my program in compiled in Debian. A much easier solution would be to simply
compile my program in CentOS but I do not have permission to do this. So, I
was thinking of making my program use the libc and ld files of Debian
instead of the ones provided by CentOS.

Is this not possible ? Is there another way of doing this ?
-- 
View this message in context: http://old.nabble.com/getaddrinfo-is-not-statically-compiled-tp28385701p28390861.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
  2010-04-28 16:24     ` Andrew Haley
@ 2010-04-29 16:19       ` bassis
  2010-04-29 17:17         ` Andrew Haley
  0 siblings, 1 reply; 10+ messages in thread
From: bassis @ 2010-04-29 16:19 UTC (permalink / raw)
  To: gcc-help




Andrew Haley wrote:
> 
> Which version differences do you want to avoid?
> 
> gcc liks with libc by default.  I don't know what you're asking.
> 
> If you really need getaddrinfo you can always shell out to an external
> program.  I'm not sure that's a good idea, though.
> 
> Andrew.
> 
> 
I want to avoid linux-distribution differences.

All I want is to run my program in CentOS but my program in compiled in
Debian. A much easier solution would be to simply compile my program in
CentOS but I do not have permission to do this. So, I was thinking of making
my program use the libc and ld files of Debian instead of the ones provided
by CentOS.

Is this not possible ? Is there another way of doing this ?
-- 
View this message in context: http://old.nabble.com/getaddrinfo-is-not-statically-compiled-tp28385701p28390912.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
  2010-04-29 16:19       ` bassis
@ 2010-04-29 17:17         ` Andrew Haley
  2010-04-29 19:38           ` bassis
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Haley @ 2010-04-29 17:17 UTC (permalink / raw)
  To: bassis; +Cc: gcc-help

On 04/28/2010 05:24 PM, bassis wrote:
> 
> 
> 
> Andrew Haley wrote:
>>
>> Which version differences do you want to avoid?
>>
>> gcc liks with libc by default.  I don't know what you're asking.
>>
>> If you really need getaddrinfo you can always shell out to an external
>> program.  I'm not sure that's a good idea, though.
>
> I want to avoid linux-distribution differences.
> 
> All I want is to run my program in CentOS but my program in compiled in
> Debian. A much easier solution would be to simply compile my program in
> CentOS but I do not have permission to do this. So, I was thinking of making
> my program use the libc and ld files of Debian instead of the ones provided
> by CentOS.
> 
> Is this not possible ? Is there another way of doing this ?

I tell you what I'd do: I'd either link against the CentOS libraries or
install a CentOS virtual machine and build in there.

Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
  2010-04-29 17:17         ` Andrew Haley
@ 2010-04-29 19:38           ` bassis
  0 siblings, 0 replies; 10+ messages in thread
From: bassis @ 2010-04-29 19:38 UTC (permalink / raw)
  To: gcc-help




Andrew Haley wrote:
> 
> I tell you what I'd do: I'd either link against the CentOS libraries or
> install a CentOS virtual machine and build in there.
> 
> Andrew.
> 
Unfortunately, using the CentOS libraries segfaults my program. The server
uses a 2004 CentOS but the oldest available at centos.org is 2007.
-- 
View this message in context: http://old.nabble.com/getaddrinfo-is-not-statically-compiled-tp28385701p28393542.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: getaddrinfo is not statically compiled
@ 2010-04-29 21:45 Andrew Haley
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Haley @ 2010-04-29 21:45 UTC (permalink / raw)
  To: gcc-help

On 04/28/2010 09:21 PM, bassis wrote:

> 
> Andrew Haley wrote:
>>
>> I tell you what I'd do: I'd either link against the CentOS libraries or
>> install a CentOS virtual machine and build in there.
>>
>> Andrew.
>>
> Unfortunately, using the CentOS libraries segfaults my program.  The server
> uses a 2004 CentOS but the oldest available at centos.org is 2007.

http://vault.centos.org/2.1/

Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-04-29  8:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-28 11:15 getaddrinfo is not statically compiled bassis
2010-04-28 11:26 ` Andrew Haley
2010-04-28 14:52   ` bassis
2010-04-28 16:24     ` Andrew Haley
2010-04-29 16:19       ` bassis
2010-04-29 17:17         ` Andrew Haley
2010-04-29 19:38           ` bassis
2010-04-28 17:07     ` John (Eljay) Love-Jensen
2010-04-29  8:18       ` bassis
2010-04-29 21:45 Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).