Bug 19726 – Visual D does not link C standard library with D-only project

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
visuald
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2019-03-08T10:30:23Z
Last change time
2019-03-16T18:58:00Z
Keywords
industry
Assigned to
No Owner
Creator
Mihails Strasuns

Comments

Comment #0 by mihails.strasuns — 2019-03-08T10:30:23Z
NB: only affects vcxproj projects, not Visual D own project format. Steps to reproduce: - Create new project using mixed D/C++ template - Remove all C++ sources from the project At that point program will fail the linking stage. Adding dummy .cpp file to the project can be used a workaround to force necessary linker flags.
Comment #1 by r.sagitario — 2019-03-10T14:56:29Z
The default is not to add any C++ to the project and that works for me. Dmd adds the reference to the C runtime into the module that contains main, DllMain or WinMain. Are you using LDC instead? Or maybe your project doesn't include any of the functions above? You can also disable any C runtime reference by choosing "None" as the "C Runtime Library" in the D compiler options.
Comment #2 by mihails.strasuns — 2019-03-10T14:59:40Z
LDC is used. Not sure what do you refer to by disabling C runtime reference - it is needed for D standard library to work. the fact that it is not linked is exactly the problem. Being able to explicitly specify that it needs to be linked via vcxproj spec would also work just fine for me.
Comment #3 by kinke — 2019-03-10T21:02:07Z
Right, that's what I meant by the DMD behavior of embedding the MSVCRT lib references in the main object file sounding like a way to make MSBuild work. If there's no simple Visual D solution to this, we can implement it for LDC too.
Comment #4 by r.sagitario — 2019-03-11T07:45:45Z
Looks like I can fix that, Visual D already adds the D libraries to the linker command line. @Mihaels: I meant the "C Runtime Library" selector on the D compiler general page. It is hidden for the LDC compiler pages though, because it has no meaning so far. Current workaround is to add the library (e.g. libcmt.lib or msvcrt.lib) to the Additional Dependencies linker option.
Comment #5 by r.sagitario — 2019-03-16T18:58:00Z