digitalmars.D.learn - .di header imports with DLL symbols fails to link
- Andrej Mitrovic (15/15) Mar 12 2011 On Windows, x86.
- Bekenn (3/6) Mar 12 2011 Your dll is exporting a different symbol: _D5mydll3fooFiZi
- Daniel Green (5/11) Mar 12 2011 I believe _D5mydll12__ModuleInfoZ is supposed to be exported by the
- Andrej Mitrovic (4/4) Mar 12 2011 Actually passing that .di file compiles it in statically, and the exe
- Andrej Mitrovic (4/4) Mar 12 2011 My commands to compile were:
- Bekenn (11/15) Mar 12 2011 Thanks.
- Daniel Green (5/20) Mar 12 2011 Probably unrelated, but this same issue showed up in the GDC backend.
On Windows, x86. http://dl.dropbox.com/u/9218759/DLL_Imports.zip fail_build.bat runs: dmd driver.d mydll.lib -I%cd%\include\ but linking fails: driver.obj(driver) Error 42: Symbol Undefined _D5mydll12__ModuleInfoZ --- errorlevel 1 work_build.bat runs: dmd driver.d mydll.lib %cd%\include\mydll.di and this succeeds. So passing the .di file explicitly works, but via the import switch it does not. Here's a non-DLL example which works fine when using header files and an import switch: http://dl.dropbox.com/u/9218759/importsWorkUsually.zip So unless I'm missing something this looks like a linker bug?
Mar 12 2011
On 3/12/2011 5:24 PM, Andrej Mitrovic wrote:driver.obj(driver) Error 42: Symbol Undefined _D5mydll12__ModuleInfoZ --- errorlevel 1Your dll is exporting a different symbol: _D5mydll3fooFiZi Do you have the .def file and the command line used to build the DLL?
Mar 12 2011
On 3/12/2011 9:15 PM, Bekenn wrote:On 3/12/2011 5:24 PM, Andrej Mitrovic wrote:I believe _D5mydll12__ModuleInfoZ is supposed to be exported by the compiler. It contains static constructor and unittest information used by the runtime to initialize it.driver.obj(driver) Error 42: Symbol Undefined _D5mydll12__ModuleInfoZ --- errorlevel 1Your dll is exporting a different symbol: _D5mydll3fooFiZi Do you have the .def file and the command line used to build the DLL?
Mar 12 2011
Actually passing that .di file compiles it in statically, and the exe ends up not needing the DLL. It's a bit too late for me to thinker with the linker, I'll have a clearer head tomorrow.
Mar 12 2011
My commands to compile were: dmd -ofmydll.dll mydll.d dmd -o- -Hdinclude mydll.d dmd driver.d mydll.lib -I%cd%\include
Mar 12 2011
On 3/12/2011 7:02 PM, Andrej Mitrovic wrote:My commands to compile were: dmd -ofmydll.dll mydll.d dmd -o- -Hdinclude mydll.d dmd driver.d mydll.lib -I%cd%\includeThanks. I've tried several things, but can't get the _D5mydll12__ModuleInfoZ symbol to show up at all. The behavior is the same with and without a .def file (I tried a few versions). I even went back to http://www.digitalmars.com/d/2.0/dll.html and copied everything in the "D code calling D code in DLLs" section verbatim. After fixing a few compilation errors (the web page's version of concat needs its arguments qualified with "in"), I ended up with the exact same problem you're experiencing. I'd definitely call this a bug.
Mar 12 2011
On 3/12/2011 11:39 PM, Bekenn wrote:On 3/12/2011 7:02 PM, Andrej Mitrovic wrote:Probably unrelated, but this same issue showed up in the GDC backend. Apparently, the compiler tried to be smart about exporting ModuleInfo only for those modules that needed it. The fix was to always export it regardless.My commands to compile were: dmd -ofmydll.dll mydll.d dmd -o- -Hdinclude mydll.d dmd driver.d mydll.lib -I%cd%\includeThanks. I've tried several things, but can't get the _D5mydll12__ModuleInfoZ symbol to show up at all. The behavior is the same with and without a .def file (I tried a few versions). I even went back to http://www.digitalmars.com/d/2.0/dll.html and copied everything in the "D code calling D code in DLLs" section verbatim. After fixing a few compilation errors (the web page's version of concat needs its arguments qualified with "in"), I ended up with the exact same problem you're experiencing. I'd definitely call this a bug.
Mar 12 2011