www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - linux 64/32

reply Kevin Bealer <Kevin_member pathlink.com> writes:
I tried a bit ago to compile D programs on my computer, under Linux - which I
upgraded to a 64 bit machine.  This didn't work.  I thought I could at least get
a 32 bit executable, but it had linking errors.  I was able to fix these, but
each fix only revealed a further obstacle - I stopped when I got to pthreads,
which I couldn't find a 32 bit version of (I suspect I could build one, but I
have no idea what other libs I would be missing at that point.)

I was surprised, when I tried under WinXP and it worked - I assumed this is
because it doesn't do 64 bits yet?

In any case, has anyone figured out how to build code on a 64 bit machine?  If
it's completely impossible for now, I'm okay with that, I just don't want to
climb the mountain if there's nothing at the top.

If noone knows, I can try again and report what I did and give more details.

(P.S. the previous try was with a D compiler that was several versions back.)

Thanks,
Kevin
Feb 13 2006
next sibling parent reply Sean Kelly <sean f4.ca> writes:
Kevin Bealer wrote:
 I tried a bit ago to compile D programs on my computer, under Linux - which I
 upgraded to a 64 bit machine.  This didn't work.  I thought I could at least
get
 a 32 bit executable, but it had linking errors.  I was able to fix these, but
 each fix only revealed a further obstacle - I stopped when I got to pthreads,
 which I couldn't find a 32 bit version of (I suspect I could build one, but I
 have no idea what other libs I would be missing at that point.)
 
 I was surprised, when I tried under WinXP and it worked - I assumed this is
 because it doesn't do 64 bits yet?
 
 In any case, has anyone figured out how to build code on a 64 bit machine?  If
 it's completely impossible for now, I'm okay with that, I just don't want to
 climb the mountain if there's nothing at the top.
Are you using a 32 or 64 bit kernel? Using an AMD-64 all by itself should affect things--it's the OS that matters. I'm not sure about other changes, but the pthread stuff shouldn't be too difficult to fix, as that is all declared in std/thread.d--simply add "version(x86_64)" blocks where appropriate. Sean
Feb 13 2006
parent reply Kevin Bealer <Kevin_member pathlink.com> writes:
In article <dsr2jl$4n0$1 digitaldaemon.com>, Sean Kelly says...
Kevin Bealer wrote:
 I tried a bit ago to compile D programs on my computer, under Linux - which I
 upgraded to a 64 bit machine.  This didn't work.  I thought I could at least
get
 a 32 bit executable, but it had linking errors.  I was able to fix these, but
 each fix only revealed a further obstacle - I stopped when I got to pthreads,
 which I couldn't find a 32 bit version of (I suspect I could build one, but I
 have no idea what other libs I would be missing at that point.)
 
 I was surprised, when I tried under WinXP and it worked - I assumed this is
 because it doesn't do 64 bits yet?
 
 In any case, has anyone figured out how to build code on a 64 bit machine?  If
 it's completely impossible for now, I'm okay with that, I just don't want to
 climb the mountain if there's nothing at the top.
Are you using a 32 or 64 bit kernel? Using an AMD-64 all by itself should affect things--it's the OS that matters. I'm not sure about other changes, but the pthread stuff shouldn't be too difficult to fix, as that is all declared in std/thread.d--simply add "version(x86_64)" blocks where appropriate. Sean
I'm using a 64 bit kernel, Linux Ubuntu. I tried this again with the latest version, and it had an error, but I can work around it. I don't think I could have just missed this before; I don't know if Ubuntu has upgraded their libraries, or D has changed, but somehow it works now: It seems like what I need to do to compile is: dmd -c hello.d gcc hello.o -o hi -lphobos -lpthread -lm -m32 I don't know how to specify the "-m32" to dmd - passing as a link flag doesn't seem to work, but I can build binaries again, hurrah! In any case, the last time I looked at this (a month or 3 ago), I spend many hours with libraries with no success (at that time). Thanks, Kevin
Feb 13 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin Bealer schrieb am 2006-02-14:
 In article <dsr2jl$4n0$1 digitaldaemon.com>, Sean Kelly says...
Kevin Bealer wrote:
 I tried a bit ago to compile D programs on my computer, under Linux - which I
 upgraded to a 64 bit machine.  This didn't work.  I thought I could at least
get
 a 32 bit executable, but it had linking errors.  I was able to fix these, but
 each fix only revealed a further obstacle - I stopped when I got to pthreads,
 which I couldn't find a 32 bit version of (I suspect I could build one, but I
 have no idea what other libs I would be missing at that point.)
 
 I was surprised, when I tried under WinXP and it worked - I assumed this is
 because it doesn't do 64 bits yet?
 
 In any case, has anyone figured out how to build code on a 64 bit machine?  If
 it's completely impossible for now, I'm okay with that, I just don't want to
 climb the mountain if there's nothing at the top.
Are you using a 32 or 64 bit kernel? Using an AMD-64 all by itself should affect things--it's the OS that matters. I'm not sure about other changes, but the pthread stuff shouldn't be too difficult to fix, as that is all declared in std/thread.d--simply add "version(x86_64)" blocks where appropriate. Sean
I'm using a 64 bit kernel, Linux Ubuntu. I tried this again with the latest version, and it had an error, but I can work around it. I don't think I could have just missed this before; I don't know if Ubuntu has upgraded their libraries, or D has changed, but somehow it works now: It seems like what I need to do to compile is: dmd -c hello.d gcc hello.o -o hi -lphobos -lpthread -lm -m32 I don't know how to specify the "-m32" to dmd - passing as a link flag doesn't seem to work, but I can build binaries again, hurrah! In any case, the last time I looked at this (a month or 3 ago), I spend many hours with libraries with no success (at that time). Thanks, Kevin
I am using dmd on AMD-64 with Gentoo with the following setup: 1) 32bit emulation libs: emul-linux-x86-baselibs-2.3 emul-linux-x86-compat-1.0 emul-linux-x86-glibc-1000 2) gcc wraper: /opt/dmd/bin/gcc gcc -m32 $* 3) changed path, so that dmd uses the gcc script PATH=/opt/dmd/bin/:$PATH dmd somesource.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFD8YRS3w+/yD4P9tIRAux/AJ9vwsYt7KOSUYWq6myxbjtZh2+MyQCgizTe /0QGFARh7PzA1UqA23QDtM4= =1SZ0 -----END PGP SIGNATURE-----
Feb 13 2006
prev sibling parent reply John Demme <me teqdruid.com> writes:
A 64-bit Linux system should be able to run 32-bit binaries as long as it
has the 32-bit versions of the libraries to link to (both the static
libraries and dynamic).  I'm not sure about Ubuntu, but I know Gentoo
64-bit provides 32-bit libraries.

You should be able to send -m32 to the gcc linker using -L-m32 .  You may
also want to check out gdc.  It may be able to generate 64-bit code,
although I'm not sure.

I don't have a 64-bit box (yet) so I'm not sure how much help that was, but
in theory it should be possible.

BTW, I think the reason there aren't any issues with Windows in because
Windows doesn't use 64-bit anything, just 32.  They may have upgraded since
I last heard, however.

~John Demme

Kevin Bealer wrote:

 I tried a bit ago to compile D programs on my computer, under Linux -
 which I
 upgraded to a 64 bit machine.  This didn't work.  I thought I could at
 least get
 a 32 bit executable, but it had linking errors.  I was able to fix these,
 but each fix only revealed a further obstacle - I stopped when I got to
 pthreads, which I couldn't find a 32 bit version of (I suspect I could
 build one, but I have no idea what other libs I would be missing at that
 point.)
 
 I was surprised, when I tried under WinXP and it worked - I assumed this
 is because it doesn't do 64 bits yet?
 
 In any case, has anyone figured out how to build code on a 64 bit machine?
  If it's completely impossible for now, I'm okay with that, I just don't
 want to climb the mountain if there's nothing at the top.
 
 If noone knows, I can try again and report what I did and give more
 details.
 
 (P.S. the previous try was with a D compiler that was several versions
 back.)
 
 Thanks,
 Kevin
Feb 13 2006
parent Kevin Bealer <Kevin_member pathlink.com> writes:
Thanks;  I tried this, but using -Xlinker, I get this:

/usr/bin/ld: unrecognised emulation mode: 32
Supported emulations: elf_i386 i386linux
collect2: ld returned 1 exit status

It seems like "-m32" needs to go to the compiler phase, even when just linking
the code.  I don't know exactly why, though.  Maybe there is glue code *between*
the library and application that needs to be 32 or 64.

It might be simple for dmd to automatically provide the -m32 option, but of
course the user will need all the 32 bit versions of things too (which I have,
but which will not be standard on most 64 bit systems I think).

In any case, it all works for me now.

BTW, Walter, great idea on the -run option, I've always thought D was only
inches from being a great scripting language.

Kevin


In article <dsrmje$m91$1 digitaldaemon.com>, John Demme says...
A 64-bit Linux system should be able to run 32-bit binaries as long as it
has the 32-bit versions of the libraries to link to (both the static
libraries and dynamic).  I'm not sure about Ubuntu, but I know Gentoo
64-bit provides 32-bit libraries.

You should be able to send -m32 to the gcc linker using -L-m32 .  You may
also want to check out gdc.  It may be able to generate 64-bit code,
although I'm not sure.

I don't have a 64-bit box (yet) so I'm not sure how much help that was, but
in theory it should be possible.

BTW, I think the reason there aren't any issues with Windows in because
Windows doesn't use 64-bit anything, just 32.  They may have upgraded since
I last heard, however.

~John Demme

Kevin Bealer wrote:

 I tried a bit ago to compile D programs on my computer, under Linux -
 which I
 upgraded to a 64 bit machine.  This didn't work.  I thought I could at
 least get
 a 32 bit executable, but it had linking errors.  I was able to fix these,
 but each fix only revealed a further obstacle - I stopped when I got to
 pthreads, which I couldn't find a 32 bit version of (I suspect I could
 build one, but I have no idea what other libs I would be missing at that
 point.)
 
 I was surprised, when I tried under WinXP and it worked - I assumed this
 is because it doesn't do 64 bits yet?
 
 In any case, has anyone figured out how to build code on a 64 bit machine?
  If it's completely impossible for now, I'm okay with that, I just don't
 want to climb the mountain if there's nothing at the top.
 
 If noone knows, I can try again and report what I did and give more
 details.
 
 (P.S. the previous try was with a D compiler that was several versions
 back.)
 
 Thanks,
 Kevin
Feb 14 2006