My favorites | Sign in
Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 31: Guichan SDL and mingw
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----
Type-Defect
Priority-Medium


Sign in to add a comment
 
Reported by uberiain50, Feb 29, 2008
hello,

I want to use guichan with mingw, but i have problems to link exmaples. I
am do this:

configure CXX=g++ CPPFLAGS="-D_REENTRANT -I/usr/local/include -I/usr/local/in
clude/SDL" LDFLAGS=-L/usr/local/lib --enable-force-sdlimage

with this settings the result is:

-------------------------------
Guichan ready for compilation!
-------------------------------
* Allegro   = disabled
* HGE       = no (Windows specific and cannot be built)
* OpenGL    = no
* OpenLayer = no (Requires static build and cannot be built)
* SDL       = yes
* SDL Image = forced
--------------------------------

why this settings? The test for SDL_image don't link: they must have:

int main ( int argc, char *argv[] ) as it's required for SDL_main to work.

I then do:

make
make install

the libs and includes goes to /usr/local/lib /usr/local/include

when i compile exmaples with:

make -f Makefile.examples sdl CFLAGS="-D_REENTRANT -I/usr/local/include
-I/usr/local/include/SDL"

the result is:

g++ sdlhelloworld.cpp -o sdlhelloworld -D_REENTRANT -I/usr/local/include
-I/usr/local/include/SDL \
-lguichan_sdl -lguichan -lSDL_image `sdl-config --libs --cflags`
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/cc2zbaaa.o:sdlhelloworld.cpp:(.text+0x1cd):
undefined reference to `_imp___ZN3gcn5Image14setImageLoaderEPNS_11ImageLoaderE'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/cc2zbaaa.o:sdlhelloworld.cpp:(.text+0x1ef):
undefined reference to `_imp___ZN3gcn11SDLGraphicsC1Ev'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/cc2zbaaa.o:sdlhelloworld.cpp:(.text+0x290):
undefined reference to `_imp___ZN3gcn8SDLInputC1Ev'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/cc2zbaaa.o:sdlhelloworld.cpp:(.text+0x312):
undefined reference to `_imp___ZN3gcn9ContainerC1Ev'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/cc2zbaaa.o:sdlhelloworld.cpp:(.text+0x395):
undefined reference to `_imp___ZN3gcn9RectangleC1Eiiii'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/cc2zbaaa.o:sdlhelloworld.cpp:(.text+0x3de):
undefined reference to `_imp___ZN3gcn3GuiC1Ev'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/cc2zbaaa.o:sdlhelloworld.cpp:(.text+0x54b):
undefined reference to `_imp___ZN3gcn9ImageFontC1ERKSsS2_'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/cc2zbaaa.o:sdlhelloworld.cpp:(.text+0x69f):
undefined reference to `_imp___ZN3gcn6Widget13setGlobalFontEPNS_4FontE'

the result is the program don't link, What I can do?.

Regards




 
Comment 1 by olof.naessen, Feb 29, 2008
The only command you need to enter in order to compile the SDL examples is

make -f Makefile.examples sdl

I think it's quite obvious that the linker cannot find SDL_image, do you have
SDL_image properly installed? I can see you force to use of SDL_image, so I bet the
configure script cannot find SDL_image which means the linker cannot find SDL_image
either.
Comment 2 by uberiain50, Feb 29, 2008
Sorry, i have installed SDL at /usr/local, not @ /usr, the test used by configure 
don't found SDL_Image.h .

if I set CPPFLAGS=-I/usr/local/include and LDFLAGS=-L/usr/local/lib for this to 
work, they found SDL_Image.h my configure is:

./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib

the result is:

-------------------------------
Guichan ready for compilation!
-------------------------------
* Allegro   = disabled
* HGE       = no (Windows specific and cannot be built)
* OpenGL    = no
* OpenLayer = no (Requires static build and cannot be built)
* SDL       = yes
* SDL Image = yes
--------------------------------

 Now, for examples if I don't set -I and -L flags the compiler don“t found headers 
and libs. if I set CFLAGS="-I/usr/local/include -L/usr/local/lib " the example 
compile, but they don't link with the errors:

C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/ccIRbaaa.o:sdlhelloworld.cpp:(.text+0x1cd): 
undefined reference to `_imp___ZN3gcn5Image14setImageLoaderEPNS_11ImageLoaderE'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/ccIRbaaa.o:sdlhelloworld.cpp:(.text+0x1ef): 
undefined reference to `_imp___ZN3gcn11SDLGraphicsC1Ev'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/ccIRbaaa.o:sdlhelloworld.cpp:(.text+0x290): 
undefined reference to `_imp___ZN3gcn8SDLInputC1Ev'
C:/DOCUME~1/794811~1.SEC/CONFIG~1/Temp/ccIRbaaa.o:sdlhelloworld.cpp:(.text+0x312): 
undefined reference to `_imp___ZN3gcn9ContainerC1Ev'

maybe I must set libs @ /usr/lib ???. or /mingw/lib ??

regards

Comment 3 by olof.naessen, Feb 29, 2008
I think you should see what ldconfig -v outputs, do you have SDL_image there? If not,
then SDL_image cannot be automatically found by the linker.
Comment 4 by uberiain50, Feb 29, 2008
Sorry, but mingw don't use ldconfig , and I am using SDL_image with other programs, 
and is working.

I found this http://guichan.sourceforge.net/forum/read.php?3,571,1494#msg-1494 , the 
problem is the same?.
Comment 5 by olof.naessen, Feb 29, 2008
Might be. I never use MinGW so I can't really help you with this one. Somehow the
linker needs to be able to find SDL_image, and it doesn't in your case.

How do you use SDL_image, with -lSDL_image?
Comment 6 by uberiain50, Feb 29, 2008
yes I use -lSDL_image, i see this ->http://humming.dip.jp/wiki/wiki.pl?GuiChan%
2FMinGW

 and with this 

mkdir dll
cd dll
g++ -shared -o guichan.dll ../src/.libs/*.o ../src/widgets/.libs/*.o -Wl,--out-
implib,libguichan.a
cp guichan.dll $HOME/sdl/bin
cp libguichan.a $HOME/sdl/lib
g++ -shared -o guichan_sdl.dll ../src/sdl/.libs/*.o -Wl,--out-
implib,libguichan_sdl.a -L$HOME/sdl/lib -lguichan -lSDL_image `sdl-config --libs`
cp guichan_sdl.dll $HOME/sdl/bin
cp libguichan_sdl.a $HOME/sdl/lib

the create guichan DLL I test this and the link errors are down to 3 only. I must 
test more I think.
Comment 7 by olof.naessen, Feb 29, 2008
Well keep me posted on your progress. I would be interested to know if you can solve it.
Comment 8 by uberiain50, Feb 29, 2008
Hello, i think it's working. Based on this -> http://humming.dip.jp/wiki/wiki.pl?
GuiChan%2FMinGW

I have made this:

./configure CPPFLAGS=-I=/usr/local/include LDFLAGS="-L/usr/local/lib"

result:


-------------------------------
Guichan ready for compilation!
-------------------------------
* Allegro   = disabled
* HGE       = no (Windows specific and cannot be built)
* OpenGL    = no
* OpenLayer = no (Requires static build and cannot be built)
* SDL       = yes
* SDL Image = yes
--------------------------------
I have SDL, SDL_image and SDL_ttf, SDL_mixer @ /usr/local

make
make install

guichan is istalled @ /usr/local by default

then I made:

mkdir dll
g++ -shared -o guichan.dll ../src/.libs/*.o ../src/widgets/.libs/*.o -Wl,--no
-undefined --Wl,--export-all-symbols -Wl,--out-implib,libguichan.a

-Wl,--no-undefined and -Wl,--export-all-symbols say the linker than no undefined 
symbols are allowed and export all lib symbols

this created libguichan.a and guichan.dll 
I copy this to /usr/local/lib/libguichad.a & /usr/local/bin/guichan.dll

Then I made:

g++ -shared -o guichan_sdl.dll ../src/sdl/.libs/*.o -Wl,--no-undefined -Wl,--
export-all-symbols -Wl,--out-implib,libguichan_sdl.a -L/usr/local/lib -lguichan
 -lSDL_image `sdl-config --libs`

-L/usr/local/lib tells linker where are my libs ( SDL_image and guichan )

this created libguichan_sdl.a & guichan_sdl.dll ro /usr/local/lib & /usr/local/bin

then change to example and:

make -f Makefile.examples sdl CFLAGS="-Werror -Wall -Wno-unused -I/usr/local/
include -L/usr/local/lib

remember my libs are @ /usr/local/lib

and the result is :

g++ sdlhelloworld.cpp -o sdlhelloworld -Werror -Wall -Wno-unused -
I/usr/local/include -L/usr/local/lib \
        -lguichan_sdl -lguichan -lSDL_image `sdl-config --libs --cflags`
g++ sdlwidgets.cpp -o sdlwidgets -Werror -Wall -Wno-unused -I/usr/local/include -
L/usr/local/lib \
        -lguichan_sdl -lguichan -lSDL_image `sdl-config --libs --cflags`
g++ sdlaction.cpp -o sdlaction -Werror -Wall -Wno-unused -I/usr/local/include -
L/usr/local/lib \
        -lguichan_sdl -lguichan -lSDL_image `sdl-config --libs --cflags`


And I have:

sdlaction.exe  sdlhelloworld.exe  sdlwidgets.exe

working!!!!!!!

remember guichan.dll and guichan_sdl.dll must be in the PATH of windows or in the 
same directory wehre *.exe is executed..

--------------->

I think the proble is than guichan.dll and guichan_sdl.dll is not contrusted with 
the make, maybe settings --no-undefined --export-all-symbols may help???.

regards




Comment 9 by olof.naessen, Feb 29, 2008
Excellent news!

The --noundefined --export-all-symbols thing might be the problem. I'm not really
sure how to add it to the configure scripts without compromising the scripts on other
systems though. What happens if you use this:

./configure --host=mingw32
Comment 10 by uberiain50, Feb 29, 2008
same problem with --host=mingw32, i am testing how to setup configure to produce  
dll's. If I get any result i publish they here, Ok?
Comment 11 by olof.naessen, Feb 29, 2008
Sounds good!
Comment 12 by uberiain50, Feb 29, 2008
Hello, again, i think i have one solution to this.

1.- add to configure.in test to see if we are at mingw.

case $host in

        *-*-mingw*)
                MAS_LIBTOOL_LDFLAGS="-no-undefined -Wl,--export-all-symbols"
                SDL_LIBTOOL_LDFLAGS="-L../ -lguichan -lSDL_image -lSDL"
        ;;
    *-*-linux*)
                MAS_LIBTOOL_LDFLAGS=""
                SDL_LIBTOOL_LDFLAGS=""
                ;;
    *)
        ;;
esac
AC_SUBST(MAS_LIBTOOL_LDFLAGS)
AC_SUBST(SDL_LIBTOOL_LDFLAGS)

2.- Change src/Makefile.am order ob subdirectories and add MAS_LIBTOOL_LDFLAGS to 
generate guichan lib ( guichan.dll )

SUBDIRS = widgets . @GUICHAN_EXTRADIRS@ hge openlayer

libguichan_la_LIBADD = widgets/libguichan_widgets.la $(MAS_LIBTOOL_LDFLAGS)

guichan depends on widgets lib.....

3.- change src/sdl/Makefile.am add this:

libguichan_sdl_la_LIBADD  =  $(SDL_LIBTOOL_LDFLAGS) $(MAS_LIBTOOL_LDFLAGS)

and

aclocal
autoconf
automake
./configure CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/include

make
make install

and ............. this is working !.

This generates static libs, dinamics and *.dll for guichan and guichan_sdl

I can upload this files.

Regards


Comment 13 by olof.naessen, Mar 01, 2008
The MAS_LIBTOOL_LDFLAGS="-no-undefined -Wl,--export-all-symbols" looks needed but I'm
not sure modifying Makefile.in is the correct way to add linker flags, can't you just
add the flags to the global LDFLAGS variable as all libraries want those flags?

Another thing, we can't just assume that SDL and SDL_image are present when compiling
the guichan_sdl library, we need to add those linker flags if the configure scripts
finds SDL and SDL_image. In your case SDL_image isn't found even though you have
SDL_image installed (welcome to the world of the crapy autotools...), but that's not
really a problem as you can always force the SDL_image.

By the way, are you using the SVN version of Guichan?


Comment 14 by uberiain50, Mar 01, 2008
Hello, these flags ( MAS_LIBTOOL_LDFLAGS ) are only need for the version of windows, 
for mingw create dll's, if you see configure.in I do one test to see if I am working 
with mingw and set the flags.

Yes, these flags are needed for release dll's on mingw environment, see this:

http://www.mingw.org/MinGWiki/index.php/sample%20DLL?
PHPSESSID=10ec7a86f2eef38c98168f792cead312

and for create guichan_sdl.dll you must tell linker where are the symbols not 
present's at this library ( i.e: symbols at guichan and SDL and SDL_image ) , this 
is for the mingw version only......

I am usign version 0.7.1 of guichan.

Regards

Comment 15 by olof.naessen, Mar 01, 2008
Yes I understand that they are only needed in Windows, but still, why not just add
the flags to the LDFLAGS variable if we are in Windows?

And I understand that you have to link with all libraries when producing a DLL. But
the flags should be added only if the libraries are present. So something like an
SDL_LIBS variable for SDL and ALLEGRO_LIBS for Allegro would be appropriate. They
should of course only be populated if we are in Windows. This could be easily done in
the HAVE* functions present in the configure script. 
Comment 16 by uberiain50, Mar 01, 2008
This variables are only for libraries generating DLL not for  static libraries ( 
libguichan_widgets ), LDFLAGS aplies to all link options, i think. Separate LDFLAGS 
( generic ) from MAS_LIBTOOL_LDFLAGS for libraries need DLL output  maybe more flex. 
I must test if I set --disable-shared at configure option this is working and what 
options need. Uff autotools & windows joke :)

Yes I think so, SDL_LIBS and ALLEGRO_LIBS yes, but I don't have allegro and can't 
probe this, but must be same choice.. I can download allegro and test if you want.

Use HAVE functions and test for mingw ? .It can be a solution more clean.
Comment 17 by olof.naessen, Mar 01, 2008
I see your point about static libraries, and I guess it makes sense. About other back
ends such as Allegro and OpenGL, I don't think it will be much different from how the
SDL back end should be handled.
Comment 18 by uberiain50, Mar 01, 2008
Ok, if I force --disable-shared , they don't link examples (externals not found) , 
but for me I am using dll for all (SDL SDL_image libpng , etc .. ) and with the 
changes to config and Makefiles is working. At the moment is enough for me.

Continue with the tests and if I found any solution i send there here.

Regards
Comment 19 by uberiain50, Mar 03, 2008
Hello, again, the best solution I found till now to get guichan @ mingw working is:

change src/Makefile.am 

SUBDIRS = widgets @GUICHAN_EXTRADIRS@ hge openlayer

->>

SUBDIRS = widgets . @GUICHAN_EXTRADIRS@ hge openlayer
libguichan_la_LDFLAGS= -no-undefined

add . to reflect scr directory. -no-undefined is needed for libguichan.dll 

change src/sdl/Makefile.am and add this lines:

libguichan_sdl_la_LDFLAGS = -no-undefined -Wl,--export-all-symbols
libguichan_sdl_la_LIBADD  = ../libguichan.la -lSDL_image -lSDL

needed to create a working libguichan_sdl.dll 

Regards
Comment 20 by olof.naessen, Mar 03, 2008
So, -Wl,--export-all-symbols is not needed for the main Guichan DLL?

It would be very nice to add MinGW support for the upcoming 0.8.0 release. Oh, and by
the way, many thanks for your great efforts!
Comment 21 by uberiain50, Mar 03, 2008
for the main Guichan, not needed ( at the moment :) ). I test with examples and with 
guichanffdemo and is working.

When you launch 0.8.0 I test mingw with it, ok?
Comment 22 by olof.naessen, Mar 03, 2008
Sounds great! Hopefully I can make a release this week or the upcoming week.
Sign in to add a comment

Hosted by Google Code