LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2009, 07:43 AM   #1
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Glibc warning concerning use of getaddrinfo() in static library


I am using a static library in which one of the modules employs the use of getaddrinfo().

When I link the library with an application, I get the following warning:
Code:
libSocket++.a(SocketUtility.o): In function `socketpp::FillAddress(int, char const*, unsigned short, sockaddr_in*)':
/home/whitneyd/Redirector/SocketLibrary-1.1.6/socket++/SocketUtility.cpp:114: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Is there any way to prevent this warning from occurring? I've tried linking the static version of the C library (/usr/lib/libc.a, by specifying "-static -lc" as one of my linker options, but that did not work.

Here is the Makefile I am using:
Code:
APP      = udp_redir

SRCS     = udp_redir.cpp
OBJS     = $(SRCS:.cpp=.o)

CXXFLAGS = -Wall -pedantic -ansi
INCLUDES = -I./include
LDFLAGS  = -L./lib
LIBS     = -static -lSocket++ -static -lc 

all: SocketLibrary $(APP)

$(APP): $(OBJS)
        @echo Linking $@
        @$(CXX) $^ $(LDFLAGS) $(LIBS) -o $@

.cpp.o:
        @echo Compiling $<
        @$(CXX) $(CXXFLAGS) $(INCLUDES) -c $<

clean:
        @make -s -C SocketLibrary* DEST=.. clean
        $(RM) $(OBJS)

distclean: clean
        @make -s -C SocketLibrary* DEST=.. distclean
        @$(RM) -r SocketLibrary*
        @$(RM) ./.getLib
        @$(RM) -r include lib
        $(RM) $(APP)

SocketLibrary: .getLib
        @echo Building SocketLibrary
        @make -s -C SocketLibrary* DEST=.. install

.getLib:
        @$(RM) -r SocketLibrary*
        @wget http://softhouseproductions.com/SocketLibrary.tgz >& /dev/null
        @tar xzf SocketLibrary.tgz
        @$(RM) SocketLibrary.tgz
        @touch $@
 
Old 06-19-2009, 01:28 PM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I think you posted about this elsewhere... the answer is that some glibc functions simply cannot be linked statically and still work. IF you want to use those functions you need to supply or depend on the shared libraries being present at runtime, or use some other libc to link against -I'm not sure, though, if newlib or uClibc will let you do this either.
 
Old 06-19-2009, 01:38 PM   #3
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Original Poster
Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
If I had posted this topic before, I must have been inebriated, because I do not recall doing such.

Anyhow, I understand the cause of the warning, and your answer seems to confirm that. I was just wondering if there was a way to remove the warning, perhaps by statically linking the C library into the app. But it does not appear as if this is possible, nor when I think about it, be very practical.

Fortunately for me, I only use the SocketLibrary on Linux distros, so portability to other OSes is not a concern.

Thanxs for your reply.
 
Old 06-19-2009, 01:43 PM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Sorry, I must be mistaken -but I just saw a posting yesterday about the same fucntion plus a couple of others.
If you are statically linking, it would be worth checking out newlib and/or uclibc as using them will provide much smaller binaries. uClibc, especially, claims to be better for staically-linking. newlib is less feature-full.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating static library that includes another static library kskkumar Programming 2 10-22-2007 10:51 AM
Making a static library from a given shared library vro Programming 1 07-27-2007 04:07 PM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
Replacing glibc using linuxthreads for glibc using nptl (native positx thread library CestusGW Linux From Scratch 4 01-20-2005 07:26 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration