codeblocksdldc

How do I use LDC (D Compiler) with Code::Blocks? Specifically, how do I use the linker?


I have been using CodeBlocks with the Digital Mars D compiler and the LLVM Clang compiler for some time without any problems. Now I need to use the LDC D compiler and am having problems with the linker invocation.

I get the following output:

-------------- Build: Debug in test (compiler: LLVM D Compiler)---------------

ldc2.exe  -g    -I"C:\Program Files\LDC\ldc2-1.13.0-windows-x64\bin" -c hello.d -of=obj\Debug\hello.o
ldc2.exe -L-L"C:\Program Files\LDC\ldc2-1.13.0-windows-x64\lib" -of=bin\Debug\test.exe obj\Debug\hello.o   
Error: unrecognized file extension o
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

The compile step seems to work fine, but specifying ldc2.exe as a linker clearly fails.

Similarly, using ldmd2.exe and lld-link.exe in CodeBlocks' linker specification produce similar errors.

Any suggestions?


Solution

  • Looks like Code::Blocks is using the .o extension for object files on Windows, while the linker driver in the compiler frontend is probably expecting object files to have the .obj extension, which is more common on Windows.

    I'm not familiar with Code::Blocks or how it interfaces with D compilers, but you can try checking to see if it has a setting to control what extension is used for object files. This may be a bug (or, simply, lacking Windows support) in whatever code is responsible for building D compiler command lines in Code::Blocks.