Hi,
I installed the Vala extension from Prince Ferro and the Vala language-server and I can successfully compile and run, but I always get the error “The namespace name `Gtk’ could not be found” in the editor. How can I correct this in VS Code ?
Thanks…
have you got any sample code?
can you supply the meson build files?
I tried the examples / tutorial from the official Vala documentation page.
There were some problems compiling Vala code. I quit learning Vala now, I stay at old C.
I have vala compiling and building in vscode quite well
contact me if you want the instructions
check your meson.build file in your projects “src” directory
you need to add the Gtk dependency in there and then in your code you should have a line that states “using Gtk;”
heres a meson.build file
sources = files(
'MyApp.vala',
'MyAppWindow.vala',
'MyClass.vala',
'MyOtherClass.vala'
)
dependencies = [
dependency('gtk4'),
dependency('gee-0.8'),
dependency('glib-2.0'),
dependency('libadwaita-1')
]
executable(
meson.project_name(),
sources,
dependencies: dependencies,
install: true
)
and in your source file
/*
main app for your app
*/
using Gtk;
public class MyApp : Adw.Application {
// Member variables
private GLib.Settings myapp_settings;
private MyApprWindow app_window;
// Constructor
public MyApp () {
Object (application_id: "com.github.xxxx.xxxxx",
flags : GLib.ApplicationFlags.FLAGS_NONE);
}
… etc
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.