0

Is there a way to link in mainCRTStartup without having Visual Studio installed? I have libcmt.lib in my Visual Studio installation, and that works fine for linking against on my computer. However, I would like to be able to build and link without having to have Visual Studio installed.

I am using Clang and LLD 9.0.0 on Windows 10.

Graznarak
  • 3,626
  • 4
  • 28
  • 47
  • vs is only integrated shell, convenient to use. it not need for compile/build/run any pe. – RbMm Dec 03 '19 at 18:41
  • That was my thought. However, I can't think of how to get away from having it installed other than rewriting mainCRTStartup (which I don't want to do). – Graznarak Dec 03 '19 at 18:44
  • for what you need Visual Studio installed ? only for get crt includes/src ? – RbMm Dec 03 '19 at 18:49
  • For a definition of mainCRTStartup. – Graznarak Dec 03 '19 at 18:50
  • how is VS related to definition ? – RbMm Dec 03 '19 at 18:58
  • @rbm: The runtime libraries are part of the language implementation. The language implementation is part of Visual Studio. – IInspectable Dec 03 '19 at 19:08
  • 3
    If you need the Visual C++ libraries, but do not want to install the full Visual Studio suite, you can download the [Build Tools for Visual Studio](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019) separately. – IInspectable Dec 03 '19 at 19:12
  • Why do you need to link in `mainCRTStartup`? What kind of C program is this? – the busybee Dec 03 '19 at 19:39
  • mainCRTStartup is the function called by Windows that eventually calls main. – Graznarak Dec 03 '19 at 19:49
  • 1
    That's incorrect. Windows calls whatever you specify as the `/ENTRYPOINT`. Microsoft's tooling uses one of the `*CRTStartup` functions, that set up the runtime environment before calling into the user-provided entry point. The raw entry point is an implementation detail of the language implementation. Clang may or may not use Microsoft's defaults on Windows. You'll have to investigate that. – IInspectable Dec 03 '19 at 20:17
  • I don't believe that clang provides an entry point implementation. It does compile and link to needing mainCRTStartup, which is the reason for the question. – Graznarak Dec 03 '19 at 20:25
  • Clang is a language implementation. The language runtime is part of the language implementation. Clang ships its own language runtime, but attempts to be [ABI compatible with MSVC](https://clang.llvm.org/docs/MSVCCompatibility.html), so you *can* link with MSVC's C and C++ runtimes. – IInspectable Dec 03 '19 at 21:14

0 Answers0