digitalmars.D.learn - Include .def definition file information for the linker into a .d
- BoQsc (23/23) Nov 24 2021 I'm not sure if I have sucessfully achieved something like this
- Adam D Ruppe (2/5) Nov 24 2021 https://dlang.org/spec/pragma.html#linkerDirective
- Adam D Ruppe (9/10) Nov 24 2021 example from my stuff:
- BoQsc (10/15) Nov 24 2021 The many times I tried this pragma, it did not even get
- Adam D Ruppe (5/7) Nov 24 2021 You need to use `dmd -m32mscoff` or `dmd -m64`. Plain `dmd` won't
- BoQsc (13/20) Nov 24 2021 Thanks, seems to work now.
- BoQsc (12/15) Nov 24 2021 It probably has to do something with the default target of dmd
- Imperatorn (3/25) Nov 24 2021 Just a quick question before going deeper. Why do you not want to
- BoQsc (4/5) Nov 24 2021 https://dlang.org/spec/pragma.html#linkerDirective
- Imperatorn (4/28) Nov 25 2021 What most ppl do in that case is to just provide a script, for
- Stanislav Blinov (9/12) Nov 25 2021 "How can I make it so that I don't need an extra file written in
- Imperatorn (5/17) Nov 25 2021 Scalable or not it's a pretty common pattern. The build script is
I'm not sure if I have sucessfully achieved something like this before or is it even possible right now, but there is a sample file that comes with DMD compiler: `D\dmd2\samples\d\winsamp.d` **The problem:** `winsamp.d` have to be compiled with `.def` file. ``` /+ Compile with: + dmd winsamp winsamp.def + or: + dmd winsamp -L-Subsystem:Windows + + 64 bit version: + dmd -m64 winsamp -L-Subsystem:Windows user32.lib +/ ``` This is how the `.def` file looks like (`D\dmd2\samples\d\winsamp.def`): ``` EXETYPE NT SUBSYSTEM WINDOWS ``` **The question:** Is there a way to include the `.def` file instructions inside `.d` file, so that there won't be a need for additional `.def` file when compiling. (`dmd winsamp`)
Nov 24 2021
On Wednesday, 24 November 2021 at 17:06:21 UTC, BoQsc wrote:**The question:** Is there a way to include the `.def` file instructions inside `.d` file, so that there won't be a need for additional `.def` file when compiling. (`dmd winsamp`)https://dlang.org/spec/pragma.html#linkerDirective
Nov 24 2021
On Wednesday, 24 November 2021 at 17:14:42 UTC, Adam D Ruppe wrote:https://dlang.org/spec/pragma.html#linkerDirectiveexample from my stuff: import arsd.minigui; pragma(linkerDirective, "/subsystem:windows"); pragma(linkerDirective, "/entry:mainCRTStartup"); that works with dmd -m32mscoff. need a wmainCRTStartup for ldc, no entry at all for dmd -m32. Maybe I should make this a tempalte in my library.......
Nov 24 2021
On Wednesday, 24 November 2021 at 17:14:42 UTC, Adam D Ruppe wrote:On Wednesday, 24 November 2021 at 17:06:21 UTC, BoQsc wrote:The many times I tried this pragma, it did not even get recognised as pragma at all. Essentialy it did not work. Mind giving a demonstration of this pragma? ``` dmd winsamp.d winsamp.d(13): Error: unrecognized `pragma(linkerDirective)` ```**The question:** Is there a way to include the `.def` file instructions inside `.d` file, so that there won't be a need for additional `.def` file when compiling. (`dmd winsamp`)https://dlang.org/spec/pragma.html#linkerDirective
Nov 24 2021
On Wednesday, 24 November 2021 at 17:23:07 UTC, BoQsc wrote:The many times I tried this pragma, it did not even get recognised as pragma at all.You need to use `dmd -m32mscoff` or `dmd -m64`. Plain `dmd` won't work. If -m32mscoff and -m64 still don't work, what's your dmd version? It was added in 2.083.0, November 2018.
Nov 24 2021
On Wednesday, 24 November 2021 at 17:29:09 UTC, Adam D Ruppe wrote:On Wednesday, 24 November 2021 at 17:23:07 UTC, BoQsc wrote:Thanks, seems to work now. I had to add these two pragmas to the `winsamp.d` ``` pragma(linkerDirective, "/subsystem:windows"); pragma(lib, "user32.lib"); ``` And as you mentioned give additional`-m32mscoff` flag to the compiler. `dmd winsamp.d -m32mscoff` **The obvious problem now is:** How can you compile without specifying the flags. With plain dmd.The many times I tried this pragma, it did not even get recognised as pragma at all.You need to use `dmd -m32mscoff` or `dmd -m64`. Plain `dmd` won't work. If -m32mscoff and -m64 still don't work, what's your dmd version? It was added in 2.083.0, November 2018.
Nov 24 2021
On Wednesday, 24 November 2021 at 17:38:42 UTC, BoQsc wrote:[...] **The obvious problem now is:** How can you compile without specifying the flags. With plain dmd.It probably has to do something with the default target of dmd (`-m32`) generating **OMF object file**. https://dlang.org/dmd-windows.html#switch-m32 `-m32mscoff` and `-m64` both generate **MS-COFF Object file** instead of **OMF object file**. --- The below error is caused when the compilation target is **OMF object file** instead of **MS-COFF Object file**. ``` winsamp.d(11): Error: unrecognized pragma(linkerDirective) ```
Nov 24 2021
On Wednesday, 24 November 2021 at 17:38:42 UTC, BoQsc wrote:On Wednesday, 24 November 2021 at 17:29:09 UTC, Adam D Ruppe wrote:Just a quick question before going deeper. Why do you not want to supply the definition file?On Wednesday, 24 November 2021 at 17:23:07 UTC, BoQsc wrote:Thanks, seems to work now. I had to add these two pragmas to the `winsamp.d` ``` pragma(linkerDirective, "/subsystem:windows"); pragma(lib, "user32.lib"); ``` And as you mentioned give additional`-m32mscoff` flag to the compiler. `dmd winsamp.d -m32mscoff` **The obvious problem now is:** How can you compile without specifying the flags. With plain dmd.The many times I tried this pragma, it did not even get recognised as pragma at all.You need to use `dmd -m32mscoff` or `dmd -m64`. Plain `dmd` won't work. If -m32mscoff and -m64 still don't work, what's your dmd version? It was added in 2.083.0, November 2018.
Nov 24 2021
On Wednesday, 24 November 2021 at 20:29:36 UTC, Imperatorn wrote:On Wednesday, 24 November 2021 at 17:38:42 UTC, BoQsc wrote:To have a single standalone .d script file, that's the end goal. I want to have everything in one .d source file and run it without specifying additional files or flags. In other words: as simple as possible to use.On Wednesday, 24 November 2021 at 17:29:09 UTC, Adam D Ruppe wrote:Just a quick question before going deeper. Why do you not want to supply the definition file?On Wednesday, 24 November 2021 at 17:23:07 UTC, BoQsc wrote:Thanks, seems to work now. I had to add these two pragmas to the `winsamp.d` ``` pragma(linkerDirective, "/subsystem:windows"); pragma(lib, "user32.lib"); ``` And as you mentioned give additional`-m32mscoff` flag to the compiler. `dmd winsamp.d -m32mscoff` **The obvious problem now is:** How can you compile without specifying the flags. With plain dmd.The many times I tried this pragma, it did not even get recognised as pragma at all.You need to use `dmd -m32mscoff` or `dmd -m64`. Plain `dmd` won't work. If -m32mscoff and -m64 still don't work, what's your dmd version? It was added in 2.083.0, November 2018.
Nov 24 2021
On Thursday, 25 November 2021 at 06:56:38 UTC, BoQsc wrote:In other words: as simple as possible to use.`dmd -i`,no need `one big file`.
Nov 25 2021
Since the **linkerDirective pragma** is not supported for OMF object file.Linker directives are only supported for MS-COFF output.https://dlang.org/spec/pragma.html#linkerDirective I doubt that this thread is completely resolved.
Nov 24 2021
On Wednesday, 24 November 2021 at 17:06:21 UTC, BoQsc wrote:I'm not sure if I have sucessfully achieved something like this before or is it even possible right now, but there is a sample file that comes with DMD compiler: `D\dmd2\samples\d\winsamp.d` **The problem:** `winsamp.d` have to be compiled with `.def` file. ``` /+ Compile with: + dmd winsamp winsamp.def + or: + dmd winsamp -L-Subsystem:Windows + + 64 bit version: + dmd -m64 winsamp -L-Subsystem:Windows user32.lib +/ ``` This is how the `.def` file looks like (`D\dmd2\samples\d\winsamp.def`): ``` EXETYPE NT SUBSYSTEM WINDOWS ``` **The question:** Is there a way to include the `.def` file instructions inside `.d` file, so that there won't be a need for additional `.def` file when compiling. (`dmd winsamp`)What most ppl do in that case is to just provide a script, for example build.cmd that just does what it needs. The user just clicks the script and it does everything for them.
Nov 25 2021
On Thursday, 25 November 2021 at 09:00:52 UTC, Imperatorn wrote:What most ppl do in that case is to just provide a script, for example build.cmd that just does what it needs. The user just clicks the script and it does everything for them."How can I make it so that I don't need an extra file written in another language?" "Just add yet another file written in yet another language". Nice going there :) Build scripts never have been scalable. A good language shall only require a compiler and source file(s). No extra voodoo mumbojumbo. This is why we have all those pragmas and the -i switch.
Nov 25 2021
On Thursday, 25 November 2021 at 09:47:50 UTC, Stanislav Blinov wrote:On Thursday, 25 November 2021 at 09:00:52 UTC, Imperatorn wrote:Scalable or not it's a pretty common pattern. The build script is modular. I wouldn't call the linker "mumbojumbo". Voodo maybe, yes.What most ppl do in that case is to just provide a script, for example build.cmd that just does what it needs. The user just clicks the script and it does everything for them."How can I make it so that I don't need an extra file written in another language?" "Just add yet another file written in yet another language". Nice going there :) Build scripts never have been scalable. A good language shall only require a compiler and source file(s). No extra voodoo mumbojumbo. This is why we have all those pragmas and the -i switch.
Nov 25 2021