Cant compile GTK with tcc

Nothing to say there. To develop something with UI, fast recompilation is very important. In tests, the tcc gives me approximately 2x increase. But unfortunately I can’t compile an application using GTK.

> vala hello.vala  --cc tcc
Hello, World
> vala gtkExample.vala --pkg gtk+-3.0  --cc tcc
tcc: error: undefined symbol 'main'
error: cc exited with status 256
> 

Without pasting your actual code, there isn’t much we can do to help. Trying a very simple program here, it works fine.

Um, absolutely any code, even if i just include GTK.

using Gtk;
void main(){
  print("Hello, World\n");
}
> valac console.vala --pkg gtk+-3.0 --cc tcc
tcc: error: undefined symbol 'main'
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

I don’t get an error with valac 0.42.5 together with tcc 0.9.27.

However, couldn’t it be that vala gets confused by you using Gtk which
defines main itself? I don’t think it should, but I could understand
it’s confused by not knowing what to select between main() and
Gtk.main(). My version definitely doesn’t get confused, but maybe
another one, I don’t know.

WORKSFORME. I guess something is wrong with your install.
(FTR, I’m using valac 0.42.5-1 and tcc 0.9.27-8 from debian)

I’m on arch and I have the latest versions.

> tcc -v
tcc version 0.9.27 (x86_64 Linux)
> valac --version
Vala 0.44.6

I hope someone with arch will respond in this thread to make sure that this is my problem(after all, applications without GTK are compiled??? maybe it’s a regression)

You could try and see what kind of C code gets generated; but, in general, I think you should open a bug against Vala whenever the generated C code does not compile valid Vala code.

Just wonderful C code is generated.

/* console.c generated by valac 0.44.6, the Vala compiler
 * generated from console.vala, do not modify */

#include <glib.h>

void _vala_main (void);

void
_vala_main (void)
{
	g_print ("Hello, World\n");
}

int
main (int argc,
      char ** argv)
{
	_vala_main ();
	return 0;
}

If you thought that I cant compile applications with gtk then it is not. They arent compiled only when using tcc. And there is obviously one main. Now I will try to do it on a virtual machine with Ubuntu 19.04.

You can try passing -v to vala to see the tcc command line it used.

I tested this on Ubuntu 19.04 VM and Manjaro VM.
Ubuntu

gavr@gavr-VirtualBox:~/Документы$ vala console.vala 
hello
gavr@gavr-VirtualBox:~/Документы$ vala console.vala --cc tcc
hello
gavr@gavr-VirtualBox:~/Документы$ vala console.vala --cc tcc --pkg gtk+-3.0
hello
gavr@gavr-VirtualBox:~/Документы$ valac --version
Vala 0.44.3
gavr@gavr-VirtualBox:~/Документы$ uname -a
Linux gavr-VirtualBox 5.0.0-13-generic #14-Ubuntu SMP Mon Apr 15 14:59:14 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Manjaro

[gavr@gavr-pc ~]$ vala console.vala
hello
[gavr@gavr-pc ~]$ vala console.vala -cc tcc --pkg gtk+-3.0
tcc: error: undefined symbol 'main'
error: cc exited with status 256
[gavr@gavr-pc ~]$ valac --version
Vala 0.44.3
[gavr@gavr-pc ~]$ uname -r
4.19.42-1-MANJARO

As you can see Vala versions are the same. On both VMs, tcc has just been installed, so it is extremely unlikely that the problem is in its installation. It looks like this is something specific to the arch-based distribution, although this is only a guess.
I don’t know in which project issue should be created, it would be nice if someone more knowledgeable tried to do the same as me.

UPD compile with -v flag
Ubuntu

gavr@gavr-VirtualBox:~/Документы$ vala console.vala --cc tcc --pkg gtk+-3.0 -v
Loaded package `/usr/share/vala-0.44/vapi/glib-2.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gobject-2.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gtk+-3.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gio-2.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/atk.vapi'
Loaded package `/usr/share/vala-0.44/vapi/cairo.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gdk-pixbuf-2.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gdk-3.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/pango.vapi'
Loaded package `/usr/share/vala-0.44/vapi/pangocairo.vapi'
Loaded package `/usr/share/vala-0.44/vapi/x11.vapi'
tcc -o '/tmp/console.vala.P0TH5Z' '/tmp/console.vala.P0TH5Z.c' -pthread -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lgio-2.0 -lgobject-2.0 -lglib-2.0

Arch

> valac  console.vala --cc tcc --pkg gtk+-3.0 -v 
Loaded package `/usr/share/vala-0.44/vapi/glib-2.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gobject-2.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gtk+-3.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gio-2.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/atk.vapi'
Loaded package `/usr/share/vala-0.44/vapi/cairo.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gdk-pixbuf-2.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/gdk-3.0.vapi'
Loaded package `/usr/share/vala-0.44/vapi/pango.vapi'
Loaded package `/usr/share/vala-0.44/vapi/pangocairo.vapi'
Loaded package `/usr/share/vala-0.44/vapi/x11.vapi'
tcc -o '/home/gavr/console' '/home/gavr/console.vala.c' -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi-3.2.1/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/uuid -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/libdrm -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread -lgtk-3 -lgio-2.0 -latk-1.0 -lgdk-3 -lz -lgdk_pixbuf-2.0 -lcairo-gobject -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lX11
tcc: error: undefined symbol 'main'
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.