LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
 
LinkBack Search this Thread
Old 01-25-2012, 10:04 AM   #1
grob115
Member
 
Registered: Oct 2005
Posts: 386

Rep: Reputation: 32
Undefined reference to Apache ARR functions


Hi, need some expert advice on how to build a C++ project using the log4cxx lib. For some reason the liblog4cxx.a lib keeps on complaining that it can't find references to APR functions.

Can someone check the following to see if I may have missed anything? Thanks!!


Code:
apache@buildbox:/appvol/apache/lib/apr-1.4.5> ./configure --prefix=/appvol/apache/lib/apr-1.4.5/bin
apache@buildbox:/appvol/apache/lib/apr-1.4.5> make
apache@buildbox:/appvol/apache/lib/apr-1.4.5> make install

apache@buildbox:/appvol/apache/lib/apr-util-1.4.1> ./configure --prefix=/appvol/apache/lib/apr-util-1.4.1/bin
apache@buildbox:/appvol/apache/lib/apr-util-1.4.1> make
apache@buildbox:/appvol/apache/lib/apr-util-1.4.1> make install
Build log4cxx
Code:
apache@buildbox:/appvol/apache/lib/apache-log4cxx-0.10.0> ./configure --with-apr=/appvol/apache/lib/apr-1.4.5/bin/bin/apr-1-config --with-apr-util=/appvol/apache/lib/apr-util-1.4.1/bin/bin/apu-1-config --prefix=/appvol/apache/lib/apache-log4cxx-0.10.0/bin
apache@buildbox:/appvol/apache/lib/apache-log4cxx-0.10.0> make
apache@buildbox:/appvol/apache/lib/apache-log4cxx-0.10.0> make install
Build process above have generated both .so and .a files. Am moing the .a file into a sub-directory so when I build my project I can use the static .a lib.
Code:
apache@buildbox:/appvol/apache/lib/apache-log4cxx-0.10.0> mkdir static
apache@buildbox:/appvol/apache/lib/apache-log4cxx-0.10.0> cp liblog4cxx.a ./static/.
Bulding my custom app "myapp" with log4cxx. Note for some reason it keeps on complaning about the APR functions not found.
Code:
g++ -g -o myapp *.o -L/appvol/apache/lib/apache-log4cxx-0.10.0/bin/lib/static -L/usr/local/lib64 -L/usr/lib64 -llog4cxx -lm -ldl -lpthread -lrt
/appvol/apache/lib/apache-log4cxx-0.10.0/bin/lib/static/liblog4cxx.a(file.o): In function `log4cxx::File::getPath(log4cxx::helpers::Pool&) const':
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/file.cpp:121: undefined reference to `apr_filepath_encoding'
/appvol/apache/lib/apache-log4cxx-0.10.0/bin/lib/static/liblog4cxx.a(file.o): In function `log4cxx::File::mkdirs(log4cxx::helpers::Pool&) const':
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/file.cpp:238: undefined reference to `apr_dir_make_recursive'
/appvol/apache/lib/apache-log4cxx-0.10.0/bin/lib/static/liblog4cxx.a(file.o): In function `log4cxx::File::lastModified(log4cxx::helpers::Pool&) const':
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/file.cpp:182: undefined reference to `apr_stat'
.......................
/appvol/apache/lib/apache-log4cxx-0.10.0/bin/lib/static/liblog4cxx.a(socket.o): In function `Socket':
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:36: undefined reference to `apr_socket_create'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:47: undefined reference to `apr_sockaddr_info_get'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:53: undefined reference to `apr_socket_connect'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:62: undefined reference to `apr_socket_addr_get'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:71: undefined reference to `apr_sockaddr_ip_get'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:62: undefined reference to `apr_socket_addr_get'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:71: undefined reference to `apr_sockaddr_ip_get'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:36: undefined reference to `apr_socket_create'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:47: undefined reference to `apr_sockaddr_info_get'
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/socket.cpp:53: undefined reference to `apr_socket_connect'
/appvol/apache/lib/apache-log4cxx-0.10.0/bin/lib/static/liblog4cxx.a(strftimedateformat.o): In function `log4cxx::helpers::StrftimeDateFormat::format(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, long long, log4cxx::helpers::Pool&) const':
/appvol/apache/lib/apache-log4cxx-0.10.0/src/main/cpp/strftimedateformat.cpp:44: undefined reference to `apr_strftime'
collect2: ld returned 1 exit status

Last edited by grob115; 01-25-2012 at 10:05 AM.
 
Old 01-25-2012, 10:29 AM   #2
NevemTeve
Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 270

Rep: Reputation: 91
I might be wrong, but if you want to resolve from libapr-1.so then you should use linker flag -lapr-1
(Or you could use libtool)
 
Old 01-26-2012, 10:04 AM   #3
grob115
Member
 
Registered: Oct 2005
Posts: 386

Original Poster
Rep: Reputation: 32
Hi, sorry am not following on why I need to resolve from "libapr-1.so". All I know is per the following link, In need to specify the "--with-apr" and "--with-apr-util" flags for "path to non-default location for APR" and "path to non-default location for APR-Util". However, the site isn't really clear to what exact path I need to specify. What I did notice is that the ./configure for log4cxx says I need to provide the same path I specified for the --prefix option when running ./configure for APR and APR-UTIL, or the path to the apr-1-config and apu-1-config files. I did both (the code pasted above showed I did the latter) but still have the same issue.
http://logging.apache.org/log4cxx/bu...autotools.html

Can you tell me where you saw the "-lapr-1" flag?
 
Old 01-27-2012, 02:31 AM   #4
NevemTeve
Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 270

Rep: Reputation: 91
Eventually apr_socket_create comes from /somepath/lib[64]/libapr-1.so, so if you want to link without unresolved externs, specify flags -L/somepath/lib[64] -lapr-1
If you used libtool, it would do that automagically.
 
Old 01-27-2012, 10:17 AM   #5
grob115
Member
 
Registered: Oct 2005
Posts: 386

Original Poster
Rep: Reputation: 32
Ah of course!!! I was thinking about it as a switch to be passed to ./configure for one of the three APR, APR-UTIL, or log4cxx.
However, isn't the ./configure for log4cxx supposed to have compiled it, and linked in the lib from APR, and/or APR-UTIL? Maybe it's done so with a dynamic linking? Can I specify it to use static *.a libs from APR, APR-UTIL when building the *.a lib for log4cxx?

Also, haven't tested it out but earlier on I was thinking maybe I need to include the header files from APR and/or APR-UTIL with the -I switch when compiling and linking my code. But yeah guess adding the "-lapr-1" flag is properly the answer to it all. Will definitely give it a try.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
undefined reference to.... crapodino Programming 1 01-13-2008 07:05 PM
undefined reference to functions from pcap.h suchitra Programming 6 12-28-2007 12:53 AM
Undefined reference to: ashlesha Programming 5 11-08-2006 01:07 PM
undefined reference? Sharky01252 Programming 3 11-07-2006 11:36 AM
g++: inline functions can cause an undefined reference when linking? R00ts Programming 5 06-21-2005 03:13 AM


All times are GMT -5. The time now is 05:40 AM.

Main Menu
 
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
Open Source Consulting | Domain Registration