Re: [Vala] undefined reference to 'SDL_Init' and/or 'WinMain 16' (under Windows)
- From: Raum no-log org
- To: "Andreas" <tradiaz yahoo de>
- Cc: vala-list gnome org
- Subject: Re: [Vala] undefined reference to 'SDL_Init' and/or 'WinMain 16' (under Windows)
- Date: Tue, 20 Mar 2012 14:27:46 +0100 (CET)
Really strange...
This code below is correct and a window appears !
==================================
using GLib;
using SDL;
int WinMain(string[] argc)
{
SDL.Surface *screen;
if( SDL.init( InitFlag.VIDEO ) < 0 )
{
stdout.printf( "Impossible d'initialiser SDL: %s\n",
SDL.get_error( ) );
return 1;
}
screen = SDL.Screen.set_video_mode( 640, 480, 16,
SurfaceFlag.HWSURFACE );
SDL.WindowManager.set_caption ("Vala SDL Demo", "");
if( screen == null )
{
stdout.printf( "Impossible d'initialiser le mode video: %s\n",
SDL.get_error( ) );
return 1;
}
SDL.Timer.delay( 3000 );
SDL.quit();
return 0;
}
int main(string[] argc )
{
stdout.printf ("not printed\n");
return 0;
}
=========================================
The "main" function is not called and I've got two warnings :
Compilation time :
test2.vala:5.1-5.11: warning: method `WinMain' never used
int WinMain(string[] argc)
Linking time :
Warning: resolving _WinMain 16 by linking to _WinMain
I need to have these two function "main" and "winmain"... :-?
Ehm...
Thanks
Hi
WinMain usually is the entry point for Win32 programs (isntead of
main()). If you do not have such a function defined in your C-Code you
get the
the error message you described. At least that's the experience I have
with that error message with pure C an WinAPI
regards
andi
Am 20.03.2012 12:06, schrieb Raum no-log org:
Ehm.. I don't have any idea or any clue....
I've tried to create C code and compile it :
-----------------------------------------------------
/* test2.c generated by valac 0.12.0, the Vala compiler
* generated from test2.vala, do not modify */
#include<glib.h>
#include<glib-object.h>
#include<stdlib.h>
#include<string.h>
#include<SDL.h>
#include<stdio.h>
gint _vala_main (gchar** argc, int argc_length1);
gint _vala_main (gchar** argc, int argc_length1) {
gint result = 0;
SDL_Init ((guint32) 0);
SDL_Quit ();
fprintf (stdout, "Hello world!");
result = 0;
return result;
}
int main (int argc, char ** argv) {
g_type_init ();
return _vala_main (argv, argc);
}
-------------------------------------------------
And I've got the same error (which is not surprising...) :
gcc -o C:/vala\test2 C:/vala/test2.vala.c -mms-bitfields
-Ic:/vala/include/glib-2.0 -Ic:/vala/lib/glib-2.0/include -Lc:/vala/lib
-lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lintl -lSDL -lSDLmain -lmingw32
-mwindows
c:/vala/lib/libmingw32.a(main.o):main.c:(.text+0xbd): undefined
reference
to `WinMain 16'
collect2: ld returned 1 exit status
Hello,
2012/3/20<Raum no-log org>:
Perhaps a basic linkage error but I dont know how to correct :D
You should be looking at the SDL FAQ for Windows:
http://wiki.libsdl.org/moin.cgi/FAQWindows
For example this question seems to be exactly what you want (don't
forget -X before each argument):
I get "Undefined reference to 'WinMain 16'"
Under Visual C++, you need to link with SDLmain.lib. Under the gcc
build environments including Dev-C++, you need to link with the output
of "sdl-config --libs", which is usually: -lmingw32 -lSDLmain -lSDL
-mwindows
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]