digitalmars.D.learn - 64-bit two-step compilation on Ubuntu?
- Sean Eskapp (9/9) Apr 25 2011 I'm trying to get a D2 project to build on Ubuntu through Code::Blocks.
- Jonathan M Davis (12/24) Apr 25 2011 First thing I'd try would be to use dmd as the linker.
- Sean Eskapp (3/27) Apr 25 2011 How do I use dmd as the linker separately from using it as the compiler?
- Jonathan M Davis (10/42) Apr 25 2011 If you pass -c to dmd, it won't link, but will just produce .o files.
- Sean Eskapp (3/45) Apr 25 2011 I reinstalled dmd, changed up my compiler flags from global and project-...
I'm trying to get a D2 project to build on Ubuntu through Code::Blocks. Unfortunately, Code::Blocks doesn't allow the simple one-step compilation that is default with dmd, so it does compiling and linking in two separate steps. Unfortunately, this is causing some linker errors, the main one being: /usr/bin/ld: i386 architecture of input file `obj/Debug/main.o' is incompatible with i386:x86-64 output I've tried passing -melf_x86_64 to the linker, and that doesn't change anything. I'm also trying to pass -m64 to the compilation step, and it doesn't work. Help?
Apr 25 2011
I'm trying to get a D2 project to build on Ubuntu through Code::Blocks. Unfortunately, Code::Blocks doesn't allow the simple one-step compilation that is default with dmd, so it does compiling and linking in two separate steps. Unfortunately, this is causing some linker errors, the main one being: /usr/bin/ld: i386 architecture of input file `obj/Debug/main.o' is incompatible with i386:x86-64 output I've tried passing -melf_x86_64 to the linker, and that doesn't change anything. I'm also trying to pass -m64 to the compilation step, and it doesn't work. Help?First thing I'd try would be to use dmd as the linker. dmd compiles in 32-bit by default. Assuming that you're using dmd 2.052, then you can use -m64 to tell it to compile for 64-bit, at which point linking with gcc should work. Otherwise, you'd need to pass -m32 to gcc when linking (unless you're using ld directly (at which point, I don't know what you do), and I'm not aware of anyone doing that - dmd doesn't). Regardless, if you're linking separately and not using dmd for the linking step, then you need to look at dmd.conf and make sure that you include the linker flags that it does, or your code may not work. In any case, my best suggestion if you can't compile and link in one step would be to just use dmd for both. - Jonathan M Davis
Apr 25 2011
== Quote from Jonathan M Davis (jmdavisProg gmx.com)'s articleHow do I use dmd as the linker separately from using it as the compiler? As you can see in my original post, I'm passing -m64 to DMD, but it doesn't seem to be picking it up..I'm trying to get a D2 project to build on Ubuntu through Code::Blocks. Unfortunately, Code::Blocks doesn't allow the simple one-step compilation that is default with dmd, so it does compiling and linking in two separate steps. Unfortunately, this is causing some linker errors, the main one being: /usr/bin/ld: i386 architecture of input file `obj/Debug/main.o' is incompatible with i386:x86-64 output I've tried passing -melf_x86_64 to the linker, and that doesn't change anything. I'm also trying to pass -m64 to the compilation step, and it doesn't work. Help?First thing I'd try would be to use dmd as the linker. dmd compiles in 32-bit by default. Assuming that you're using dmd 2.052, then you can use -m64 to tell it to compile for 64-bit, at which point linking with gcc should work. Otherwise, you'd need to pass -m32 to gcc when linking (unless you're using ld directly (at which point, I don't know what you do), and I'm not aware of anyone doing that - dmd doesn't). Regardless, if you're linking separately and not using dmd for the linking step, then you need to look at dmd.conf and make sure that you include the linker flags that it does, or your code may not work. In any case, my best suggestion if you can't compile and link in one step would be to just use dmd for both. - Jonathan M Davis
Apr 25 2011
== Quote from Jonathan M Davis (jmdavisProg gmx.com)'s articleIf you pass -c to dmd, it won't link, but will just produce .o files. Otherwise, it'll link the .o files and produce a binary. If you're doing 2 step compilation, then you must be passing -c to dmd for the first step. So, for the second step, just give it the .o files instead of the .d files and don't pass it -c. As for -m64, if you have a version of dmd prior to 2.052, then it only does 32-bit compilation. If you have 2.052, then it should accept -m64 and produce 64-bit .o files, and produce a 64-bit binary when when not using -c. If that doesn't work, then it needs to be reported in bugzilla. - Jonathan M DavisHow do I use dmd as the linker separately from using it as the compiler? As you can see in my original post, I'm passing -m64 to DMD, but it doesn't seem to be picking it up..I'm trying to get a D2 project to build on Ubuntu through Code::Blocks. Unfortunately, Code::Blocks doesn't allow the simple one-step compilation that is default with dmd, so it does compiling and linking in two separate steps. Unfortunately, this is causing some linker errors, the main one being: /usr/bin/ld: i386 architecture of input file `obj/Debug/main.o' is incompatible with i386:x86-64 output I've tried passing -melf_x86_64 to the linker, and that doesn't change anything. I'm also trying to pass -m64 to the compilation step, and it doesn't work. Help?First thing I'd try would be to use dmd as the linker. dmd compiles in 32-bit by default. Assuming that you're using dmd 2.052, then you can use -m64 to tell it to compile for 64-bit, at which point linking with gcc should work. Otherwise, you'd need to pass -m32 to gcc when linking (unless you're using ld directly (at which point, I don't know what you do), and I'm not aware of anyone doing that - dmd doesn't). Regardless, if you're linking separately and not using dmd for the linking step, then you need to look at dmd.conf and make sure that you include the linker flags that it does, or your code may not work. In any case, my best suggestion if you can't compile and link in one step would be to just use dmd for both. - Jonathan M Davis
Apr 25 2011
== Quote from Jonathan M Davis (jmdavisProg gmx.com)'s articleI reinstalled dmd, changed up my compiler flags from global and project-specific to just project specific in Code::Blocks, and removed the unnecessary - melf_x86_64 linker flag, and it seems to have started working. Thanks!== Quote from Jonathan M Davis (jmdavisProg gmx.com)'s articleIf you pass -c to dmd, it won't link, but will just produce .o files. Otherwise, it'll link the .o files and produce a binary. If you're doing 2 step compilation, then you must be passing -c to dmd for the first step. So, for the second step, just give it the .o files instead of the .d files and don't pass it -c. As for -m64, if you have a version of dmd prior to 2.052, then it only does 32-bit compilation. If you have 2.052, then it should accept -m64 and produce 64-bit .o files, and produce a 64-bit binary when when not using -c. If that doesn't work, then it needs to be reported in bugzilla. - Jonathan M DavisHow do I use dmd as the linker separately from using it as the compiler? As you can see in my original post, I'm passing -m64 to DMD, but it doesn't seem to be picking it up..I'm trying to get a D2 project to build on Ubuntu through Code::Blocks. Unfortunately, Code::Blocks doesn't allow the simple one-step compilation that is default with dmd, so it does compiling and linking in two separate steps. Unfortunately, this is causing some linker errors, the main one being: /usr/bin/ld: i386 architecture of input file `obj/Debug/main.o' is incompatible with i386:x86-64 output I've tried passing -melf_x86_64 to the linker, and that doesn't change anything. I'm also trying to pass -m64 to the compilation step, and it doesn't work. Help?First thing I'd try would be to use dmd as the linker. dmd compiles in 32-bit by default. Assuming that you're using dmd 2.052, then you can use -m64 to tell it to compile for 64-bit, at which point linking with gcc should work. Otherwise, you'd need to pass -m32 to gcc when linking (unless you're using ld directly (at which point, I don't know what you do), and I'm not aware of anyone doing that - dmd doesn't). Regardless, if you're linking separately and not using dmd for the linking step, then you need to look at dmd.conf and make sure that you include the linker flags that it does, or your code may not work. In any case, my best suggestion if you can't compile and link in one step would be to just use dmd for both. - Jonathan M Davis
Apr 25 2011