Thread overview
Can't compile with ldc in termux
Aug 11, 2021
_ZZ_ZZ_ZZ
Aug 11, 2021
Paul Backus
Aug 11, 2021
_ZZ_ZZ_ZZ
Aug 11, 2021
jfondren
Aug 11, 2021
_ZZ_ZZ_ZZ
Aug 11, 2021
jfondren
Aug 11, 2021
jfondren
Aug 11, 2021
_ZZ_ZZ_ZZ
August 11, 2021

After having downloaded ldc in Termux, i have tried to create an example script (obviously, D-program) and after having compiled it, it gives an error.

$ vim example_program.d
$ ldc2 example_program.d
clang-12: error: invalid linker name in argument '-fuse-ld=bfd'
Error: /data/data/com.termux/files/usr/bin/cc failed with status: 1

The example file contains...

void main() {
    import std.stdio : writeln;
    writeln("Hello, world!");
}

I don't know what is the problem :( The device is arch armv71.
But I need help, please!

August 11, 2021

On Wednesday, 11 August 2021 at 17:17:23 UTC, _ZZ_ZZ_ZZ wrote:

>

After having downloaded ldc in Termux, i have tried to create an example script (obviously, D-program) and after having compiled it, it gives an error.

$ vim example_program.d
$ ldc2 example_program.d
clang-12: error: invalid linker name in argument '-fuse-ld=bfd'
Error: /data/data/com.termux/files/usr/bin/cc failed with status: 1

The example file contains...

void main() {
    import std.stdio : writeln;
    writeln("Hello, world!");
}

I don't know what is the problem :( The device is arch armv71.
But I need help, please!

Looks like the same problem as this thread:

https://forum.dlang.org/thread/bdfkqekglpkkxsmtjvek@forum.dlang.org

Maybe try compiling with --linker= (nothing after the = sign) and see if that helps?

August 11, 2021

On Wednesday, 11 August 2021 at 18:20:13 UTC, Paul Backus wrote:

>

Maybe try compiling with --linker= (nothing after the = sign) and see if that helps?

YOU ARE MY HERO!!!
it works, and it's great!

But in any case ... Can i configure the compiler to automatically execute the --linker = flag?

August 11, 2021

On Wednesday, 11 August 2021 at 18:46:44 UTC, _ZZ_ZZ_ZZ wrote:

>

On Wednesday, 11 August 2021 at 18:20:13 UTC, Paul Backus wrote:

>

Maybe try compiling with --linker= (nothing after the = sign) and see if that helps?

YOU ARE MY HERO!!!
it works, and it's great!

But in any case ... Can i configure the compiler to automatically execute the --linker = flag?

confirm the location of ldc2.conf with ldc2 -v, then edit that file. Mine was at ../usr/etc/ldc2.conf (relative to $HOME)

August 11, 2021

On Wednesday, 11 August 2021 at 18:58:16 UTC, jfondren wrote:

>

confirm the location of ldc2.conf with ldc2 -v, then edit that file. Mine was at ../usr/etc/ldc2.conf (relative to $HOME)

Mine was at /data/data/com.termux/files/usr/etc/ldc2.conf too.
Now, the file contains:

$ cat ldc2.conf
// See comments in driver/config.d in ldc source tree for grammar description of
// this config file.

// For cross-compilation, you can add sections for specific target triples by
// naming the sections as (quoted) regex patterns. See LDC's -v output
// (config line) to figure out your normalized triple, depending on the used
// -mtriple, -m32 etc. E.g.:
//
//     "^arm.*-linux-gnueabihf$": { … };
//     "86(_64)?-.*-linux": { … };
//     "i[3-6]86-.*-windows-msvc": { … };
//
// Later sections take precedence and override settings from previous matching
// sections while inheriting unspecified settings from previous sections.
// A default section always matches (treated as ".*") and is therefore usually
// the first section.
default:
{
    // default switches injected before all explicit command-line switches
    switches = [
        "-defaultlib=phobos2-ldc,druntime-ldc",
        "-link-defaultlib-shared=false",
    ];
    // default switches appended after all explicit command-line switches
    post-switches = [
        "-I%%ldcbinarypath%%/../include/d",
    ];
    // default directories to be searched for libraries when linking
    lib-dirs = [
        "%%ldcbinarypath%%/../lib",
    ];
    // default rpath when linking against the shared default libs
    rpath = "";
};

"^wasm(32|64)-":
{
    switches = [
        "-defaultlib=",
        "-L--export-dynamic",
    ];
    lib-dirs = [];
};

But... Now, what i do? :(
(Yes, i'm a beginner)

August 11, 2021

On Wednesday, 11 August 2021 at 19:10:09 UTC, _ZZ_ZZ_ZZ wrote:

>

On Wednesday, 11 August 2021 at 18:58:16 UTC, jfondren wrote:

>

confirm the location of ldc2.conf with ldc2 -v, then edit that file. Mine was at ../usr/etc/ldc2.conf (relative to $HOME)

Mine was at /data/data/com.termux/files/usr/etc/ldc2.conf too.
Now, the file contains:
...
But... Now, what i do? :(
(Yes, i'm a beginner)

default:
{
    switches = [
        "-defaultlib=phobos2-ldc,druntime-ldc",
        "-link-defaultlib-shared=false",
        "-linker=", // <-- add this
    ];
August 11, 2021

On Wednesday, 11 August 2021 at 19:16:25 UTC, jfondren wrote:
With two dashes:

>
default:
{
    switches = [
        "-defaultlib=phobos2-ldc,druntime-ldc",
        "-link-defaultlib-shared=false",
        "--linker=", // <-- add this
    ];
August 11, 2021

On Wednesday, 11 August 2021 at 19:17:40 UTC, jfondren wrote:

>

On Wednesday, 11 August 2021 at 19:16:25 UTC, jfondren wrote:
With two dashes:

>
default:
{
    switches = [
        "-defaultlib=phobos2-ldc,druntime-ldc",
        "-link-defaultlib-shared=false",
        "--linker=", // <-- add this
    ];

THANK YOU VERY MUCH!!!
Now i can program in this beautiful language! :D

Thank you so much @Paul Backus too :D