www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Undefined Symbol: ModuleInfo when Linking DLL Test Program

reply GeorgeToth <GEToth verizon.net> writes:
I am sure this a stupid mistake on my part.... I create a DLL Test0.dll from
the following
file (Test0.d):
module Test0;

import std.stdio;

class Test0
  int Test0( string ID0 )
      printf("<Test0: ID={%s}> ",ID0.ptr);
      return ID0.length+5;
 }  // export end

export Test0 instTest0() { return new Test0(); }
Lib listing shows the following symbols:
Publics by name		module
_D5Test05Test05Test0MFAyaZi      _D5Test05Test05Test0MFAyaZi
_D5Test09instTest0FZC5Test05Test0 _D5Test09instTest0FZC5Test05Test0

Publics by module


It seems everything exported properly.  I wrote the following Test Harness
module Test0h;

import Test0;
import std.stdio;

int main()
	Test0 t0 = instTest0();

	puts("Starting main()");
	auto tret = t0.Test0("Harness Test0h");
	printf("T0 Ret=%d\n",tret);
	puts("Ending main()");
	return 0;
with the following Import Definition file:
module Test0;

import std.stdio;

class Test0
    int Test0(string ID0);

Test0 instTest0();
Watching the compile in verbose mode I get the following with the concluding
binary    I:\Progs\dmd2\windows\bin\dmd.exe
version   v2.050
config    I:\Progs\dmd2\windows\bin\sc.ini
parse     Test0h
importall Test0h
import    object	(I:\Progs\dmd2\windows\bin\..\..\src\druntime\import\object.di)
import    Test0	(Test0.di)
import    std.stdio	(I:\Progs\dmd2\windows\bin\..\..\src\phobos\std\stdio.d)
import    core.stdc.stdio	(I:\Progs\dmd2\windows\bin\..\..\src\druntime\import\core
import    std.container	(I:\Progs\dmd2\windows\bin\..\..\src\phobos\std\container.d)
semantic  Test0h
semantic2 Test0h
semantic3 Test0h
code      Test0h
function  main
I:\Progs\dmd2\windows\bin\link.exe Test0h,,,"Test0.lib"+user32+kernel32/noi;
OPTLINK (R) for Win32  Release 8.00.8
Copyright (C) Digital Mars 1989-2010  All rights reserved.
 Error 42: Symbol Undefined _D5Test012__ModuleInfoZ

I can't get the Test0 to be recognized.  If I add it to the compile then of
course it works,
and runs properly, but that defeats the purpose of the DLL.  Can someone point
out my error?
Nov 23 2010
parent GeorgeToth <GEToth verizon.net> writes:
Found my own mistake:  In module Test0 the "import of std.stdio" caused
the error.  There was nothing in the exports which required elements of
std.stdio and somehow (don't know why) it caused ModuleInfo to be
incomplete or omitted.
Nov 24 2010