LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 05-25-2012, 11:06 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,888
Blog Entries: 1

Rep: Reputation: 77
compiling phc - ld doesn't want to see a library that's in front of it


Hi!

I think I'm very close to finishing compiling phc on kubuntu precise (I've spent a good couple of hours fighting with this compilation process).

Now I've hit a brick wall where ld doesn't want to see a so that's (I think) right in front of it.

The command in question and the output error is like this:
Code:
$ LANG=en g++ -Wextra -Wno-unused-parameter -Wno-write-strings -Wno-deprecated -g -O2 -o src/.libs/phc phc.o -Wl,--export-dynamic  /home/antoranz/Downloads/phc/phc-0.3.0.1/libltdl/./.libs/dlopen.a libltdl/.libs/libltdlc.a -lboost_regex ./.libs/libphc.so -L/usr/local/boost/lib -L/usr/local/php/lib -lgccpp -lgc -lphp5 -ldl -Wl,-rpath -Wl,/usr/local/phc/lib
./.libs/libphc.so: undefined reference to `boost::re_detail::raise_runtime_error(std::runtime_error const&)'
./.libs/libphc.so: undefined reference to `boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
./.libs/libphc.so: undefined reference to `boost::cpp_regex_traits<char>::toi(char const*&, char const*, int) const'
./.libs/libphc.so: undefined reference to `boost::re_detail::put_mem_block(void*)'
./.libs/libphc.so: undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > const&)'
./.libs/libphc.so: undefined reference to `boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >::maybe_assign(boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > > const&)'
./.libs/libphc.so: undefined reference to `boost::re_detail::get_mem_block()'
./.libs/libphc.so: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
./.libs/libphc.so: undefined reference to `boost::re_detail::verify_options(unsigned int, boost::regex_constants::_match_flags)'
./.libs/libphc.so: undefined reference to `boost::re_detail::get_default_error_string(boost::regex_constants::error_type)'
./.libs/libphc.so: undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
./.libs/libphc.so: undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform(char const*, char const*) const'
./.libs/libphc.so: undefined reference to `boost::re_detail::cpp_regex_traits_implementation<char>::transform_primary(char const*, char const*) const'
collect2: ld returned 1 exit status
The symbols are in libboost_regex:
Code:
$ nm -gC /usr/local/boost/lib/libboost_regex.so | grep raise_runtime_error
0007f250 T boost::re_detail::raise_runtime_error(std::runtime_error const&)
So, it's a linker problem. I have tried adding this options when calling g++:
-Wl,-rpath -Wl,/usr/local/boost/lib
-Wl,-L -Wl,/usr/local/boost/lib

Also setting LD_LIBRARY_PATH or (logical or) LD_RUN_PATH to /usr/local/boost/lib to no avail. ld refuses to use the libboost_regex library:

Code:
$ ls /usr/local/boost/lib/libboost_regex.so -l
lrwxrwxrwx 1 root root 24 may 25 20:31 /usr/local/boost/lib/libboost_regex.so -> libboost_regex.so.1.46.1
How can I force ld to see it? Thanks in advance.

Last edited by eantoranz; 05-25-2012 at 11:56 PM. Reason: typo
 
Old 05-26-2012, 03:55 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,396

Rep: Reputation: 440Reputation: 440Reputation: 440Reputation: 440Reputation: 440
Try using

-l:libboost_regex.so

instead of '-lboost_regex' which you have; pay attention to ':' and to full file name.

This approach sometimes helps to resolve linking issues - I never digged why.
 
1 members found this post helpful.
Old 05-26-2012, 03:59 PM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,396

Rep: Reputation: 440Reputation: 440Reputation: 440Reputation: 440Reputation: 440
Also, read about LD_DEBUG, LD_DEBUG_OUTPUT in http://linux.die.net/man/8/ld-linux - I used the environment variable to debug linker failures.

I think you need LD_LIBRARY_PATH to be set.
 
1 members found this post helpful.
Old 05-26-2012, 04:05 PM   #4
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 2,793

Rep: Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622
you need to use -L <path> to define directories where the libraries located, and -l<libname> to use the lib (libname will not contain the word lib at the beginning and .so at the end), so -lboost_regex would be fine). The problem is that the -L should come first before -l.
 
1 members found this post helpful.
Old 05-26-2012, 04:10 PM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,396

Rep: Reputation: 440Reputation: 440Reputation: 440Reputation: 440Reputation: 440
Quote:
Originally Posted by pan64;4688385... The problem is that the -L should come first [I
before[/I] -l.
I don't think it matters:


Code:
       -Lsearchdir
       --library-path=searchdir
           Add path searchdir to the list of paths that ld will search for archive libraries and ld control scripts.  You may use this option any number of times.   The  directo-
           ries are searched in the order in which they are specified on the command line.  Directories specified on the command line are searched before the default directories.
           All -L options apply to all -l options, regardless of the order in which the options appear.
 
Old 05-27-2012, 06:46 PM   #6
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,888
Blog Entries: 1

Original Poster
Rep: Reputation: 77
I think the problem is in the ./configure script that is not setting things right. Based on all the information you provided I was able to finish the compilation process.

First I tried adding this to the g++ calls:

Code:
-Wl,-L/usr/local/boost/lib -Wl,-lboost_regex
Thas was enough to make it move ahead. But ultimately it can be hacked on the Makefile.

On LIBS add -lboost_regex
On LDFLAGS add -L/usr/local/boost/lib

Or according to your environment. With that I was able to resume "making" and finish the compilation process.

Thank you all for your kind help.
 
  


Reply

Tags
boost, boost_regex, ld, missing, phc


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
[SOLVED] phc compilation on precise - invalid conversion eantoranz Programming 7 05-25-2012 10:52 PM
[SOLVED] phc (php compiler) - How to compile on kubuntu precise eantoranz Linux - Software 3 05-25-2012 03:20 PM
PHC - php compiler entz Programming 2 12-15-2010 10:15 AM
Writing GUI front-ends: what language + what GUI library? pear Programming 7 07-07-2008 08:17 AM
Compiling library files into another library file. knobby67 Programming 3 04-10-2007 02:07 PM


All times are GMT -5. The time now is 04:18 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