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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - igorko

Pages: [1]
1
General / Re: Static linking under Linux
« on: May 07, 2012, 08:22:05 pm »
Ok. I have fixed it. First of all seems like

Code: [Select]
g++ app.cpp -o app -lpthread -lX11 -lGL -lXrandr -lfreetype -lsfml-graphics -lsfml-window -lsfml-system
is wrong (at least on ubuntu 12.04)

Here is part of final cmakelists.txt that does work:

Code: [Select]
add_Executable (Holyspirit ${GAME_SOURCES})

# add an option for choosing the build type of SFML(shared or static)
set_option(SFML_STATIC_LIBRARIES TRUE BOOL "TRUE to build SFML as static libraries, FALSE to build it as shared libraries")

# Detect and add SFML
find_package(SFML 2.0 REQUIRED system window graphics network audio)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
list(APPEND LINKS
${GNUWIN_LIBRARY} ${SFML_AUDIO_LIBRARY} ${SFML_NETWORK_LIBRARY} ${SFML_GRAPHICS_LIBRARY} ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY})
endif()

#If game doesn't build try to put next IF statement before SFML detection
if (NOT WIN32 AND SFML_STATIC_LIBRARIES)

#This can be used if your distro can't find needed libraries
#find_package(OpenGL REQUIRED) ${OPENGL_gl_LIBRARY}
#find_package(Freetype REQUIRED) ${FREETYPE_LIBRARY}
#find_package(GLEW REQUIRED) ${GLEW_LIBRARY}
#find_package(JPEG REQUIRED) ${JPEG_LIBRARY}
#find_package(X11 REQUIRED) ${X11_LIBRARIES}
#find_package(OpenAL REQUIRED) ${OPENAL_LIBRARY}
#find_package(Sndfile REQUIRED) ${SNDFILE_LIBRARY}

list(APPEND LINKS
#if needed uncomment those
#pthread
#X11
#GL
Xrandr
freetype
GLEW
jpeg
sndfile
openal
)
endif()


target_link_libraries(Holyspirit ${LINKS})

linking to pthread-openal libs BEFORE linking to SFML worked under ubuntu 8.04 without problems. But under ubuntu 12.04 i should link to these libs AFTER linking with SFML. Also if i link after SFML, some libs(commented out) are not needed at all on both systems(but were needed on ubuntu 8.04 in previous case)

2
General / Re: Lots of unresolved externals...
« on: April 12, 2012, 07:28:30 am »
I think your problem is you are using #include <SFML\Graphics.hpp> but you need #include <Window.hpp> (or both?). Also don't link your app with SFML libs you are not using.

3
General / Re: Static linking under Linux
« on: April 11, 2012, 10:21:02 pm »
See my first post. It works under Ubuntu 10.04. Now i have tried to add find_package and replaced lib names with vars but no success... Looks like 12.04 is still buggy.

4
General / Re: Static linking under Linux
« on: April 10, 2012, 06:42:14 pm »
Code: [Select]
||=== Holyspirit, all ===|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Listener.cpp.o)||In function `sf::Listener::setGlobalVolume(float)':|
Listener.cpp|| undefined reference to `alListenerf'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Listener.cpp.o)||In function `sf::Listener::getGlobalVolume()':|
Listener.cpp|| undefined reference to `alGetListenerf'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Listener.cpp.o)||In function `sf::Listener::setPosition(float, float, float)':|
Listener.cpp|| undefined reference to `alListener3f'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Listener.cpp.o)||In function `sf::Listener::setPosition(sf::Vector3<float> const&)':|
Listener.cpp|| undefined reference to `alListener3f'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Listener.cpp.o)||In function `sf::Listener::getPosition()':|
Listener.cpp|| undefined reference to `alGetListener3f'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Listener.cpp.o)||In function `sf::Listener::setDirection(float, float, float)':|
Listener.cpp|| undefined reference to `alListenerfv'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Listener.cpp.o)||In function `sf::Listener::setDirection(sf::Vector3<float> const&)':|
Listener.cpp|| undefined reference to `alListenerfv'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Listener.cpp.o)||In function `sf::Listener::getDirection()':|
Listener.cpp|| undefined reference to `alGetListenerfv'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::~Sound()':|
Sound.cpp|| undefined reference to `alSourceStop'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::~Sound()':|
Sound.cpp|| undefined reference to `alSourceStop'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::Sound(sf::SoundBuffer const&)':|
Sound.cpp|| undefined reference to `alSourcei'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::Sound(sf::Sound const&)':|
Sound.cpp|| undefined reference to `alSourcei'|
Sound.cpp|| undefined reference to `alGetSourcei'|
Sound.cpp|| undefined reference to `alSourcei'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::setBuffer(sf::SoundBuffer const&)':|
Sound.cpp|| undefined reference to `alSourceStop'|
Sound.cpp|| undefined reference to `alSourcei'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::setLoop(bool)':|
Sound.cpp|| undefined reference to `alSourcei'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::setPlayingOffset(sf::Time)':|
Sound.cpp|| undefined reference to `alSourcef'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::getLoop() const':|
Sound.cpp|| undefined reference to `alGetSourcei'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::getPlayingOffset() const':|
Sound.cpp|| undefined reference to `alGetSourcef'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::operator=(sf::Sound const&)':|
Sound.cpp|| undefined reference to `alSourceStop'|
Sound.cpp|| undefined reference to `alSourcei'|
Sound.cpp|| undefined reference to `alGetSourcei'|
Sound.cpp|| undefined reference to `alSourcei'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::resetBuffer()':|
Sound.cpp|| undefined reference to `alSourceStop'|
Sound.cpp|| undefined reference to `alSourcei'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::play()':|
Sound.cpp|| undefined reference to `alSourcePlay'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::pause()':|
Sound.cpp|| undefined reference to `alSourcePause'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(Sound.cpp.o)||In function `sf::Sound::stop()':|
Sound.cpp|| undefined reference to `alSourceStop'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundBuffer.cpp.o)||In function `sf::SoundBuffer::update(unsigned int, unsigned int) [clone .part.18]':|
SoundBuffer.cpp|| undefined reference to `alBufferData'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundBuffer.cpp.o)||In function `sf::SoundBuffer::saveToFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const':|
SoundBuffer.cpp|| undefined reference to `alGetBufferi'|
SoundBuffer.cpp|| undefined reference to `alGetBufferi'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundBuffer.cpp.o)||In function `sf::SoundBuffer::getSampleRate() const':|
SoundBuffer.cpp|| undefined reference to `alGetBufferi'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundBuffer.cpp.o)||In function `sf::SoundBuffer::getChannelCount() const':|
SoundBuffer.cpp|| undefined reference to `alGetBufferi'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundBuffer.cpp.o)||In function `sf::SoundBuffer::SoundBuffer()':|
SoundBuffer.cpp|| undefined reference to `alGenBuffers'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundBuffer.cpp.o)||In function `sf::SoundBuffer::SoundBuffer(sf::SoundBuffer const&)':|
SoundBuffer.cpp|| undefined reference to `alGenBuffers'|
SoundBuffer.cpp|| undefined reference to `alGetBufferi'|
SoundBuffer.cpp|| undefined reference to `alGetBufferi'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundBuffer.cpp.o)||In function `sf::SoundBuffer::~SoundBuffer()':|
SoundBuffer.cpp|| undefined reference to `alDeleteBuffers'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundBuffer.cpp.o)||In function `sf::SoundBuffer::operator=(sf::SoundBuffer const&)':|
SoundBuffer.cpp|| undefined reference to `alGenBuffers'|
SoundBuffer.cpp|| undefined reference to `alGetBufferi'|
SoundBuffer.cpp|| undefined reference to `alGetBufferi'|
SoundBuffer.cpp|| undefined reference to `alDeleteBuffers'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundSource.cpp.o)||In function `sf::SoundSource::~SoundSource()':|
SoundSource.cpp|| undefined reference to `alSourcei'|
SoundSource.cpp|| undefined reference to `alDeleteSources'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundSource.cpp.o)||In function `sf::SoundSource::~SoundSource()':|
SoundSource.cpp|| undefined reference to `alSourcei'|
SoundSource.cpp|| undefined reference to `alDeleteSources'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundSource.cpp.o)||In function `sf::SoundSource::SoundSource()':|
SoundSource.cpp|| undefined reference to `alGenSources'|
SoundSource.cpp|| undefined reference to `alSourcei'|
/home/igor/SFML/Build/lib/libsfml-audio-s.a(SoundSource.cpp.o)||In function `sf::SoundSource::SoundSource(sf::SoundSource const&)':|
SoundSource.cpp|| undefined reference to `alGenSources'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|
while project links with openal and sfml audio was built successfully...

5
General / Re: Static linking under Linux
« on: April 10, 2012, 12:04:36 pm »
System/CmakeLists.txt

if(UNIX)
    set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} pthread)
endif()
if(LINUX)
    set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} rt)
endif()

Linux doesn't use pthread? Interested because the same binary(with static sfml) has some problems with libxcb... But rt(dunno what it is) is not listed in dependencies list, only pthread...

6
General / Re: Static linking under Linux
« on: April 10, 2012, 11:04:26 am »
How SFML does search for opengl? Don't see that code... Only for GLEW.

7
General / Static linking under Linux
« on: April 10, 2012, 07:35:57 am »
Yes, i have found this topic ;)
http://en.sfml-dev.org/forums/index.php?topic=280

And i have added next code to CmakeLists.txt even before i found it.

if (NOT WIN32 AND SFML_STATIC_LIBRARIES)
list(APPEND LINKS
   pthread
   GL
   X11
   Xrandr
   freetype
   GLEW
   jpeg
   sndfile
   openal
)
endif()

And this fixed linking with static sfml (the game http://sourceforge.net/projects/lechemindeladam/develop) under Ubuntu 10.04. But when i tried to build the same code under Xubuntu 12.04 beta static SFML was built ok, but linking the game with sfml gave "cannot found -lGL". When removing linking with GL i get unresolved external... you know...

SFML used: master branch.
IDE: Code::Blocks.

Code::Blocks under Windows + MinGW doesn't need to link twice with opengl and company.(it's known) but i wonder how does it work: SFML links ok with -lGL but game doesn't.

Maybe it's just because 12.04 is still beta but maybe SFML finds opengl in some tricky way under linux. I didn't find corresponding code in cmake scripts(maybe I just looked too less)

If you will ask why i do need to link with sfml statically i have answer: it's not released yet :/ and i want to have portable binary.

Pages: [1]