www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - more fun with ubuntu

reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
I have a project here which fails on link on ubuntu 12.10.

It give undefined reference errors for functions in libdl and libutil. 
For some reason, ld won't cooperate unless you pass -ldl -lutil at the 
end of the command string. Holy Ubuntu!

I can't seem to get dmd to do this though. Any suggestions?

I am using the beta, but apparently this is a thing with ubuntu.
May 25 2013
next sibling parent reply "estew" <estewh gmail.com> writes:
On Sunday, 26 May 2013 at 05:01:10 UTC, Ellery Newcomer wrote:
 I have a project here which fails on link on ubuntu 12.10.

 It give undefined reference errors for functions in libdl and 
 libutil. For some reason, ld won't cooperate unless you pass 
 -ldl -lutil at the end of the command string. Holy Ubuntu!

 I can't seem to get dmd to do this though. Any suggestions?

 I am using the beta, but apparently this is a thing with ubuntu.
I have the same on Fedora 18 using derelict and some other D libs which I can't remember right now. My understanding is derelict requires libdl for dynamic loading of libs at runtime. My compiler flags are similar to this: dmd -gc -w -Iderelict_import_dir -L-Lderelict_lib_dir -L-lDerelictGL3 -L-lDerelictGLFW3 -L-lDerelictUtil -L-lGL -L-lGLU -L-lglfw -L-ldl myapp.d Could you post your compiler command line? Cheers, Stewart
May 25 2013
next sibling parent "estew" <estewh gmail.com> writes:
Just to clarify:

-I = flag to specify include path
-L-L = flag to specify additional library search path
-L-l = flag to specify link library

/Stewart
May 25 2013
prev sibling parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 05/25/2013 10:20 PM, estew wrote:
 On Sunday, 26 May 2013 at 05:01:10 UTC, Ellery Newcomer wrote:
 I have a project here which fails on link on ubuntu 12.10.

 It give undefined reference errors for functions in libdl and libutil.
 For some reason, ld won't cooperate unless you pass -ldl -lutil at the
 end of the command string. Holy Ubuntu!

 I can't seem to get dmd to do this though. Any suggestions?

 I am using the beta, but apparently this is a thing with ubuntu.
I have the same on Fedora 18 using derelict and some other D libs which I can't remember right now. My understanding is derelict requires libdl for dynamic loading of libs at runtime. My compiler flags are similar to this: dmd -gc -w -Iderelict_import_dir -L-Lderelict_lib_dir -L-lDerelictGL3 -L-lDerelictGLFW3 -L-lDerelictUtil -L-lGL -L-lGLU -L-lglfw -L-ldl myapp.d Could you post your compiler command line? Cheers, Stewart
huh. I haven't run into it on fedora. python is built differently, though. dmd -L-lpthread -L-ldl -L-lutil -L-L/usr/lib -L-lz /usr/lib/python2.7/config/libpython2.7.a -debug -ofbuild/lib.linux-x86_64-2.7/link {lotsaobjectfiles} -L-ldl -L-lutil -v
May 25 2013
parent "estew" <estewh gmail.com> writes:
 huh. I haven't run into it on fedora. python is built 
 differently, though.

 dmd -L-lpthread -L-ldl -L-lutil -L-L/usr/lib -L-lz 
 /usr/lib/python2.7/config/libpython2.7.a -debug 
 -ofbuild/lib.linux-x86_64-2.7/link {lotsaobjectfiles} -L-ldl 
 -L-lutil -v
Well, that should work fine, although the libs are generally referenced after the object files that require them, which you have for dl and util. ld changed a while back now (around Fedora 13 or 14 I think) which introduced similar behaviour. This may provide some more information or links: http://fedoraproject.org/wiki/Features/ChangeInImplicitDSOLinking Sorry I cannot really help....hopefully a D/Linux guru out there know more? Cheers, Stewart
May 25 2013
prev sibling parent reply "Jesse Phillips" <jesse.k.phillips+D gmail.com> writes:
On Sunday, 26 May 2013 at 05:01:10 UTC, Ellery Newcomer wrote:
 I have a project here which fails on link on ubuntu 12.10.

 It give undefined reference errors for functions in libdl and 
 libutil. For some reason, ld won't cooperate unless you pass 
 -ldl -lutil at the end of the command string. Holy Ubuntu!

 I can't seem to get dmd to do this though. Any suggestions?

 I am using the beta, but apparently this is a thing with ubuntu.
It is not uncommon to request the libraries needed to build your app. Dmd passes a couple/one for phobos dependencies, but other libraries need to be reqested.
May 26 2013
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 05/26/2013 07:55 AM, Jesse Phillips wrote:
 On Sunday, 26 May 2013 at 05:01:10 UTC, Ellery Newcomer wrote:
 I have a project here which fails on link on ubuntu 12.10.

 It give undefined reference errors for functions in libdl and libutil.
 For some reason, ld won't cooperate unless you pass -ldl -lutil at the
 end of the command string. Holy Ubuntu!

 I can't seem to get dmd to do this though. Any suggestions?

 I am using the beta, but apparently this is a thing with ubuntu.
It is not uncommon to request the libraries needed to build your app. Dmd passes a couple/one for phobos dependencies, but other libraries need to be reqested.
I am doing that. I think the problem is libpython2.7.a requires libdl and libutil, and ld requires -ldl and -lutil be positioned after libpython2.7.a, but dmd very stubbornly arranges them before libpython2.7.a in the call to gcc.
May 26 2013
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 05/26/2013 08:10 AM, Ellery Newcomer wrote:
 On 05/26/2013 07:55 AM, Jesse Phillips wrote:
 On Sunday, 26 May 2013 at 05:01:10 UTC, Ellery Newcomer wrote:
 I have a project here which fails on link on ubuntu 12.10.

 It give undefined reference errors for functions in libdl and libutil.
 For some reason, ld won't cooperate unless you pass -ldl -lutil at the
 end of the command string. Holy Ubuntu!

 I can't seem to get dmd to do this though. Any suggestions?

 I am using the beta, but apparently this is a thing with ubuntu.
It is not uncommon to request the libraries needed to build your app. Dmd passes a couple/one for phobos dependencies, but other libraries need to be reqested.
I am doing that. I think the problem is libpython2.7.a requires libdl and libutil, and ld requires -ldl and -lutil be positioned after libpython2.7.a, but dmd very stubbornly arranges them before libpython2.7.a in the call to gcc.
dmd -unittest -property -debug -gc -version=Python_2_7_Or_Later -version=Python_2_6_Or_Later -version=Python_2_5_Or_Later -version=Python_2_4_Or_Later -L-ldl /usr/lib/python2.7/config/libpython2.7.a object_.d -ofobject_.x -I../../infrastructure/ -L-ldl -L-lutil -v dmd turns the above into: gcc object_.o -o object_.x -g -m64 -ldl -ldl -lutil -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i386-linux-gnu -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic /usr/lib/python2.7/config/libpython2.7.a -l:libphobos2.a -lpthread -lm -lrt which fails, but gcc object_.o -o object_.x -g -m64 -ldl -ldl -lutil -L/usr/lib/x86_64-linux-gnu -L/usr/lib/i386-linux-gnu -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic /usr/lib/python2.7/config/libpython2.7.a -l:libphobos2.a -lpthread -lm -lrt -ldl -lutil works.
May 26 2013
parent reply Mike Wey <mike-wey example.com> writes:
On 05/26/2013 05:18 PM, Ellery Newcomer wrote:
 On 05/26/2013 08:10 AM, Ellery Newcomer wrote:
 On 05/26/2013 07:55 AM, Jesse Phillips wrote:
 On Sunday, 26 May 2013 at 05:01:10 UTC, Ellery Newcomer wrote:
 I have a project here which fails on link on ubuntu 12.10.

 It give undefined reference errors for functions in libdl and libutil.
 For some reason, ld won't cooperate unless you pass -ldl -lutil at the
 end of the command string. Holy Ubuntu!

 I can't seem to get dmd to do this though. Any suggestions?

 I am using the beta, but apparently this is a thing with ubuntu.
It is not uncommon to request the libraries needed to build your app. Dmd passes a couple/one for phobos dependencies, but other libraries need to be reqested.
I am doing that. I think the problem is libpython2.7.a requires libdl and libutil, and ld requires -ldl and -lutil be positioned after libpython2.7.a, but dmd very stubbornly arranges them before libpython2.7.a in the call to gcc.
dmd -unittest -property -debug -gc -version=Python_2_7_Or_Later -version=Python_2_6_Or_Later -version=Python_2_5_Or_Later -version=Python_2_4_Or_Later -L-ldl /usr/lib/python2.7/config/libpython2.7.a object_.d -ofobject_.x -I../../infrastructure/ -L-ldl -L-lutil -v
Try prefixing the python lib with -L like so: dmd -unittest -property -debug -gc -version=Python_2_7_Or_Later -version=Python_2_6_Or_Later -version=Python_2_5_Or_Later -version=Python_2_4_Or_Later -L-ldl -L/usr/lib/python2.7/config/libpython2.7.a object_.d -ofobject_.x -I../../infrastructure/ -L-ldl -L-lutil -v -- Mike Wey
May 26 2013
parent reply "Ellery Newcomer" <ellery-newcomer utulsa.edu> writes:
On Sunday, 26 May 2013 at 16:28:33 UTC, Mike Wey wrote:
 Try prefixing the python lib with -L like so:

 dmd -unittest -property -debug -gc  
 -version=Python_2_7_Or_Later -version=Python_2_6_Or_Later 
 -version=Python_2_5_Or_Later -version=Python_2_4_Or_Later 
 -L-ldl -L/usr/lib/python2.7/config/libpython2.7.a  object_.d 
 -ofobject_.x -I../../infrastructure/  -L-ldl -L-lutil -v
Hey, that worked! now go report that to issue 7044 :)
May 26 2013
parent Mike Wey <mike-wey example.com> writes:
On 05/26/2013 06:50 PM, Ellery Newcomer wrote:
 On Sunday, 26 May 2013 at 16:28:33 UTC, Mike Wey wrote:
 Try prefixing the python lib with -L like so:

 dmd -unittest -property -debug -gc -version=Python_2_7_Or_Later
 -version=Python_2_6_Or_Later -version=Python_2_5_Or_Later
 -version=Python_2_4_Or_Later -L-ldl
 -L/usr/lib/python2.7/config/libpython2.7.a  object_.d -ofobject_.x
 -I../../infrastructure/  -L-ldl -L-lutil -v
Hey, that worked! now go report that to issue 7044 :)
It works in this case because it's treating the path to the python lib as just an other linker flag. You would still need to be able to control the order of the arguments passed to the linker by dmd if you want to use std.net.curl for example since -lcurl should be passed to the linker after -lphobos2. -- Mike Wey
May 26 2013