HackerPoet / MarbleMarcher

A Fractal Physics Game
GNU General Public License v2.0
2.47k stars 167 forks source link

Errors compiling on Ubuntu 18.04 with SFML 2.5.1 #6

Open SnowySailor opened 5 years ago

SnowySailor commented 5 years ago

I installed SFML once from source and once using the precompiled libraries for Linux here: https://www.sfml-dev.org/download/sfml/2.5.1/ (also tried 2.5.0).

Everything up until cmake --build build worked fine. Once I ran that command, however, I got the following error:

[ 87%] Linking CXX executable MarbleMarcher
CMakeFiles/MarbleMarcher.dir/src/Main.cpp.o: In function `main':
Main.cpp:(.text+0xa53): undefined reference to `sf::RenderTexture::create(unsigned int, unsigned int, sf::ContextSettings const&)'
Main.cpp:(.text+0xa8f): undefined reference to `sf::RenderWindow::setActive(bool)'
src/libMarbleMarcherSources.a(Overlays.cpp.o): In function `Overlays::UpdateMenu(float, float)':
Overlays.cpp:(.text+0x913): undefined reference to `sf::Text::setLineSpacing(float)'
Overlays.cpp:(.text+0x92d): undefined reference to `sf::Text::setLineSpacing(float)'
src/libMarbleMarcherSources.a(Overlays.cpp.o): In function `Overlays::UpdateControls(float, float)':
Overlays.cpp:(.text+0xa5c): undefined reference to `sf::Text::setLineSpacing(float)'
Overlays.cpp:(.text+0xa76): undefined reference to `sf::Text::setLineSpacing(float)'
src/libMarbleMarcherSources.a(Overlays.cpp.o): In function `Overlays::DrawCredits(sf::RenderWindow&)':
Overlays.cpp:(.text+0x1a92): undefined reference to `sf::Text::setLineSpacing(float)'
src/libMarbleMarcherSources.a(Overlays.cpp.o): In function `Overlays::MakeText(char const*, float, float, float, sf::Color const&, sf::Text&, bool)':
Overlays.cpp:(.text+0x1e2f): undefined reference to `sf::Text::setLetterSpacing(float)'
src/libMarbleMarcherSources.a(SelectRes.cpp.o): In function `SelectRes::MakeText(char const*, float, float, int, bool, bool) const':
SelectRes.cpp:(.text+0x72a): undefined reference to `sf::Text::setLetterSpacing(float)'
collect2: error: ld returned 1 exit status
CMakeFiles/MarbleMarcher.dir/build.make:95: recipe for target 'MarbleMarcher' failed
make[2]: *** [MarbleMarcher] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/MarbleMarcher.dir/all' failed
make[1]: *** [CMakeFiles/MarbleMarcher.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Seems to be something to do with SFML, but I'm not sure exactly what. I thought it was something to do with the specific library I installed, but I got the same error when using the precompiled one. Any ideas?

Thanks

HackerPoet commented 5 years ago

SFML supports 2 types of libraries, static and dynamic, and this error can occur if you mix them. I use static libraries in my builds with the SFML_STATIC preprocessor flag, not sure if the same is true on Linux...

tatsujb commented 5 years ago

@SnowySailor can you explain to me how you installed SFML, the contents of the downloaded zip make no sense. I too use ubuntu and I have no idea how to get this game up and running.

here's what i tried :

git clone https://github.com/HackerPoet/MarbleMarcher.git
git checkout shader-backport #did not work
sudo apt install cmake libeigen3-dev libsfml-dev libboost-dev libboost-system-dev libboost-filesystem-dev
cd MarbleMarcher/
mkdir build
cmake -SFML_STATIC
# OUTPUT :
#-- The C compiler identification is GNU 8.2.0
#-- The CXX compiler identification is GNU 8.2.0
#-- Check for working C compiler: /usr/bin/cc
#-- Check for working C compiler: /usr/bin/cc -- works
#-- Detecting C compiler ABI info
#-- Detecting C compiler ABI info - done
#-- Detecting C compile features
#-- Detecting C compile features - done
#-- Check for working CXX compiler: /usr/bin/c++
#-- Check for working CXX compiler: /usr/bin/c++ -- works
#-- Detecting CXX compiler ABI info
#-- Detecting CXX compiler ABI info - done
#-- Detecting CXX compile features
#-- Detecting CXX compile features - done
#-- Found SFML 2.5.0 in /usr/lib/x86_64-linux-gnu/cmake/SFML
#-- Configuring done
#-- Generating done
#-- Build files have been written to: /home/t/MarbleMarcher/MarbleMarcher
cmake --build build
# OUTPUT :
#Error: could not load cache

if i understand correctly in order to have the two dependencies : eigen3 and sfml

libeigen3-dev and libsfml-dev are suitable libs.

nottux commented 5 years ago

you will need libsfml 2.5 packages and ubuntu 18.04 repositories doesn't have them, i downloaded .deb packages from ubuntu 18.10 repositories if you have libsfml 2.5 packages remove -SFML_STATIC and build again hope it helps ;)

eacousineau commented 5 years ago

BTW I was able to get this to build on Ubuntu 18.04 w/ SFML 2.5.1 (but building from source), and submitted this PR: #39

Not sure if it'll resolve the static vs. shared linking, but it at least gets things going.

ghost commented 5 years ago

@tuxutku Could you link to the deb, please?

nottux commented 5 years ago

off course @Modanung https://pkgs.org/download/libsfml-audio2.5 https://pkgs.org/download/libsfml-system2.5 https://pkgs.org/download/libsfml-window2.5 https://pkgs.org/download/libsfml-network2.5 https://pkgs.org/download/libsfml-graphics2.5 https://pkgs.org/download/libsfml-dev WARNING: don't forget to download for the right distro WARNING: you have to install all WARNING: you have to download 2.5.0 version of the libsfml-dev or it will conflict

gr4viton commented 5 years ago

As i was not sure and it took me some time to get it working i am gonna post a summary.

How to build and run MarbleMarcher on Ubuntu 18.04