I'm testing Vala and I think I didn't understand how to use package with
it... I want to use SDL and SDLNet but I've got an "undefined
reference"...
Here is my test program :
--------------------
using GLib;
using SDL;
int main (string[] args) {
SDL.init( 0 );
SDL.quit( );
stdout.printf ("Hello world!");
return 0;
}
--------------------
My command line to compile :
---------------------
>valac --pkg sdl test.vala
(...)\LOCALS~1\Temp/cconhiY1.o:test.vala.c:(.text+0x15): undefined
reference to `SDL_Init'
(...)\LOCALS~1\Temp/cconhiY1.o:test.vala.c:(.text+0x1a): undefined
reference to `SDL_Quit'
c:/vala-0.12.0/lib/libmingw32.a(main.o):main.c:(.text+0xbd): undefined
reference to `WinMain@16'
collect2: ld returned 1 exit status
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)
--------------------
But this sample below just compile without any error with the same command
line :
--------------------------------------
using GLib;
using SDL;
int main (string[] args) {
stdout.printf ("Hello world!");
return 0;
}
--------------------------------------
Result :
-----------------------
>>valac --pkg sdl test2.vala
>>test2
Hello world!
----------------------
Where am i wrong ?
Thanks !
Regards
Raum
_______________________________________________
vala-list mailing list
vala...@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list
So I've linked my code with sdl library but I've got the last error
undefined reference to `WinMain@16' for libmingw32.a
Any advice ? :)
Thanks
I forget the exact magic needed for mingw, maybe you need to add -X
-mwindows to the command line?
If not, add --verbose to your vala commandline and post the full gcc
commandline that's being used, that may be useful
Sam
I've got this message :
-------------------------------------------
C:\vala-0.12.0>valac --pkg sdl -X -lsdl -X -mwindows --verbose test2.vala
gcc -o 'C:/vala-0.12.0\test2' 'C:/vala-0.12.0/test2.vala.c' -mms-bitfields
-Ic:/vala-0.12.0/include/glib-2.0 -Ic:/vala-0.12.0/lib/glib-2.0/include
-Lc:/vala-0.12.0/lib -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lintl '-lsdl'
'-mwindows'
c:/vala-0.12.0/lib/libmingw32.a(main.o):main.c:(.text+0xbd): undefined
reference to `WinMain@16'
collect2: ld returned 1 exit status
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)
-----------------------------------------
I've tried '-X -lSDLMain' option :
----------------------------------------------------
C:\vala-0.12.0>valac --pkg sdl -X -lsdl -X -lSDLMain -X -mwindows
--verbose test2.vala
gcc -o 'C:/vala-0.12.0\test2' 'C:/vala-0.12.0/test2.vala.c' -mms-bitfields
-Ic:/vala-0.12.0/include/glib-2.0 -Ic:/vala-0.12.0/lib/glib-2.0/include
-Lc:/vala-0.12.0/lib -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lintl '-lsdl'
'-lSDLMain' '-mwindows'
Warning: .drectve `/manifestdependency:"type='win32'
name='Microsoft.VC90.CRT' version='9.0.21022.8'
processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'"
/DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
c:/vala-0.12.0/lib/SDLMain.lib(./Release/SDL_win32_main.obj):(.text[_main]+0x7):
undefined reference to `__security_cookie'
c:/vala-0.12.0/lib/SDLMain.lib(./Release/SDL_win32_main.obj):(.text[_main]+0x99):
undefined reference to `_alloca_probe_16'
c:/vala-0.12.0/lib/SDLMain.lib(./Release/SDL_win32_main.obj):(.text[_main]+0xc6):
undefined reference to `SDL_strlcpy'
(...)
------------------------------------------------
Perhaps a basic linkage error but I dont know how to correct :D
Thanks
>>> stdout.printf ("Hello%
2012/3/20 <Ra...@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
I've downloaded these packages :
http://www.libsdl.org/release/SDL-devel-1.2.15-VC.zip
Perhaps I should download (gasp, =__= I didnt notice..)
http://www.libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz
I'll try and keep you informed ;) (I need to clean my vala install..)
,> Hi
SDL package : SDL-devel-1.2.15-mingw32.tar.gz
(copy files from tarball to directories "include", "lib" and "bin").
To correct a "-lcom32dlg" error, I've installed :
http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/w32api-3.17/w32api-3.17-1-mingw32-dev.tar.lzma/download
(copy files from tarball to directories "include", "lib" and "bin").
>valac --pkg sdl -X -lsdl -X -lsdlmain -X -lmingw32 -X -mwindows
--verbose test2.vala
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
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)
:-?
Thanks :)
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
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
It was a painful process. You don't need a main or winmain functions
at all. I ended up side loading cygwin, and visual studio libraries
(for opengl). Hopefully that helps enough. I also packaged the
libraries I ended up using with vala-0.12
http://files.myopera.com/sutabi/vala_game_sdk/vala-0.12.0.zip that may
also help.
--
Joseph Montanez
Web Developer
Gorilla3D
Design, Develop, Deploy