public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* library not present in ldd after g++ compiled and linked my sources
@ 2013-01-09 11:57 michaelr
  2013-01-09 12:38 ` Florian Weimer
  2013-01-09 13:39 ` Marc Glisse
  0 siblings, 2 replies; 10+ messages in thread
From: michaelr @ 2013-01-09 11:57 UTC (permalink / raw)
  To: gcc-help

Hi all,

i run into a strange problem which i can't solve alone. The complete
projects builds fine (no errors or warnings) but the programm will 
not start afterwards because one library (-lboost_date_time) is simply
not present when i run ldd on it.

In the Makefile.am i have defined something like this:

libmodwscmi_la_CXXFLAGS = $(INCLUDES) $(PROJECT_INCLUDES) $(APR_CFLAGS)
libmodwscmi_la_LDFLAGS  = $(LDADD) $(BOOST_LDFLAGS) $(LIB_BOOST_REGEX)
$(LIB_BOOST_DATETIME) `$(APR1CONFIG) --link-ld --libs`
libmodwscmi_la_LIBADD   = $(top_builddir)/utils/mysqlpp/libmysqlpp.la
$(top_builddir)/utils/jwsmtp/libjwsmtp.la

During build the linker gets called with this command:

g++  -fPIC -DPIC -shared
-nostdlib /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.7/crtbeginS.o  .libs/libmodwscmi_la-mod_wscmi.o .libs/libmodwscmi_la-mod_gsoap.o .libs/libmodwscmi_la-mod_utils.o .libs/libmodwscmi_la-mod_mysql.o .libs/libmodwscmi_la-md5.o .libs/libmodwscmi_la-regEx.o .libs/libmodwscmi_la-utils.o .libs/libmodwscmi_la-exception.o .libs/libmodwscmi_la-dateTime.o .libs/libmodwscmi_la-validator.o .libs/libmodwscmi_la-mysqlPool.o .libs/libmodwscmi_la-mysqlCons.o .libs/libmodwscmi_la-mysqlQueries.o .libs/libmodwscmi_la-sqlite3.o   -Wl,-rpath -Wl,/var/www/projects/mod_wscmi-1.0/utils/mysqlpp/.libs -Wl,-rpath -Wl,/var/www/projects/mod_wscmi-1.0/utils/jwsmtp/.libs -L/usr/local/lib -lboost_date_time -lboost_regex -L/usr/lib /usr/lib/libapr-1.so -L/usr/local/mysql/lib ../utils/mysqlpp/.libs/libmysqlpp.so ../utils/jwsmtp/.libs/libjwsmtp.so -L/usr/lib/gcc/x86_64-linux-gnu/4.7 -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crtn.o  -pthread -O3 -Wl,-R/usr/local/lib   -pthread -Wl,-soname -Wl,libmodwscmi.so.0 -o .libs/libmodwscmi.so.0.0.0

As you can see above, both libraries are present: -lboost_date_time
-lboost_regex - they are also present in the right place 
of my harddrive (in /use/local/lib) and there are no warnings or errors
during the build:

...
-rw-r--r-- 1 root  136876 Nov 20 09:19 libboost_date_time.a
lrwxrwxrwx 1 root      28 Nov 20 09:18 libboost_date_time.so ->
libboost_date_time.so.1.52.0
-rwxr-xr-x 1 root   94337 Nov 20 09:18 libboost_date_time.so.1.52.0
...
-rw-r--r-- 1 root 2619610 Nov 20 09:19 libboost_regex.a
lrwxrwxrwx 1 root      24 Nov 20 09:18 libboost_regex.so ->
libboost_regex.so.1.52.0
-rwxr-xr-x 1 root 1251576 Nov 20 09:18 libboost_regex.so.1.52.0
...

When i run LDD on the finaly library i get something like this:

ldd /usr/local/apache/modules/mod_wscmi.so
 linux-vdso.so.1 =>  (0x00007fffeafff000)
 libboost_regex.so.1.52.0 => /usr/local/lib/libboost_regex.so.1.52.0
(0x00007fcfe8bc5000)
 libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0x00007fcfe8974000)
 libmysqlpp.so.0 => /usr/local/lib/libmysqlpp.so.0 (0x00007fcfe86f4000)
 libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007fcfe83f1000)
 libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcfe8031000)
 libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007fcfe7e1b000)
 libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007fcfe7bfe000)
 libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fcfe79f8000)
 libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcfe77f4000)
 libmysqlclient.so.18 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18
(0x00007fcfe72b0000)
 libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcfe6fb3000)
 /lib64/ld-linux-x86-64.so.2 (0x00007fcfe91a8000)
 libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fcfe6d9c000)

Running the same command on another box includes the missing library
(libboost_date_time.so) and the programm
works as expected but on this box (Ubuntu 12.10 - GNU/Linux
3.5.0-21-generic x86_64) it can't start because
of some undefined symbols.

I have absolutly no idea what went wrong here and why libboost_date_time
is not included correctly. Hopefully 
someone of the list could give me an hint.

Thanks
 Michael



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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 11:57 library not present in ldd after g++ compiled and linked my sources michaelr
@ 2013-01-09 12:38 ` Florian Weimer
  2013-01-09 12:58   ` michaelr
  2013-01-09 13:39 ` Marc Glisse
  1 sibling, 1 reply; 10+ messages in thread
From: Florian Weimer @ 2013-01-09 12:38 UTC (permalink / raw)
  To: michaelr; +Cc: gcc-help

On 01/09/2013 11:42 AM, michaelr wrote:

> i run into a strange problem which i can't solve alone. The complete
> projects builds fine (no errors or warnings) but the programm will
> not start afterwards because one library (-lboost_date_time) is simply
> not present when i run ldd on it.

What's the error message when you try to start the program?

(Not sure if this is actually a GCC problem, though.)

-- 
Florian Weimer / Red Hat Product Security Team

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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 12:38 ` Florian Weimer
@ 2013-01-09 12:58   ` michaelr
  2013-01-09 12:59     ` Florian Weimer
  0 siblings, 1 reply; 10+ messages in thread
From: michaelr @ 2013-01-09 12:58 UTC (permalink / raw)
  To: Florian Weimer; +Cc: gcc-help

Hi Florian,

On Wed, 2013-01-09 at 12:56 +0100, Florian Weimer wrote:
> On 01/09/2013 11:42 AM, michaelr wrote:
> 
> > i run into a strange problem which i can't solve alone. The complete
> > projects builds fine (no errors or warnings) but the programm will
> > not start afterwards because one library (-lboost_date_time) is simply
> > not present when i run ldd on it.
> 
> What's the error message when you try to start the program?
> 
> (Not sure if this is actually a GCC problem, though.)
> 

the message is: /usr/local/apache/modules/mod_wscmi.so undefined symbol:
_ZNK5boost9gregorian10greg_month15as_short_stringEv

it's undefined because the complete library is not linked into the
binary i think. 







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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 12:58   ` michaelr
@ 2013-01-09 12:59     ` Florian Weimer
  2013-01-09 13:45       ` michaelr
  0 siblings, 1 reply; 10+ messages in thread
From: Florian Weimer @ 2013-01-09 12:59 UTC (permalink / raw)
  To: michaelr; +Cc: gcc-help

On 01/09/2013 01:36 PM, michaelr wrote:
> Hi Florian,
>
> On Wed, 2013-01-09 at 12:56 +0100, Florian Weimer wrote:
>> On 01/09/2013 11:42 AM, michaelr wrote:
>>
>>> i run into a strange problem which i can't solve alone. The complete
>>> projects builds fine (no errors or warnings) but the programm will
>>> not start afterwards because one library (-lboost_date_time) is simply
>>> not present when i run ldd on it.
>>
>> What's the error message when you try to start the program?

> the message is: /usr/local/apache/modules/mod_wscmi.so undefined symbol:
> _ZNK5boost9gregorian10greg_month15as_short_stringEv

Is mod_wscmi.so really the same file as libmodwscmi.so.0.0.0?

(It's a bit unusual to build Apache httpd modules using libtool, I 
think.  Doesn't httpd provide a separate too for that?)

-- 
Florian Weimer / Red Hat Product Security Team

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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 11:57 library not present in ldd after g++ compiled and linked my sources michaelr
  2013-01-09 12:38 ` Florian Weimer
@ 2013-01-09 13:39 ` Marc Glisse
  2013-01-09 14:11   ` michaelr
  1 sibling, 1 reply; 10+ messages in thread
From: Marc Glisse @ 2013-01-09 13:39 UTC (permalink / raw)
  To: michaelr; +Cc: gcc-help

On Wed, 9 Jan 2013, michaelr wrote:

> i run into a strange problem which i can't solve alone. The complete
> projects builds fine (no errors or warnings) but the programm will
> not start afterwards because one library (-lboost_date_time) is simply
> not present when i run ldd on it.

--no-as-needed (I guess you are on Ubuntu). Still, you could link your 
plugin with boost, since it uses boost.

-- 
Marc Glisse

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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 12:59     ` Florian Weimer
@ 2013-01-09 13:45       ` michaelr
  2013-01-09 14:42         ` Florian Weimer
  0 siblings, 1 reply; 10+ messages in thread
From: michaelr @ 2013-01-09 13:45 UTC (permalink / raw)
  To: Florian Weimer; +Cc: gcc-help

On Wed, 2013-01-09 at 13:58 +0100, Florian Weimer wrote:

> Is mod_wscmi.so really the same file as libmodwscmi.so.0.0.0?

i rename the finally library during install (just to meet the
apache httpd naming conventions).

> 
> (It's a bit unusual to build Apache httpd modules using libtool, I 
> think.  Doesn't httpd provide a separate too for that?)
> 

yes, you can use apxs. It's more comfortable for me to use libtool.



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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 13:39 ` Marc Glisse
@ 2013-01-09 14:11   ` michaelr
  0 siblings, 0 replies; 10+ messages in thread
From: michaelr @ 2013-01-09 14:11 UTC (permalink / raw)
  To: gcc-help

Hi Marc,

On Wed, 2013-01-09 at 13:59 +0100, Marc Glisse wrote:
> --no-as-needed (I guess you are on Ubuntu). Still, you could link your 
> plugin with boost, since it uses boost.
> 

thanks! This gives me a direction where to look at.


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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 13:45       ` michaelr
@ 2013-01-09 14:42         ` Florian Weimer
  2013-01-09 14:45           ` michaelr
  0 siblings, 1 reply; 10+ messages in thread
From: Florian Weimer @ 2013-01-09 14:42 UTC (permalink / raw)
  To: michaelr; +Cc: gcc-help

On 01/09/2013 02:36 PM, michaelr wrote:
> On Wed, 2013-01-09 at 13:58 +0100, Florian Weimer wrote:
>
>> Is mod_wscmi.so really the same file as libmodwscmi.so.0.0.0?
>
> i rename the finally library during install (just to meet the
> apache httpd naming conventions).

In this case, the Boost headers probably do not match the Boost DSO.

-- 
Florian Weimer / Red Hat Product Security Team

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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 14:42         ` Florian Weimer
@ 2013-01-09 14:45           ` michaelr
  2013-01-09 16:25             ` Florian Weimer
  0 siblings, 1 reply; 10+ messages in thread
From: michaelr @ 2013-01-09 14:45 UTC (permalink / raw)
  To: Florian Weimer; +Cc: gcc-help

Hi Florian,

On Wed, 2013-01-09 at 15:11 +0100, Florian Weimer wrote:
On 01/09/2013 02:36 PM, michaelr wrote:
> > On Wed, 2013-01-09 at 13:58 +0100, Florian Weimer wrote:
> >
> >> Is mod_wscmi.so really the same file as libmodwscmi.so.0.0.0?
> >
> > i rename the finally library during install (just to meet the
> > apache httpd naming conventions).
> 
> In this case, the Boost headers probably do not match the Boost DSO. 

thanks, the included headers and the library version are the same.

As Marc Glisse wrote a post later it has something to to do with
optimization flag: --no-add-needed which is used on the ubuntu platform.

During compile/link time no symbols are used from the boost date_time
library by the module itself so the linker does not link the libary
at all. Later at runtime i load a bunch of other 'plugins' via  
apr_dso_load(...). These plugins then need some symbols from boost 
date time and the trouble begins.

All i have to do is to tell the linker to link the libray even if it's
symbols are not used in the module at build time.





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

* Re: library not present in ldd after g++ compiled and linked my sources
  2013-01-09 14:45           ` michaelr
@ 2013-01-09 16:25             ` Florian Weimer
  0 siblings, 0 replies; 10+ messages in thread
From: Florian Weimer @ 2013-01-09 16:25 UTC (permalink / raw)
  To: michaelr; +Cc: gcc-help

On 01/09/2013 03:39 PM, michaelr wrote:

> During compile/link time no symbols are used from the boost date_time
> library by the module itself so the linker does not link the libary
> at all. Later at runtime i load a bunch of other 'plugins' via
> apr_dso_load(...). These plugins then need some symbols from boost
> date time and the trouble begins.

Ah, somehow, this critical piece of information escaped me.  You should 
link those plugins against the boost libraries, then.

-- 
Florian Weimer / Red Hat Product Security Team

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

end of thread, other threads:[~2013-01-09 14:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-09 11:57 library not present in ldd after g++ compiled and linked my sources michaelr
2013-01-09 12:38 ` Florian Weimer
2013-01-09 12:58   ` michaelr
2013-01-09 12:59     ` Florian Weimer
2013-01-09 13:45       ` michaelr
2013-01-09 14:42         ` Florian Weimer
2013-01-09 14:45           ` michaelr
2013-01-09 16:25             ` Florian Weimer
2013-01-09 13:39 ` Marc Glisse
2013-01-09 14:11   ` michaelr

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).