digitalmars.D.learn - ImportC question
- DLearner (20/20) Oct 28 Just trying ImportC under Windows 10:
- Richard (Rikki) Andrew Cattermole (4/4) Oct 28 https://github.com/dlang/dmd/blob/dbba866c71db5e1222a1b631b3e910f1a08117...
- DLearner (15/19) Oct 29 Thank you.
- Lance Bachmeier (10/19) Oct 29 I don't do much on Windows, so I was having trouble with getting
- DLearner (6/27) Oct 29 Thanks for the idea.
- ryuukk_ (3/34) Oct 29 you need to invoke that command inside this windoze stupid thing:
- DLearner (9/45) Oct 29 Similar message from Powershell:
- Lance Bachmeier (3/49) Oct 29 It might be a bug so create an issue. It's hard to see how it's
- Richard (Rikki) Andrew Cattermole (1/1) Oct 29 https://issues.dlang.org/show_bug.cgi?id=24308
- Lance Bachmeier (4/5) Oct 29 I guess that explains why I've never run into the issue - I've
- Dennis (12/15) Oct 29 Whether it's CMD/Powershell isn't important, but it has to have
- Richard (Rikki) Andrew Cattermole (7/33) Oct 29 Don't add cl.exe directly to your PATH variable, there are other stuff
- Salih Dincer (3/21) Oct 29 DMD Compiler version?
- DLearner (5/29) Oct 29 ```
- ryuukk_ (3/33) Oct 30 update your compiler, latest version is: 2.109.1
- DLearner (27/62) Oct 30 Now upgraded.
- ryuukk_ (2/68) Oct 30 why X86 brother, pick the developper prompt for X64
- Salih Dincer (10/18) Oct 31 First of all, be sure to get rid of that old version because a
Just trying ImportC under Windows 10: ``` #include <stdio.h> int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fihello.i Error: C preprocess command cl.exe failed for file hello.c, exit status 1 ``` Any ideas? Best regards
Oct 28
https://github.com/dlang/dmd/blob/dbba866c71db5e1222a1b631b3e910f1a0811732/compiler/src/dmd/link.d#L1332 cl.exe comes from Visual Studio (MSVC). If you haven't got it installed, that'll be why. Otherwise its related to dmd not being able to find it.
Oct 28
On Tuesday, 29 October 2024 at 00:10:17 UTC, Richard (Rikki) Andrew Cattermole wrote:https://github.com/dlang/dmd/blob/dbba866c71db5e1222a1b631b3e910f1a0811732/compiler/src/dmd/link.d#L1332 cl.exe comes from Visual Studio (MSVC). If you haven't got it installed, that'll be why. Otherwise its related to dmd not being able to find it.Thank you. I installed Visual Studio 2022, proved the existence of cl.exe, and added the location to the search path. However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command cl.exe failed for file hello.c, exit status 2 ``` which looks like dmd found cl.exe, but did not supply it with all the data it required.
Oct 29
On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote:However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command cl.exe failed for file hello.c, exit status 2 ``` which looks like dmd found cl.exe, but did not supply it with all the data it required.I don't do much on Windows, so I was having trouble with getting the VS stuff installed correctly. I borrowed this command from the Swift installation guide and everything worked: ``` winget install --id Microsoft.VisualStudio.2022.Community --exact --force --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ```
Oct 29
On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier wrote:On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote:Thanks for the idea. The winget installation completed without issues. Unfortunately, 'dmd hello.c' produced the same error message as before.However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command cl.exe failed for file hello.c, exit status 2 ``` which looks like dmd found cl.exe, but did not supply it with all the data it required.I don't do much on Windows, so I was having trouble with getting the VS stuff installed correctly. I borrowed this command from the Swift installation guide and everything worked: ``` winget install --id Microsoft.VisualStudio.2022.Community --exact --force --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ```
Oct 29
On Tuesday, 29 October 2024 at 15:14:24 UTC, DLearner wrote:On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier wrote:you need to invoke that command inside this windoze stupid thing: https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote:Thanks for the idea. The winget installation completed without issues. Unfortunately, 'dmd hello.c' produced the same error message as before.However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command cl.exe failed for file hello.c, exit status 2 ``` which looks like dmd found cl.exe, but did not supply it with all the data it required.I don't do much on Windows, so I was having trouble with getting the VS stuff installed correctly. I borrowed this command from the Swift installation guide and everything worked: ``` winget install --id Microsoft.VisualStudio.2022.Community --exact --force --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ```
Oct 29
On Tuesday, 29 October 2024 at 15:49:13 UTC, ryuukk_ wrote:On Tuesday, 29 October 2024 at 15:14:24 UTC, DLearner wrote:Similar message from Powershell: ``` PS C:\Users\SoftDev\Documents\BDM\projects\it\c> dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\cl.exe failed for file hello.c, exit status 2 ```On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier wrote:you need to invoke that command inside this windoze stupid thing: https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote:Thanks for the idea. The winget installation completed without issues. Unfortunately, 'dmd hello.c' produced the same error message as before.However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command cl.exe failed for file hello.c, exit status 2 ``` which looks like dmd found cl.exe, but did not supply it with all the data it required.I don't do much on Windows, so I was having trouble with getting the VS stuff installed correctly. I borrowed this command from the Swift installation guide and everything worked: ``` winget install --id Microsoft.VisualStudio.2022.Community --exact --force --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ```
Oct 29
On Tuesday, 29 October 2024 at 16:14:22 UTC, DLearner wrote:On Tuesday, 29 October 2024 at 15:49:13 UTC, ryuukk_ wrote:It might be a bug so create an issue. It's hard to see how it's not.On Tuesday, 29 October 2024 at 15:14:24 UTC, DLearner wrote:Similar message from Powershell: ``` PS C:\Users\SoftDev\Documents\BDM\projects\it\c> dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\cl.exe failed for file hello.c, exit status 2 ```On Tuesday, 29 October 2024 at 12:42:49 UTC, Lance Bachmeier wrote:you need to invoke that command inside this windoze stupid thing: https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022On Tuesday, 29 October 2024 at 12:23:06 UTC, DLearner wrote:Thanks for the idea. The winget installation completed without issues. Unfortunately, 'dmd hello.c' produced the same error message as before.However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command cl.exe failed for file hello.c, exit status 2 ``` which looks like dmd found cl.exe, but did not supply it with all the data it required.I don't do much on Windows, so I was having trouble with getting the VS stuff installed correctly. I borrowed this command from the Swift installation guide and everything worked: ``` winget install --id Microsoft.VisualStudio.2022.Community --exact --force --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22000 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64" ```
Oct 29
On Tuesday, 29 October 2024 at 18:17:37 UTC, Richard (Rikki) Andrew Cattermole wrote:https://issues.dlang.org/show_bug.cgi?id=24308I guess that explains why I've never run into the issue - I've been using LDC but not DMD on Windows.
Oct 29
On Tuesday, 29 October 2024 at 16:14:22 UTC, DLearner wrote:On Tuesday, 29 October 2024 at 15:49:13 UTC, ryuukk_ wrote:Whether it's CMD/Powershell isn't important, but it has to have the Visual Studio environment set up. Do you see this text in the shell when you launch it? ``` ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.11.5 ** Copyright (c) 2022 Microsoft Corporation ********************************************************************** ``` If not, try to search "Developer Command Prompt for VS" in your start menu.https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022Similar message from Powershell:
Oct 29
On 30/10/2024 1:23 AM, DLearner wrote:On Tuesday, 29 October 2024 at 00:10:17 UTC, Richard (Rikki) Andrew Cattermole wrote:Don't add cl.exe directly to your PATH variable, there are other stuff in the environment variables that has to be setup for it to operate (sigh). If dmd can't find it, via the VS lookup and get it working, you'll need to as ryuukk said, run dmd inside of cmd prompt that has the Visual Studio tools batch script run in it. Found in your start menu under Visual Studio (version).https://github.com/dlang/dmd/blob/ dbba866c71db5e1222a1b631b3e910f1a0811732/compiler/src/dmd/link.d#L1332 cl.exe comes from Visual Studio (MSVC). If you haven't got it installed, that'll be why. Otherwise its related to dmd not being able to find it.Thank you. I installed Visual Studio 2022, proved the existence of cl.exe, and added the location to the search path. However, there is still a problem: ``` dmd hello.c C:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h(134): fatal error C1034: sal.h: no include path set Error: C preprocess command cl.exe failed for file hello.c, exit status 2 ``` which looks like dmd found cl.exe, but did not supply it with all the data it required.
Oct 29
On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote:Just trying ImportC under Windows 10: ```c #include <stdio.h> int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fihello.i Error: C preprocess command cl.exe failed for file hello.c, exit status 1 ```DMD Compiler version? SDB 79
Oct 29
On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote:On Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote:``` C:\Users\SoftDev>dmd DMD64 D Compiler v2.106.0-dirty ```Just trying ImportC under Windows 10: ```c #include <stdio.h> int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fihello.i Error: C preprocess command cl.exe failed for file hello.c, exit status 1 ```DMD Compiler version? SDB 79
Oct 29
On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote:On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote:update your compiler, latest version is: 2.109.1 then, and only then you can start wondering what's brokenOn Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote:``` C:\Users\SoftDev>dmd DMD64 D Compiler v2.106.0-dirty ```Just trying ImportC under Windows 10: ```c #include <stdio.h> int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fihello.i Error: C preprocess command cl.exe failed for file hello.c, exit status 1 ```DMD Compiler version? SDB 79
Oct 30
On Wednesday, 30 October 2024 at 09:21:55 UTC, ryuukk_ wrote:On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote:Now upgraded. 1. I noticed that the installation process also installed _both_ Visual Studio 2019 _and_ Visual Studio 2022. Is one of these preferred? 2. With 2019: ``` C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>dmd C:\Users\SoftDev\Documents\BDM\Projects\IT\C\hello.c C:\Program Files (x86)\Microsoft Visual Studio\2019\Community> ``` ie silence (and no 'hello' files produced either). 3. With 2022: ``` C:\Program Files\Microsoft Visual Studio\2022\Community>dmd C:\Users\SoftDev\Documents\BDM\Projects\IT\C\hello.c C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared\driverspecs.h(381): warning C4005: '_Kernel_acquires_resource_': macro redefinition C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared\no_sal2.h(876): note: see previous definition of '_Kernel_acquires_resource_' C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared\driverspecs.h(391): warning C4005: '_Kernel_releases_resource_': macro redefinition ``` and a large number of similar messages.On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote:update your compiler, latest version is: 2.109.1 then, and only then you can start wondering what's brokenOn Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote:``` C:\Users\SoftDev>dmd DMD64 D Compiler v2.106.0-dirty ```Just trying ImportC under Windows 10: ```c #include <stdio.h> int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fihello.i Error: C preprocess command cl.exe failed for file hello.c, exit status 1 ```DMD Compiler version? SDB 79
Oct 30
On Wednesday, 30 October 2024 at 15:17:56 UTC, DLearner wrote:On Wednesday, 30 October 2024 at 09:21:55 UTC, ryuukk_ wrote:why X86 brother, pick the developper prompt for X64On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote:Now upgraded. 1. I noticed that the installation process also installed _both_ Visual Studio 2019 _and_ Visual Studio 2022. Is one of these preferred? 2. With 2019: ``` C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>dmd C:\Users\SoftDev\Documents\BDM\Projects\IT\C\hello.c C:\Program Files (x86)\Microsoft Visual Studio\2019\Community> ``` ie silence (and no 'hello' files produced either). 3. With 2022: ``` C:\Program Files\Microsoft Visual Studio\2022\Community>dmd C:\Users\SoftDev\Documents\BDM\Projects\IT\C\hello.c C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared\driverspecs.h(381): warning C4005: '_Kernel_acquires_resource_': macro redefinition C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared\no_sal2.h(876): note: see previous definition of '_Kernel_acquires_resource_' C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\shared\driverspecs.h(391): warning C4005: '_Kernel_releases_resource_': macro redefinition ``` and a large number of similar messages.On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote:update your compiler, latest version is: 2.109.1 then, and only then you can start wondering what's brokenOn Monday, 28 October 2024 at 20:56:03 UTC, DLearner wrote:``` C:\Users\SoftDev>dmd DMD64 D Compiler v2.106.0-dirty ```Just trying ImportC under Windows 10: ```c #include <stdio.h> int main() { printf("Hello world.\n"); return 0; } ``` Produces ``` dmd hello.c failed launching cl.exe /P /Zc:preprocessor /PD /nologo hello.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fihello.i Error: C preprocess command cl.exe failed for file hello.c, exit status 1 ```DMD Compiler version? SDB 79
Oct 30
On Tuesday, 29 October 2024 at 20:26:58 UTC, DLearner wrote:On Tuesday, 29 October 2024 at 18:57:15 UTC, Salih Dincer wrote:First of all, be sure to get rid of that old version because a lot has changed since that version. There's no harm in having different VSlibs installed. The main problem is that Windows is crap. The address of the solution is: MSYS2. It's simple to install it on your computer and use it safely. Look, there are videos on this subject, here is one of them: https://youtu.be/OwQobefF-iE?si=QN8sp5SknSROXY83 Yes, now your problems will be solved, insha'Allah SDB 79DMD Compiler version? SDB 79``` C:\Users\SoftDev>dmd DMD64 D Compiler v2.106.0-dirty ```
Oct 31