oprypin / crsfml

Crystal bindings to SFML multimedia/game library
https://oprypin.github.io/crsfml
zlib License
350 stars 14 forks source link

FindSFML.cmake required to build VoidCSFML SFML v2.5.x #29

Closed andrewoconnor closed 5 years ago

andrewoconnor commented 5 years ago

OS: OSX 10.13.6 High Sierra

FindSFML.cmake is no longer included with SFML v2.5.x (see here). I had to copy FindSFML.cmake from my old install for VoidCSFML to work.

I wanted to try SF::Cursor, a SFML v2.5.x feature but realized brew only installs 2.4.2

I tried upgrading to v2.5.1 using a formula that has not been merged yet:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e057f60014c3f95710542915df6ba763ee57923b/Formula/sfml.rb

Next I tried building VoidCSFML:

crystal run generate.cr -- /usr/local/opt/sfml/include
cmake . && make

And I got linking errors. The new v2.5.x directory structure is a little different. Modules are now found in:

/usr/local/opt/sfml/lib/cmake/SFML

I had to create the cmake dir in /usr/local/opt/sfml/share/sfml and create a symlink to the correct dir:

cd /usr/local/opt/sfml/share/sfml
mkdir cmake
cd cmake
ln -s /usr/local/opt/sfml/lib/cmake/SFML Modules

So I tried copying it from my old SFML install to the new one. And it worked:

cp /old/path/FindSFML.cmake /usr/local/opt/sfml/lib/cmake/SFML

Then I could build VoidCSFML without issues and got to enjoy my fancy new cursor.

oprypin commented 5 years ago

First of all, the title is false. "FindSFML.cmake" doesn't exist on Arch Linux but everything just works. There are also no references to it in the code.

Just try to carefully follow the instructions and troubleshooting.

It is still possible that something is wrong, but even so, there is nothing actionable for me just based on the current contents of this issue because I don't have a Mac.

oprypin commented 5 years ago

Relevant change: https://github.com/oprypin/crsfml/commit/47cff9b0cdcb6fc1b9eea22164ffcb2ccfae88b0

andrewoconnor commented 5 years ago

I tried those methods initially. To me it looks like the arguments being passed in are not used.

cmake version 3.13.2

➜ crsfml master ✗ sfml=(/usr/local/Cellar/sfml/2.*)          
cmake -DSFML_INCLUDE_DIR="$sfml/include" -DCMAKE_MODULE_PATH="$sfml/lib/cmake/SFML" . && make
-- The C compiler identification is AppleClang 10.0.0.10001044
-- The CXX compiler identification is AppleClang 10.0.0.10001044
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/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.1 in /usr/local/lib/cmake/SFML
-- Found SFML 2.5.1 in /usr/local/lib/cmake/SFML
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/crsfml
Scanning dependencies of target c-sources
[  8%] Generating voidcsfml/include/voidcsfml/system.h, voidcsfml/src/voidcsfml/system.cpp, voidcsfml/include/voidcsfml/window.h, voidcsfml/src/voidcsfml/window.cpp, voidcsfml/include/voidcsfml/graphics.h, voidcsfml/src/voidcsfml/graphics.cpp, voidcsfml/include/voidcsfml/audio.h, voidcsfml/src/voidcsfml/audio.cpp, voidcsfml/include/voidcsfml/network.h, voidcsfml/src/voidcsfml/network.cpp, src/system/lib.cr, src/system/obj.cr, src/window/lib.cr, src/window/obj.cr, src/graphics/lib.cr, src/graphics/obj.cr, src/audio/lib.cr, src/audio/obj.cr, src/network/lib.cr, src/network/obj.cr
[  8%] Built target c-sources
Scanning dependencies of target voidcsfml-window
[ 16%] Building CXX object voidcsfml/CMakeFiles/voidcsfml-window.dir/src/voidcsfml/window.cpp.o
[ 25%] Linking CXX shared library libvoidcsfml-window.dylib
Undefined symbols for architecture x86_64:
  "sf::Mouse::getPosition(sf::Window const&)", referenced from:
      _sfml_mouse_getposition_JRh in window.cpp.o
  "sf::Mouse::getPosition()", referenced from:
      _sfml_mouse_getposition in window.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [voidcsfml/libvoidcsfml-window.2.5.dylib] Error 1
make[1]: *** [voidcsfml/CMakeFiles/voidcsfml-window.dir/all] Error 2
make: *** [all] Error 2
oprypin commented 5 years ago

BTW, this library is being continuously built on Travis, so as least following the exact commands should work

https://github.com/oprypin/crsfml/blob/master/.travis.yml

oprypin commented 5 years ago

The instructions include a minimal set of flags which is enough for 2.5 on Linux and 2.4 on Mac but apparently that's now incomplete.

oprypin commented 5 years ago

Ah but that is using SFML from Homebrew, which is apparently still at 2.4?? I forgot that you brought this up. So yeah, there could be a problem.

Still worth trying the commands from Travis though. I.e. treat it as an install to a local directory.

And if that doesn't work, honestly I'll likely not follow up on this, at least until Homebrew updates.

andrewoconnor commented 5 years ago

The brew formula was finally updated to sfml 2.5.1

I can confirm that everything works and the workaround above is not needed.