Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6969093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:32:14+00:00 2026-05-27T16:32:14+00:00

Linking the following two files gives me a link-error: a.d: import std.stdio; extern string

  • 0

Linking the following two files gives me a link-error:

a.d:

import std.stdio;

extern string test ();

void main() {
    writeln(test());
    readln();
}

b.d:

string test () {
    return "hello";
}

the error I get is:

Error 42: Symbol Undefined _D1a4testFZAya`

---errorlevel 1

What is wrong ?

_________________________________________________

Edit: this is the right way to do it:

a.d:

import std.stdio;
import b;

void main() {
   writeln("some_var from Module b: \"", b.some_var, "\"");
}

b.d:

public string some_var = "Hello, world!";

//you can also use static module constructors to set your vars
static this() {
   some_var ~= " -- How are you?";
}

That code was kindly provided by Joshua Reusch in the excellent D forum for beginners in the digitalmars.com site.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:32:15+00:00Added an answer on May 27, 2026 at 4:32 pm

    Modify your a.d to:

    import std.stdio;
    import b;
    
    //extern string test ();
    
    void main() {
      writeln(test());
      readln();
    }
    

    extern is a linkage attribute and is mostly used to specify what calling convention to use for the given function (typically a C function in some library). More about extern and other attributes here: http://www.d-programming-language.org/attribute.html . If all you have are D source files, there is really no need for extern. However, if you mix C or C++ and D code, you will definitely have to use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I resolve the following linking error: LINK : fatal error LNK1561: entry
In linking a sports event to two teams, at first this seemed to make
//deep linking $(document).ready(function(){ contM = $('#main-content'); contS = $('#second-content'); $(contM).hide(); $(contM).addClass('hidden'); $(contS).hide(); $(contS).addClass('hidden'); function
How does the following example usage of extern specifer behave. We have a global
I'm trying to link two tables. I want a user on my site to
I've made a general hash up of the following function. Basically linking this function
I would like two how to do to share Resources files between 2 (or
I have the following files: Child.c , Cookie.c , Cookie.h , CookieMonster.c , Jar.c
I have a page app/views/shared/_tcpsocket.html.erb and am trying to include the following two javscripts:
The following two programs differ only by the strictness flag on variable st $

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.