LinuxQuestions.org
Visit the LQ Articles and Editorials section
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, 08:43 AM   #1
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,523

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
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, 02:28 PM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
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, 02:38 PM   #3
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,523

Original Poster
Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
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, 02:43 PM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:51 AM
Making a static library from a given shared library vro Programming 1 07-27-2007 05:07 PM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-05-2007 12:11 AM
Replacing glibc using linuxthreads for glibc using nptl (native positx thread library CestusGW Linux From Scratch 4 01-20-2005 08:26 AM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 05:20 AM


All times are GMT -5. The time now is 08:04 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration