Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problems Using SFML Compiled from Source  (Read 1806 times)

0 Members and 1 Guest are viewing this topic.

timothy.s.dev

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problems Using SFML Compiled from Source
« on: February 02, 2013, 05:24:31 am »
I've grown rather fond of both g++ and make on Linux (I blame my data-structures professor :P ), but my primary computer runs windows as I play quite a few games.  So, I've set up a build environment on windows that uses makefiles with g++.  Obviously, I ran into the usual errors when trying to use the existing binaries (figured it was worth a shot :P ), so I went to compile SFML from the source.  To do this I pulled the makefiles from the Linux distribution, and adjusted them (shifted the platform from Linux to Win32 everywhere  it was mentioned).  After a couple problems getting the dependencies in the right place, everything worked perfectly:

H:\code\lib\SFML-1.6>make
make[1]: Entering directory `H:/code/lib/SFML-1.6/src/SFML'
make[2]: Entering directory `H:/code/lib/SFML-1.6/src/SFML/System'
ar rcs ../../../lib/libsfml-system-s.a Clock.o Lock.o Sleep.o Randomizer.o Unicode.o ./Win32/Mutex.o ./Win32/Platform.o ./Win32/Thread.o
make[2]: Leaving directory `H:/code/lib/SFML-1.6/src/SFML/System'
make[2]: Entering directory `H:/code/lib/SFML-1.6/src/SFML/Window'
ar rcs ../../../lib/libsfml-window-s.a WindowImpl.o Context.o Window.o VideoMode.o Input.o ./Win32/WindowImplWin32.o ./Win32/Joystick.o ./Win32/VideoModeSupport.o
make[2]: Leaving directory `H:/code/lib/SFML-1.6/src/SFML/Window'
make[2]: Entering directory `H:/code/lib/SFML-1.6/src/SFML/Network'
ar rcs ../../../lib/libsfml-network-s.a Ftp.o SocketUDP.o SelectorBase.o SocketTCP.o Packet.o IPAddress.o Http.o ./Win32/SocketHelper.o
make[2]: Leaving directory `H:/code/lib/SFML-1.6/src/SFML/Network'
make[2]: Entering directory `H:/code/lib/SFML-1.6/src/SFML/Graphics'
ar rcs ../../../lib/libsfml-graphics-s.a Font.o FontLoader.o Drawable.o RenderTarget.o Matrix3.o String.o RenderWindow.o ImageLoader.o View.o PostFX.o Shape.o GraphicsContext.o Image.o Color.o Sprite.o ./GLEW/glew.o ./libjpeg/jcapistd.o ./libjpeg/jerror.o ./libjpeg/jdinput.o ./libjpeg/jdhuff.o ./libjpeg/jmemnobs.o ./libjpeg/jcmaster.o ./libjpeg/jcapimin.o ./libjpeg/jcomapi.o ./libjpeg/jdsample.o ./libjpeg/jcmarker.o ./libjpeg/jidctint.o ./libjpeg/jdphuff.o ./libjpeg/jdcoefct.o ./libjpeg/jchuff.o ./libjpeg/jdtrans.o ./libjpeg/jcdctmgr.o ./libjpeg/jdmaster.o ./libjpeg/jcparam.o ./libjpeg/jdatadst.o ./libjpeg/jdmainct.o ./libjpeg/jfdctint.o ./libjpeg/jcsample.o ./libjpeg/jidctfst.o ./libjpeg/jidctflt.o ./libjpeg/jddctmgr.o ./libjpeg/jdatasrc.o ./libjpeg/jcphuff.o ./libjpeg/jdpostct.o ./libjpeg/jdapistd.o ./libjpeg/jfdctfst.o ./libjpeg/jfdctflt.o ./libjpeg/jctrans.o ./libjpeg/jquant1.o ./libjpeg/jquant2.o ./libjpeg/jdmerge.o ./libjpeg/jdcolor.o ./libjpeg/jmemmgr.o ./libjpeg/jcprepct.o ./libjpeg/jcmainct.o ./libjpeg/jcinit.o ./libjpeg/jutils.o ./libjpeg/jdmarker.o ./libjpeg/jdapimin.o ./libjpeg/jidctred.o ./libjpeg/jccoefct.o ./libjpeg/jccolor.o ./libpng/pngrio.o ./libpng/pngget.o ./libpng/pngread.o ./libpng/pngpread.o ./libpng/pngset.o ./libpng/pngwrite.o ./libpng/pngrtran.o ./libpng/pngerror.o ./libpng/pngtrans.o ./libpng/pnggccrd.o ./libpng/png.o ./libpng/pngwio.o ./libpng/pngvcrd.o ./libpng/pngmem.o ./libpng/pngwtran.o ./libpng/pngwutil.o ./libpng/pngrutil.o ./SOIL/SOIL.o ./SOIL/stb_image_aug.o .
/SOIL/image_DXT.o ./zlib/compress.o ./zlib/inftrees.o ./zlib/crc32.o ./zlib/trees.o ./zlib/inflate.o ./zlib/adler32.o ./zlib/inffast.o ./zlib/zutil.o ./zlib/uncompr.o ./zlib/deflate.o
make[2]: Leaving directory `H:/code/lib/SFML-1.6/src/SFML/Graphics'
make[2]: Entering directory `H:/code/lib/SFML-1.6/src/SFML/Audio'
ar rcs ../../../lib/libsfml-audio-s.a SoundFileOgg.o SoundStream.o SoundFile.o Music.o SoundFileDefault.o SoundBuffer.o SoundRecorder.o AudioResource.o Sound.o SoundBufferRecorder.o AudioDevice.o Listener.o ./stb_vorbis/stb_vorbis.o
make[2]: Leaving directory `H:/code/lib/SFML-1.6/src/SFML/Audio'
make[1]: Leaving directory `H:/code/lib/SFML-1.6/src/SFML'

From there, I moved the libraries (compiled to be static, so no DLLs, ran into trouble trying to compile dynamic libraries... if this becomes important I'll post those errors as well) and include files over to the project folder, linked, and tried  to compile.  After fixing some minor errors, the system clock example from the website worked perfectly.  However, as soon as I start using Graphics/Windows I get a whole slew of compile errors, mostly related to undefined symbols (which appear to be windows specific?)

H:\code\cpp\smfl_test>make
g++ -c -Wall -o obj/main.o src/main.cpp -I./include
In file included from ./include/SFML/System/Resource.hpp:211:0,
                 from ./include/SFML/Graphics/Font.hpp:31,
                 from ./include/SFML/Graphics.hpp:34,
                 from src/main.cpp:2:
./include/SFML/System/ResourcePtr.inl:25:0: warning: "NULL" redefined [enabled by default]
c:\mingw-4.6.1\bin\../lib/gcc/mingw32/4.6.1/include/stddef.h:399:0: note: this is the location of the previous definition

g++ -o ./bin/game.exe obj/main.o lib/libsfml-window-s.a lib/libsfml-system-s.a -I./include
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x34): undefined reference to `wglGetProcAddress@4'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x233): undefined reference to `SwapBuffers@4'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x260): undefined reference to `wglGetCurrentContext@0'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x27c): undefined reference to `wglMakeCurrent@8'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x289): undefined reference to `wglGetCurrentContext@0'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x2a5): undefined reference to `wglMakeCurrent@8'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x5bc): undefined reference to `wglGetCurrentContext@0'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x811): undefined reference to `ChoosePixelFormat@8'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x85d): undefined reference to `DescribePixelFormat@16'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x88f): undefined reference to `SetPixelFormat@12'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x8a4): undefined reference to `wglCreateContext@4'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x8b8): undefined reference to `wglGetCurrentContext@0'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x8ce): undefined reference to `wglShareLists@8'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x8f4): undefined reference to `glEnable@4'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x974): undefined reference to `wglGetProcAddress@4'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0xafe): undefined reference to `DescribePixelFormat@16'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x1058): undefined reference to `wglDeleteContext@4'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x22d7): undefined reference to `GetDeviceCaps@8'
lib/libsfml-window-s.a(WindowImplWin32.o):WindowImplWin32.cpp:(.text+0x22fd): undefined reference to `GetDeviceCaps@8'
lib/libsfml-window-s.a(Joystick.o):Joystick.cpp:(.text+0x84): undefined reference to `joyGetPosEx@8'
lib/libsfml-window-s.a(Joystick.o):Joystick.cpp:(.text+0xba): undefined reference to `joyGetDevCapsA@12'
lib/libsfml-window-s.a(Joystick.o):Joystick.cpp:(.text+0x19b): undefined reference to `joyGetDevCapsA@12'
lib/libsfml-window-s.a(Joystick.o):Joystick.cpp:(.text+0x1da): undefined reference to `joyGetPosEx@8'
collect2: ld returned 1 exit status

Any thoughts or tips would be very much appreciated.  If I can get this working, I would be more than happy to write up a quick tutorial for anyone else interested in compiling SFML using/for g++ on windows.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Problems Using SFML Compiled from Source
« Reply #1 on: February 02, 2013, 09:41:53 am »
Static libs are not linked to their dependencies (unless you use my custom build scripts), so you need to link all SFML dependencies to your final app.

But seriously, just use SFML 2. You're wasting your time with 1.6.
Laurent Gomila - SFML developer

timothy.s.dev

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Problems Using SFML Compiled from Source
« Reply #2 on: February 02, 2013, 08:39:26 pm »
Ah, thank you very much - didn't realize there was already a GCC on windows build for 2.0!  Works perfectly now; may go back and try linking to the dependencies, simply as an academic exercise... thanks again!

 

anything