D.gnu - Using GtK
- Ruby The Roobster (21/21) Aug 23 2021 I have a very basic program that does ABSOLUTELY NOTHING. Here
- Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= (4/25) Aug 23 2021 I can only guess that module imports trigger module constructor
- Iain Buclaw (9/10) Aug 24 2021 You're using command-line arguments as if you are compiling with
- Ruby The Roobster (11/22) Aug 24 2021 No matter what I try(including correct invocation), it won't work
- Mike Parker (25/33) Aug 24 2021 There's nothing special you have to do. You should always see an
- Ruby The Roobster (3/40) Aug 24 2021 I changed test.d to be the same code as in the
- Mike Parker (32/34) Aug 24 2021 `
- Mike Parker (3/9) Aug 24 2021 On Wednesday, 25 August 2021 at 01:40:39 UTC, Mike Parker wrote:
- Ruby The Roobster (4/14) Aug 25 2021 Thank you. Now I see the executable pop up. I was using dub
I have a very basic program that does ABSOLUTELY NOTHING. Here is the code: ```d import gtk.Main; import gtk.MainWindow; import gtk.Widget; void main() { } ``` I am using gdc version 10.3.0 on Ubuntu 20.04. Assuming the file name is test.d, here is my command line: gdc -I/usr/include/gtkd-3 -L-ldl -L-libgtkd-3 test.d It generates the following errors: /usr/bin/ld: /tmp/ccelqCb4.o:(.data.rel+0x10): undefined reference to `_D3gtk10MainWindow12__ModuleInfoZ' /usr/bin/ld: /tmp/ccelqCb4.o:(.data.rel+0x18): undefined reference to `_D3gtk4Main12__ModuleInfoZ' /usr/bin/ld: /tmp/ccelqCb4.o:(.data.rel+0x20): undefined reference to `_D3gtk6Widget12__ModuleInfoZ' collect2: error: ld returned 1 exit status Why is this, and how can I fix it? Thanks in advance.
Aug 23 2021
On Monday, 23 August 2021 at 20:21:13 UTC, Ruby The Roobster wrote:I have a very basic program that does ABSOLUTELY NOTHING. Here is the code: ```d import gtk.Main; import gtk.MainWindow; import gtk.Widget; void main() { } ``` I am using gdc version 10.3.0 on Ubuntu 20.04. Assuming the file name is test.d, here is my command line: gdc -I/usr/include/gtkd-3 -L-ldl -L-libgtkd-3 test.d It generates the following errors: /usr/bin/ld: /tmp/ccelqCb4.o:(.data.rel+0x10): undefined reference to `_D3gtk10MainWindow12__ModuleInfoZ' /usr/bin/ld: /tmp/ccelqCb4.o:(.data.rel+0x18): undefined reference to `_D3gtk4Main12__ModuleInfoZ' /usr/bin/ld: /tmp/ccelqCb4.o:(.data.rel+0x20): undefined reference to `_D3gtk6Widget12__ModuleInfoZ' collect2: error: ld returned 1 exit status Why is this, and how can I fix it? Thanks in advance.I can only guess that module imports trigger module constructor including some code that requires c linkage (Gtk).
Aug 23 2021
On Monday, 23 August 2021 at 20:21:13 UTC, Ruby The Roobster wrote:gdc -I/usr/include/gtkd-3 -L-ldl -L-libgtkd-3 test.dYou're using command-line arguments as if you are compiling with dmd. On gcc `-L-libgtkd-3` means "add _directory_ ./-libgtkd-3 to the list of directories to be searched for `-l`". https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Directory-Options.html#index-L Correct invocation: gdc -I/usr/include/gtkd-3 -ldl -lgtkd-3 test.d
Aug 24 2021
On Tuesday, 24 August 2021 at 08:08:05 UTC, Iain Buclaw wrote:On Monday, 23 August 2021 at 20:21:13 UTC, Ruby The Roobster wrote:No matter what I try(including correct invocation), it won't work with gdc. Doing this, works though: dub add gtkd-3 3.9.0 then dub fetch gtkd-3 3.9.0 then dub test.d Will cause the program to run and execute. However, it doesn't save an executable to disk, which is what I want. Is there a way, to get it saved to disk?gdc -I/usr/include/gtkd-3 -L-ldl -L-libgtkd-3 test.dYou're using command-line arguments as if you are compiling with dmd. On gcc `-L-libgtkd-3` means "add _directory_ ./-libgtkd-3 to the list of directories to be searched for `-l`". https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Directory-Options.html#index-L Correct invocation: gdc -I/usr/include/gtkd-3 -ldl -lgtkd-3 test.d
Aug 24 2021
On Tuesday, 24 August 2021 at 19:07:11 UTC, Ruby The Roobster wrote:Doing this, works though: dub add gtkd-3 3.9.0 then dub fetch gtkd-3 3.9.0 then dub test.d Will cause the program to run and execute. However, it doesn't save an executable to disk, which is what I want. Is there a way, to get it saved to disk?There's nothing special you have to do. You should always see an executable after invoking dub for a run or build. But you've got some mixed-up commands here. 1. dub add requires a dub.json/sdl. I assume you have one, else the invocation would fail. But if you do, you aren't using it because of your invocation of `dub test.d` (see point 3 below). 2. dub fetch is not needed after dub add. If a dependency is added to your config file, dub will fetch it automatically. 3. dub test.d is for building a single file. To do that, you have to add your dub config in a comment at the top of the source file rather than as a separate dub.json/sdl. If you try to invoke dub with a source file name and there is no config at the top of the file, then the invocation will fail. And if you do have this, then your invocation of dub add isn't doing anything for you---it won't add dependencies to single-file configs. If the first and last invocations really are succeeding, then it looks like you've got both a dub.json/sdl *and* a single-file config. And in that case, your dub.json/sdl isn't doing anything and dub is using the config at the top of test.d. And you should see an executable next to test.d after it completes. So this is all rather confusing looking only at these command lines. How exactly have you configured this? What does test.d look like?
Aug 24 2021
On Tuesday, 24 August 2021 at 22:21:44 UTC, Mike Parker wrote:On Tuesday, 24 August 2021 at 19:07:11 UTC, Ruby The Roobster wrote:I changed test.d to be the same code as in the HelloWorld.d(https://github.com/gtkd-developers/GtkD/blob/master/demos/gtk/ elloWorld.d)example that is provided by the GtkD github. Adding the comment to the top of the file and removing the .json doesn't change what happens. Dub runs the program, but an executable file doesn't pop up next to it. Running ./test in the terminal returns a no file or directory error. Another thing. Apparently dub run is the default command, but running dub run test.d gives an error that the package test could not be found. Same with dub build. Running dub test.d still works just fine, for some reason.Doing this, works though: dub add gtkd-3 3.9.0 then dub fetch gtkd-3 3.9.0 then dub test.d Will cause the program to run and execute. However, it doesn't save an executable to disk, which is what I want. Is there a way, to get it saved to disk?There's nothing special you have to do. You should always see an executable after invoking dub for a run or build. But you've got some mixed-up commands here. 1. dub add requires a dub.json/sdl. I assume you have one, else the invocation would fail. But if you do, you aren't using it because of your invocation of `dub test.d` (see point 3 below). 2. dub fetch is not needed after dub add. If a dependency is added to your config file, dub will fetch it automatically. 3. dub test.d is for building a single file. To do that, you have to add your dub config in a comment at the top of the source file rather than as a separate dub.json/sdl. If you try to invoke dub with a source file name and there is no config at the top of the file, then the invocation will fail. And if you do have this, then your invocation of dub add isn't doing anything for you---it won't add dependencies to single-file configs. If the first and last invocations really are succeeding, then it looks like you've got both a dub.json/sdl *and* a single-file config. And in that case, your dub.json/sdl isn't doing anything and dub is using the config at the top of test.d. And you should see an executable next to test.d after it completes. So this is all rather confusing looking only at these command lines. How exactly have you configured this? What does test.d look like?
Aug 24 2021
On Tuesday, 24 August 2021 at 23:30:22 UTC, Ruby The Roobster wrote:I changed test.d to be the same code as in the HelloWorld.d(https://github.com/gtkd-developers/GtkD/blob/master/demos/gtk/ elloWorld.d)example that is provided by the GtkD github. Adding the comment to the top of the file and removing the .json doesn't change what happens. Dub runs the program, but an executable file doesn't pop up next to it. Running ./test in the terminal returns a no file or directory error. Another thing. Apparently dub run is the default command, but running dub run test.d gives an error that the package test could not be found. Same with dub build. Running dub test.d still works just fine, for some reason.` Yes, `run` is the default. But you are misunderstanding how dub works. Neither `dub run` nor `dub build` accepts a source file. These commands expect to find a dub.json/sdl in the current directory. dub will then look for source files in a `source` or `src` directory and will pass them all to the compiler. In other words, given: ``` - projectDir -- dub.sdl -- source --- app.d ``` Then you can: ``` cd projectDir dub ``` This will build and run the application with the default configuration. This is documented here: https://dub.pm/getting_started.html When you instead do `dub test.d`, dub looks for the configuration in a comment at the top of the source file. It then will build and run that file and any dependencies listed in the configuration. That's documented here: https://dub.pm/advanced_usage But either way, if the app successfully compiles and executes, you should be seeing an executable. If you could paste the source of test.d here and specify which platform you're on, then maybe I or someone else can take a look.
Aug 24 2021
On Wednesday, 25 August 2021 at 01:40:39 UTC, Mike Parker wrote: So the formatting got borked and my first paragraph ended up with the quoted text. In case it isn't clear:` Yes, `run` is the default. But you are misunderstanding how dub works. Neither `dub run` nor `dub build` accepts a source file. These commands expect to find a dub.json/sdl in the current directory. dub will then look for source files in a `source` or `src` directory and will pass them all to the compiler.
Aug 24 2021
On Wednesday, 25 August 2021 at 01:41:53 UTC, Mike Parker wrote:On Wednesday, 25 August 2021 at 01:40:39 UTC, Mike Parker wrote: So the formatting got borked and my first paragraph ended up with the quoted text. In case it isn't clear:Thank you. Now I see the executable pop up. I was using dub wrong, having never used it before. Again, thanks for all the help.` Yes, `run` is the default. But you are misunderstanding how dub works. Neither `dub run` nor `dub build` accepts a source file. These commands expect to find a dub.json/sdl in the current directory. dub will then look for source files in a `source` or `src` directory and will pass them all to the compiler.
Aug 25 2021