sanyaade-g2g-repos / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

Guichan SDL and mingw #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by uberiai...@gmail.com on 29 Feb 2008 at 11:41

GoogleCodeExporter commented 9 years ago
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.

Original comment by olof.nae...@gmail.com on 29 Feb 2008 at 12:42

GoogleCodeExporter commented 9 years ago
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

Original comment by uberiai...@gmail.com on 29 Feb 2008 at 3:52

GoogleCodeExporter commented 9 years ago
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.

Original comment by olof.nae...@gmail.com on 29 Feb 2008 at 4:35

GoogleCodeExporter commented 9 years ago
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?.

Original comment by uberiai...@gmail.com on 29 Feb 2008 at 5:06

GoogleCodeExporter commented 9 years ago
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?

Original comment by olof.nae...@gmail.com on 29 Feb 2008 at 5:32

GoogleCodeExporter commented 9 years ago
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.

Original comment by uberiai...@gmail.com on 29 Feb 2008 at 5:49

GoogleCodeExporter commented 9 years ago
Well keep me posted on your progress. I would be interested to know if you can 
solve it.

Original comment by olof.nae...@gmail.com on 29 Feb 2008 at 6:06

GoogleCodeExporter commented 9 years ago
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

Original comment by uberiai...@gmail.com on 29 Feb 2008 at 7:06

GoogleCodeExporter commented 9 years ago
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

Original comment by olof.nae...@gmail.com on 29 Feb 2008 at 7:12

GoogleCodeExporter commented 9 years ago
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?

Original comment by uberiai...@gmail.com on 29 Feb 2008 at 7:28

GoogleCodeExporter commented 9 years ago
Sounds good!

Original comment by olof.nae...@gmail.com on 29 Feb 2008 at 8:25

GoogleCodeExporter commented 9 years ago
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

Original comment by uberiai...@gmail.com on 1 Mar 2008 at 12:24

GoogleCodeExporter commented 9 years ago
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?

Original comment by olof.nae...@gmail.com on 1 Mar 2008 at 10:56

GoogleCodeExporter commented 9 years ago
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

Original comment by uberiai...@gmail.com on 1 Mar 2008 at 12:09

GoogleCodeExporter commented 9 years ago
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. 

Original comment by olof.nae...@gmail.com on 1 Mar 2008 at 1:12

GoogleCodeExporter commented 9 years ago
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.

Original comment by uberiai...@gmail.com on 1 Mar 2008 at 1:57

GoogleCodeExporter commented 9 years ago
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.

Original comment by olof.nae...@gmail.com on 1 Mar 2008 at 2:28

GoogleCodeExporter commented 9 years ago
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

Original comment by uberiai...@gmail.com on 1 Mar 2008 at 9:08

GoogleCodeExporter commented 9 years ago
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

Original comment by uberiai...@gmail.com on 3 Mar 2008 at 11:53

GoogleCodeExporter commented 9 years ago
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!

Original comment by olof.nae...@gmail.com on 3 Mar 2008 at 12:10

GoogleCodeExporter commented 9 years ago
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?

Original comment by uberiai...@gmail.com on 3 Mar 2008 at 12:18

GoogleCodeExporter commented 9 years ago
Sounds great! Hopefully I can make a release this week or the upcoming week.

Original comment by olof.nae...@gmail.com on 3 Mar 2008 at 12:55

GoogleCodeExporter commented 9 years ago
I know that this thread is a little old at this point, but would it be possible 
to 
consolidate the info re: building in Windows and add it to the INSTALL file?

Original comment by holy.smo...@gmail.com on 23 Mar 2010 at 2:24

GoogleCodeExporter commented 9 years ago
Probably.

Original comment by olof.nae...@gmail.com on 23 Mar 2010 at 4:53