www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - undefined reference to symbol '_end'

reply mimocrocodil <4denizzz gmail.com> writes:
I am trying to link my program with libpq:

$ dmd main.d dbwork.d -ofmain -v -L-lpq

[skipped good output]
import    std.c.linux.socket	(/usr/include/d/dmd/phobos/std/c/linux/socket.d)
import    core.sys.posix.netdb	(/usr/include/d/dmd/druntime/import/core/sys/posix/netdb.di)
import    core.sys.posix.netinet.in_	(/usr/include/d/dmd/druntime/import/core/sys/posix/netinet/in_.di)
import    core.sys.posix.netinet.tcp	(/usr/include/d/dmd/druntime/import/core/sys/posix/netinet/tcp.di)
import    dpq2.libpq	(dpq2/libpq.di)
importall dbwork
semantic  main
semantic  dbwork
semantic2 main
semantic2 dbwork
semantic3 main
semantic3 dbwork
code      main
function  main
function  enforce
code      dbwork
function  do_request
function  writeln
function  __dgliteral1233
gcc main.o -o main -m64 -lpq -Xlinker -L/usr/lib64 -Xlinker -L/usr/lib32
-Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lrt -lphobos2 -
lpthread -lm
/usr/bin/ld: /usr/lib64/libphobos2.a(memory_350_620.o): undefined reference to
symbol '_end'
/usr/bin/ld: note: '_end' is defined in DSO /lib64/libcom_err.so.2 so try
adding it to the linker command line
/lib64/libcom_err.so.2: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
--- errorlevel 1

If I am disable linking with libpq (just remove -L-lpq from command line)
compiling works fine. What's happening?


Also:


$ nm /usr/lib/libphobos2.a | grep _end
0000000000000000 T _D4core4stdc6stdarg6va_endFPvZv
                 U _deh_end
                 U _end
                 U __libc_stack_end
                 U _end
                 U _D4core4stdc6stdarg6va_endFPvZv

"U" means "The symbol is undefined".
Aug 12 2011
next sibling parent Jesse Phillips <jessekphillips+d gmail.com> writes:
On Fri, 12 Aug 2011 20:23:50 +0000, mimocrocodil wrote:

 I am trying to link my program with libpq:
 
 $ dmd main.d dbwork.d -ofmain -v -L-lpq
The important statement: note: '_end' is defined in DSO /lib64/libcom_err.so.2 so try adding it to the linker command line so maybe: $ dmd main.d dbwork.d -ofmain -v -L-lpq -L-lcom_err
Aug 12 2011
prev sibling next sibling parent mimocrocodil <4denizzz gmail.com> writes:
If try to link with any another lib (.so or .a) it works fine. Looks very
strange!
Aug 12 2011
prev sibling parent reply mimocrocodil <4denizzz gmail.com> writes:
Jesse Phillips:

Bingo! it is compiles and works!

Many thanks! :)
Aug 12 2011
parent Jesse Phillips <jessekphillips+d gmail.com> writes:
On Sat, 13 Aug 2011 02:13:38 +0000, mimocrocodil wrote:

 Jesse Phillips:
 
 Bingo! it is compiles and works!
 
 Many thanks! :)
The problem was with the library you were linking with, it expected more symbols. So if excluded it then those symbols were not needed.
Aug 13 2011