Re: ltdl and C++

2011-09-20 Thread Patrick Welche
On Mon, Sep 19, 2011 at 03:34:22PM +0200, Alessandro Candini wrote:
> Hi everyone.
> I have a problem making ltdl library work with some C++ code.
> I have implemented my personal version of the example at the end of
> Chapter 7 in the book "Autotools" by John Calcote.
> Basically it is the same, but I have C++ source files and I use g++
> instead of gcc.
> Configure and make works but I do not produce a dynamic linked
> executable, unlike the original John's example:
> ../src $ ldd hello
> not a dynamic executable
> 
> And I noticed that during compilation the fPIC flag is used although
> I removed every reference to it in all my Makefile.am files.

You are using libtool which works out sensible flags, and fPIC may be
such a flag, so it doesn't need to appear in your Makefile.am.

Maybe you could send us the output of "libtool --config" ?

Cheers,

Patrick

___
https://lists.gnu.org/mailman/listinfo/libtool


Re: ltdl and C++

2011-09-20 Thread Alessandro Candini

On 20/09/11 16:31, Patrick Welche wrote:

On Mon, Sep 19, 2011 at 03:34:22PM +0200, Alessandro Candini wrote:

Hi everyone.
I have a problem making ltdl library work with some C++ code.
I have implemented my personal version of the example at the end of
Chapter 7 in the book "Autotools" by John Calcote.
Basically it is the same, but I have C++ source files and I use g++
instead of gcc.
Configure and make works but I do not produce a dynamic linked
executable, unlike the original John's example:
../src $ ldd hello
 not a dynamic executable

And I noticed that during compilation the fPIC flag is used although
I removed every reference to it in all my Makefile.am files.

You are using libtool which works out sensible flags, and fPIC may be
such a flag, so it doesn't need to appear in your Makefile.am.

Maybe you could send us the output of "libtool --config" ?

Cheers,

Patrick

Ok, here you are some info about my environment and example project.

I'm building this project on this machine:
Linux office-007 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:17:25 
UTC 2011 x86_64 x86_64 x86_64 GNU/Linux


This is my project structure:

hello_chap7/
|-- common
|   |-- hellocommon.h
|   |-- Makefile.am
|   `-- print.cpp
|-- configure.ac
|-- include
|   |-- libhello.h
|   `-- Makefile.am
|-- libhello
|   |-- hello_print.cpp
|   `-- Makefile.am
|-- Makefile.am
`-- src
|-- hello.cpp
|-- Makefile.am
|-- module.h
`-- modules
`-- hithere
|-- hithere.cpp
`-- Makefile.am

These are my Makefile.am files inside the project:

hello_chap7/libhello/Makefile.am:

lib_LTLIBRARIES = libhello.la
libhello_la_SOURCES = hello_print.cpp
libhello_la_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/common
libhello_la_LIBADD = ../common/libhellocommon.la
#---

hello_chap7/src/modules/hithere/Makefile.am:

pkglib_LTLIBRARIES = hithere.la
hithere_la_SOURCES = hithere.cpp
hithere_la_LDFLAGS = -module -avoid-version
#---

hello_chap7/src/Makefile.am:

SUBDIRS = modules/hithere

bin_PROGRAMS = hello
hello_SOURCES = hello.cpp module.h
hello_CPPFLAGS = -I$(top_srcdir)/include
hello_LDADD = ../libhello/libhello.la -dlopen modules/hithere/hithere.la

check_SCRIPTS = greptest.sh
TESTS = $(check_SCRIPTS)

greptest.sh:
echo './hello | grep "Caneta says .* using program .*hello!"' > 
greptest.sh

chmod +x greptest.sh

CLEANFILES = greptest.sh
#---

hello_chap7/include/Makefile.am:

include_HEADERS = libhello.h
#---

hello_chap7/common/Makefile.am:

noinst_LTLIBRARIES = libhellocommon.la
libhellocommon_la_SOURCES = hellocommon.h print.cpp
#---

hello_chap7/Makefile.am:

SUBDIRS = common include libhello src
#---

And in the end the libtool --config output:

macro_version=2.2.6b
macro_revision=1.3017
AS=as
DLLTOOL=dlltool
OBJDUMP=objdump
build_libtool_libs=yes
build_old_libs=yes
pic_mode=default
fast_install=yes
host_alias=
host=x86_64-pc-linux-gnu
host_os=linux-gnu
build_alias=x86_64-linux-gnu
build=x86_64-pc-linux-gnu
build_os=linux-gnu
SED="/bin/sed"
Xsed="$SED -e 1s/^X//"
GREP="/bin/grep"
EGREP="/bin/grep -E"
FGREP="/bin/grep -F"
NM="/usr/bin/nm -B"
LN_S="ln -s"
max_cmd_len=3458764513820540925
objext=o
exeext=
lt_unset=unset
SP2NL="tr \\040 \\012"
NL2SP="tr \\015\\012 \\040\\040"
reload_flag=" -r"
reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs"
deplibs_check_method="pass_all"
file_magic_cmd="\$MAGIC_CMD"
AR="ar"
AR_FLAGS="cru"
STRIP="strip"
RANLIB="ranlib"
old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$oldlib"
old_postuninstall_cmds=""
LTCC="gcc"
LTCFLAGS="-Wall -g -O2"
global_symbol_pipe="sed -n -e 's/^.*[
 ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][
 ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 \\2 \\2/p'"
global_symbol_to_cdecl="sed -n -e 's/^T .* \\(.*\\)\$/extern int 
\\1();/p' -e 's/^[ABCDGIRSTW]* .* \\(.*\\)\$/extern char \\1;/p'"
global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\) \$/  
{\\\"\\1\\\", (void *) 0},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) \\([^ 
]*\\)\$/  {\"\\2\", (void *) \\&\\2},/p'"
global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \\([^ ]*\\) 
\$/  {\\\"\\1\\\", (void *) 0},/p' -e 's/^[ABCDGIRSTW]* \\([^ ]*\\) 
\\(lib[^ ]*\\)\$/  {\"\\2\", (void *) \\&\\2},/p' -e 's/^[ABCDGIRSTW]* 
\\([^ ]*\\) \\([^ ]*\\)\$/  {\"lib\\2\", (void *) \\&\\2},/p'"

objdir=.libs
SHELL="/bin/bash"
ECHO="echo"
MAGIC_CMD=file
need_locks="no"
DSYMUTIL=""
NMEDIT=""
LIPO=""
OTOOL=""
OTOOL64=""
libext=a
shrext_cmds=".so"
extract_expsyms_cmds=""
variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH 
GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"

need_lib_prefix

Re: ltdl and C++

2011-09-20 Thread Nick Bowler
On 2011-09-19 15:34 +0200, Alessandro Candini wrote:
> Configure and make works but I do not produce a dynamic linked 
> executable, unlike the original John's example:
> ../src $ ldd hello
>  not a dynamic executable

This is normal.  When libtool creates an executable that links against
other libtool libraries in your source tree, it creates a shell script
to run the program in-place so that you don't need to install it.  You
haven't shown us your Makefile.am, but I assume it contains something
like hello_LDFLAGS = -dlopen plugin.la.

You appear to be running ldd on that shell script, so of course it's
"not a dynamic executable".  The actual binary that gets installed is
located in .libs/.

If you want to run ldd on an uninstalled executable, do it through
libtool:

  libtool --mode=execute ldd hello

Hope that helps,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)

___
https://lists.gnu.org/mailman/listinfo/libtool


Re: ltdl and C++

2011-09-20 Thread Patrick Welche
On Tue, Sep 20, 2011 at 04:45:34PM +0200, Alessandro Candini wrote:
> >>../src $ ldd hello
> >> not a dynamic executable

Well spotted by Nick! (I should have asked for "file hello")

Cheers,

Patrick

___
https://lists.gnu.org/mailman/listinfo/libtool