digitalmars.D - DMD - issue building shared library
- Dibyendu Majumdar (49/49) Jan 17 2016 Hi
- bitwise (8/10) Jan 17 2016 _DllMainCRTStartup:
- Dibyendu Majumdar (4/13) Jan 17 2016 Ok thanks - wasn't aware of that. Presumably there is no compiler
- bitwise (5/6) Jan 17 2016 There's no compiler flag, but you can use this:
- Dibyendu Majumdar (9/15) Jan 18 2016 Thanks - that worked, but I had to write it this way:
- Dibyendu Majumdar (3/9) Jan 18 2016 Sorry meant to say 'not' documented.
- bitwise (9/21) Jan 18 2016 Well..I think the docs are far from complete. It's an ongoing
Hi I have an existing C shared library that I am trying to link to a D shared library. The D shared library at present only has a binding (extern (C)) definition, nothing else. When I try to create the shared library using the DMD command line I get link errors. Platform is Windows 10 64-bit. The command I am using is: dmd -m64 -shared -v -L/LIBPATH:c:\ravi\lib -Lravimatrix.lib source\matrix.d Partial output from DMD follows: binary C:\D\dmd2\windows\bin\dmd.exe version v2.069.2 config C:\D\dmd2\windows\bin\sc.ini parse matrix importall Dmatrix import object (C:\D\dmd2\windows\bin\..\..\src\druntime\import\object.d) import std.stdint (C:\D\dmd2\windows\bin\..\..\src\phobos\std\stdint.d) import core.stdc.stdint (C:\D\dmd2\windows\bin\..\..\src\druntime\import\core\stdc\stdint.d) ... import core.stdc.string (C:\D\dmd2\windows\bin\..\..\src\druntime\import\core\stdc\string.d) semantic2 Dmatrix semantic3 Dmatrix code Dmatrix C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\bin\x86_amd64\link.exe /NOLOGO matrix /DLL /LIBPATH:c:\ravi\lib ravimatrix.lib /OPT:NOICF /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\lib\amd64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.1\\lib\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\\lib\10.0.10240.0\ucrt\x64" legacy_stdio_definitions.lib matrix.obj : error LNK2001: unresolved external symbol _D3std5stdio12__ModuleInfoZ matrix.obj : error LNK2001: unresolved external symbol _D15TypeInfo_Struct6__vtblZ matrix.obj : error LNK2019: unresolved external symbol _d_assert referenced in function _D7Dmatrix8__assertFiZv matrix.obj : error LNK2019: unresolved external symbol _d_unittest referenced in function _D7Dmatrix15__unittest_failFiZv matrix.obj : error LNK2019: unresolved external symbol _d_arraybounds referenced in function _D7Dmatrix7__arrayZ LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup matrix.dll : fatal error LNK1120: 6 unresolved externals --- errorlevel 1120
Jan 17 2016
On Sunday, 17 January 2016 at 16:10:01 UTC, Dibyendu Majumdar wrote:LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup_DllMainCRTStartup: D shared libs on windows still require a DllMain. If you follow this post here[1] to create one, it should solve some of your problem. [1] http://wiki.dlang.org/Win32_DLLs_in_D Bit
Jan 17 2016
On Sunday, 17 January 2016 at 19:10:16 UTC, bitwise wrote:On Sunday, 17 January 2016 at 16:10:01 UTC, Dibyendu Majumdar wrote:Ok thanks - wasn't aware of that. Presumably there is no compiler flag to auto generate this? RegardsLINK : error LNK2001: unresolved external symbol _DllMainCRTStartup_DllMainCRTStartup: D shared libs on windows still require a DllMain. If you follow this post here[1] to create one, it should solve some of your problem. [1] http://wiki.dlang.org/Win32_DLLs_in_D
Jan 17 2016
On Sunday, 17 January 2016 at 22:12:44 UTC, Dibyendu Majumdar wrote:Presumably there is no compiler flag to auto generate this?There's no compiler flag, but you can use this: https://github.com/D-Programming-Language/druntime/blob/master/src/core/sys/windows/dll.d#L473 Bit
Jan 17 2016
On Monday, 18 January 2016 at 05:58:38 UTC, bitwise wrote:On Sunday, 17 January 2016 at 22:12:44 UTC, Dibyendu Majumdar wrote:Thanks - that worked, but I had to write it this way: import std.c.windows.windows; import core.sys.windows.dll; mixin SimpleDllMain; I noticed that above modules are documented in the library reference so I assume that this template is not supported? Regards DibyenduPresumably there is no compiler flag to auto generate this?There's no compiler flag, but you can use this: https://github.com/D-Programming-Language/druntime/blob/master/src/core/sys/windows/dll.d#L473 Bit
Jan 18 2016
On Monday, 18 January 2016 at 23:53:45 UTC, Dibyendu Majumdar wrote:Thanks - that worked, but I had to write it this way: import std.c.windows.windows; import core.sys.windows.dll; mixin SimpleDllMain; I noticed that above modules are documented in the library reference so I assume that this template is not supported?Sorry meant to say 'not' documented.
Jan 18 2016
On Monday, 18 January 2016 at 23:55:33 UTC, Dibyendu Majumdar wrote:On Monday, 18 January 2016 at 23:53:45 UTC, Dibyendu Majumdar wrote:Well..I think the docs are far from complete. It's an ongoing task to try and get them to where they need to be. Worst case scenario, is that someone removes that template, at which point you can simply go back in history on github and copy paste it into your own file. I don't see any reason that it would be removed though. BitThanks - that worked, but I had to write it this way: import std.c.windows.windows; import core.sys.windows.dll; mixin SimpleDllMain; I noticed that above modules are documented in the library reference so I assume that this template is not supported?Sorry meant to say 'not' documented.
Jan 18 2016