digitalmars.D.learn - ImportC issue?
- DLearner (25/25) Apr 19 2023 C source ex01.c:
- Richard (Rikki) Andrew Cattermole (2/2) Apr 19 2023 Yeah cl is the MSVC compiler being used for preprocessing.
- bachmeier (3/29) Apr 19 2023 Did you use the switch `-m32omf`?
- DLearner (31/33) Apr 19 2023 No so following the references I tried every preprocessor option
- Richard (Rikki) Andrew Cattermole (4/5) Apr 19 2023 Did you verify that sppn is accessible in that shell?
- DLearner (8/14) Apr 19 2023 SPPN.exe not visible from that command prompt, but neither (using
- Richard (Rikki) Andrew Cattermole (4/6) Apr 19 2023 It is not an essential component of dmd.
- bachmeier (5/22) Apr 19 2023 My understanding (from my occasional use of Windows) is that DMD
- DLearner (45/49) Apr 19 2023 Well it took a little while, but I can confirm that if you have a
C source ex01.c: ``` #include <stdio.h> int main() { printf("hello world\n"); return 0; } ``` 'dmc ex01.c' produces message: ``` link ex01,,,user32+kernel32/noi; ``` but does generate .obj, .map and .exe files, and the exe executes properly. However, trying to use ImportC via 'dmd ex01.c' produces messages: ``` failed launching cl.exe /P /Zc:preprocessor /PD /nologo ex01.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fiex01.i Error: C preprocess command cl.exe failed for file ex01.c, exit status 1 ``` This behaviour was repeated after a complete fresh re-installation of dmd & dmc from the website.
Apr 19 2023
Yeah cl is the MSVC compiler being used for preprocessing. So for whatever reason its not using dmc, hence the error.
Apr 19 2023
On Wednesday, 19 April 2023 at 10:21:22 UTC, DLearner wrote:C source ex01.c: ``` #include <stdio.h> int main() { printf("hello world\n"); return 0; } ``` 'dmc ex01.c' produces message: ``` link ex01,,,user32+kernel32/noi; ``` but does generate .obj, .map and .exe files, and the exe executes properly. However, trying to use ImportC via 'dmd ex01.c' produces messages: ``` failed launching cl.exe /P /Zc:preprocessor /PD /nologo ex01.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fiex01.i Error: C preprocess command cl.exe failed for file ex01.c, exit status 1 ``` This behaviour was repeated after a complete fresh re-installation of dmd & dmc from the website.Did you use the switch `-m32omf`? https://dlang.org/spec/importc.html#auto-cpp
Apr 19 2023
On Wednesday, 19 April 2023 at 11:50:28 UTC, bachmeier wrote: [...]Did you use the switch `-m32omf`? https://dlang.org/spec/importc.html#auto-cppNo so following the references I tried every preprocessor option I could find: ``` C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -m32omf failed launching sppn.exe ex01.c -HIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h -ED -oex01.i Error: C preprocess command sppn.exe failed for file ex01.c, exit status 1 C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -c -m32omf failed launching sppn.exe ex01.c -HIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h -ED -oex01.i Error: C preprocess command sppn.exe failed for file ex01.c, exit status 1 C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -c -m32mscoff failed launching cl.exe /P /Zc:preprocessor /PD /nologo ex01.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fiex01.i Error: C preprocess command cl.exe failed for file ex01.c, exit status 1 C:\Users\SoftDev\Documents\BDM\D\ImportC>dmd ex01.c -c -m64 failed launching cl.exe /P /Zc:preprocessor /PD /nologo ex01.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fiex01.i Error: C preprocess command cl.exe failed for file ex01.c, exit status 1 ``` Unfortunately all options failed.
Apr 19 2023
On 20/04/2023 12:07 AM, DLearner wrote:Error: C preprocess command sppn.exe failed for file ex01.c, exit status 1Did you verify that sppn is accessible in that shell? As in run it, can it be found? If not its just a PATH variable issue.
Apr 19 2023
On Wednesday, 19 April 2023 at 12:09:44 UTC, Richard (Rikki) Andrew Cattermole wrote:On 20/04/2023 12:07 AM, DLearner wrote:SPPN.exe not visible from that command prompt, but neither (using File Explorer) anywhere on the C: drive (lots of SPPNP.DLL's, in various Windows locations). If SPPN.exe essential to a component of DMD, was it not downloaded with it (and PATH modified to point to it), by the installer?Error: C preprocess command sppn.exe failed for file ex01.c, exit status 1Did you verify that sppn is accessible in that shell? As in run it, can it be found? If not its just a PATH variable issue.
Apr 19 2023
On 20/04/2023 1:11 AM, DLearner wrote:If SPPN.exe essential to a component of DMD, was it not downloaded with it (and PATH modified to point to it), by the installer?It is not an essential component of dmd. It is one option in the usage of an experimental feature inside of dmd that is not ready for general use.
Apr 19 2023
On Wednesday, 19 April 2023 at 13:11:45 UTC, DLearner wrote:On Wednesday, 19 April 2023 at 12:09:44 UTC, Richard (Rikki) Andrew Cattermole wrote:My understanding (from my occasional use of Windows) is that DMD installs the Community Edition of Visual Studio. That should solve your original issue, and you shouldn't need to mess with sppn.exe.On 20/04/2023 12:07 AM, DLearner wrote:SPPN.exe not visible from that command prompt, but neither (using File Explorer) anywhere on the C: drive (lots of SPPNP.DLL's, in various Windows locations). If SPPN.exe essential to a component of DMD, was it not downloaded with it (and PATH modified to point to it), by the installer?Error: C preprocess command sppn.exe failed for file ex01.c, exit status 1Did you verify that sppn is accessible in that shell? As in run it, can it be found? If not its just a PATH variable issue.
Apr 19 2023
On Wednesday, 19 April 2023 at 14:42:44 UTC, bachmeier wrote: [...]My understanding (from my occasional use of Windows) is that DMD installs the Community Edition of Visual Studio. That should solve your original issue, and you shouldn't need to mess with sppn.exe.Well it took a little while, but I can confirm that if you have a D function like: ``` extern(C) void DCallee() { import core.stdc.stdio : printf; printf("Entered DCallee.\n"); printf("Exiting DCallee.\n"); } ``` called from a C function like: ``` // C Master calling D (under -betterC restrictions). #include <stdio.h> extern void DCallee(); int main() { printf("MastC Entered.\n"); DCallee(); printf("MastC Exiting.\n"); return 0; } ``` Where the compilation is run from the batch file: ``` Rem Compile, link and run batch file. IF EXIST .\DCallee.exe del .\DCallee.exe IF EXIST .\DCallee.map del .\DCallee.map IF EXIST .\DCallee.obj del .\DCallee.obj IF EXIST .\MastC.exe del .\MastC.exe IF EXIST .\MastC.map del .\MastC.map IF EXIST .\MastC.obj del .\MastC.obj dmd -m32omf -betterC -c DCallee.d dmc MastC.c DCallee.obj MastC.exe Rem Exited compile, link and run batch file. ``` Then everything runs properly. As an aside, it was a surprise to me to discover that the order of the file names in the dmc line was significant, bearing in mind MastC.c contains a 'main' function, and DCallee.d does not. As a further aside, I do recall the installer loading Visual Studio, but it didn't seem to help.
Apr 19 2023