-lib question(s)

Joshua Niehus jm.niehus at gmail.com
Fri Apr 27 22:37:19 PDT 2012


Hello,

I have a few methods that I want to put into a library but I'm 
having some trouble figuring out how to go about doing it...

Here is my "library":
// world.d
module world;
import std.traits;
T hello(T)(T name) /* probably want a string constraint here... 
*/ {
   return "hello " ~ name;
}
string hello2(string name) {
   return "hello " ~ name;
}

I put this file into one of my import paths (in dmd.conf) and use 
it as follows:
// testworld.d
import std.stdio, world;
void main() {
   writeln(hello("josh"));
   //writeln(hello2("josh")); // error: undefined symbol - name 
mangle of world_hello2
}

Q1) The template version of hello seems to work, but the 
simpleton version doesn't. What am i missing?

Q2) Shouldn't I be compiling world.d with -lib and then put 
world.a in some linker directory? I did that but got nowhere 
fast.  Basically I have my .a file and a bunch of lame scripts 
that need to use functions from it, its in a -L dir listed in my 
dmd.conf, but nothing compiles.

Thanks,
Josh


More information about the Digitalmars-d-learn mailing list