Closed MachineTrader closed 1 year ago
Because Vala is a compiled language, compiler options cannot be inferred (Gtk
is a namespace belonging to gtk2, gtk3, and gtk4 packages). Therefore you need a meson.build
, compile_commands.json
, or shebang at the top of the file. (ex: #!/bin/env valac -S --pkg gtk+-3.0
#!/bin/env -S vala --pkg gtk+-3.0
)
Thanks a lot for your answer! I have this Build.sh file with the shebang at the top. But even if I move it to the same folder it doesn't seem to fix anything. I haven't heard of compile_commands.json I'll google it.
#!/bin/sh
valac \
src/main.gs \
--pkg gee-0.8 \
--pkg gio-2.0 \
--pkg gtk+-3.0
If the shebang doesn't work, try setting up a meson build
Thank you, I've been learning about Meson all day.
I have a feeling that these steps can be a big hurdle for people just to get started. I've had many days this week to get started, most people don't have that time. And will just give up and move to another language.
And also if you just have a slight OCD like me you want the langauge-server to be up and running before starting with anything beyond Hello World. Especially with an object based gui library like GTK.
If the shebang could be made to work somehow, and also be "Clearly" explained in the Read.me of this repo, that would be a big win for people who want to get started. I feel like learning the build system is something you want to do do after a few test projects, not the first thing you do.
I did try place:
#!/bin/env valac -S --pkg gtk+-3.0
Before:
[indent=0]
in the file, with negative result.
I really appreciate your help so far!
@MachineTrader it's actually supposed to be #!/bin/env -S vala --pkg gtk+-3.0
. Oops.
How do I fix this error in a vala file?
Hi, I was trying out Genie and I really love the language.
So I decided to install the language server.
Everything compiles like it should with valac.
The problem is that Vala language server doesn't seem to find the namespace of Gtk, so I get a lot of red markings on my code. Pkg-config finds it, the command:
pkg-config --cflags gtk+-3.0
gives this response:
-I/usr/include/gtk-3.0
OS: Endeavour OS KDE. IDE: Kate and VSCodium/VSCode
I have the same problem with both editors.
Vala version 0.56.5
Source code repo: yay -S vala-lanaguage-server-git
Steps to reproduce the behavior: sudo pacman -S vala gtk3 kate yay -S vala-language-server-git
Here's the code of main.gs: