SFML community forums

Bindings - other languages => C => Topic started by: krzat on January 08, 2014, 08:45:13 pm

Title: CSFML cmake broken?
Post by: krzat on January 08, 2014, 08:45:13 pm
I've built CSFML on windows few times and it has never been smooth (as opposed to SFML). This (http://en.sfml-dev.org/forums/index.php?topic=9594.0) solution sort of works, but is ugly.

My steps:
1. Clone both repos to some folder
2. Configure, build and install SFML to C:\Program Files (x86)\SFML with VS2012 as x86 shared release.
3. Configure CSFML in cmake:
a. add CMAKE_MODULE_PATH as C:\Program Files (x86)\SFML\cmake\Modules
b. Result:  SFML found but some of its dependencies are missing ( FreeType GLEW libjpeg
c. Add SFML_ROOT as C:/Program Files (x86)/SFML - why FindSFML needs standard path?
d. Result: Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY

EDIT: Ok, I get it: SFML should be static, and CSFML shared. Perhaps some helpful message when trying to build shared on shared? And SFML_ROOT should not be needed if library is in default directory.
Title: AW: CSFML cmake broken?
Post by: eXpl0it3r on January 09, 2014, 08:01:27 am
You need to understand how the C binding works. CSFML is a C library with a C API & ABI, but it includes the full C++ library within itself, thus SFML needs to be build statically. ;)

Although CMake sets a "default" path, I wouldn't ever suggest to install you libraries into the program directory. That dir is already rather cluttered with other stuff, it is intended for actual applications and you can run into permission issues.
As such I feel like there's no need to search there. ;)
Title: Re: CSFML cmake broken?
Post by: myl on May 21, 2014, 10:02:09 pm
Hey.

I agree with the above. It would really be nice with a step by step guide to building CSFML. I've done it before, but it is never a breeze like SFML.

My current goal is to have the .Net binding (that uses CSFML) working on iOS. For this to happen, I've:
1. Cloned SFML repo
2. Used CMake to generate build scripts for iOS by adding the parameter IOS to true.
3. Built SFML in xcode
4. Cloned CSFML
5. I've stalled at CMake of CSFML. What parameters should be set to what exactly? I've tried adding CMAKE_MODULE_PATH to SFML/cmake/Modules where SFML is the path of cloned SFML repo. I get "Could NOT find SFML" from FindSFML.cmake .

Help is appreciated!

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 21, 2014, 11:01:12 pm
Quote
My current goal is to have the .Net binding (that uses CSFML) working on iOS.
You'll never be able to do that. iOS only accepts static libraries, and CSFML / SFML.Net is full of shared libraries, and nothing can be done about it.
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 10:27:48 am
You'll never be able to do that. iOS only accepts static libraries, and CSFML / SFML.Net is full of shared libraries, and nothing can be done about it.

So you are saying it will never be possible to build CSFML statically for iOS? The .Net bridge from there shouldn't cause major problems:
Quote
Xamarin.iOS supports linking with both native C libraries and Objective-C libraries.
(from http://docs.xamarin.com/guides/ios/advanced_topics/native_interop/)

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 22, 2014, 10:39:09 am
Maybe it is possible, with some hacks. I don't know. I've never done it, actually. So... go ahead and try ;)
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 10:49:05 am
Maybe it is possible, with some hacks. I don't know. I've never done it, actually. So... go ahead and try ;)

Hahaha, you don't sound very convinced :)

Do you mean hacks when compiling CSFML statically for iOS? Or hacks with the .Net binding?

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 22, 2014, 10:53:43 am
I have no idea. The best way to know which problems you'd face is to try it ;)
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 11:07:24 am
Heheh, on it!

But I've stalled at CMake of CSFML. What parameters should be set to what exactly? I've tried adding CMAKE_MODULE_PATH to SFML/cmake/Modules where SFML is the path of cloned SFML repo. I get "Could NOT find SFML" from FindSFML.cmake .

I also tried setting SFML_ROOT to the path of my freshly built SFML for iOS libs.

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 22, 2014, 11:12:45 am
Quote
I also tried setting SFML_ROOT to the path of my freshly built SFML for iOS libs.
And what was the exact error message after you did it?
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 11:33:06 am
The error message i get:

CMake Error at /Users/myl/Projects/beat/github/SFML/cmake/Modules/FindSFML.cmake:307 (message):
  Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY
  SFML_NETWORK_LIBRARY SFML_GRAPHICS_LIBRARY SFML_AUDIO_LIBRARY)
Call Stack (most recent call first):
  src/SFML/CMakeLists.txt:24 (find_package)


Configuring incomplete, errors occurred!
See also "/Users/myl/Projects/beat/github/CSFMLiOS/CMakeFiles/CMakeOutput.log".


myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 22, 2014, 11:43:21 am
And what's inside the SFML_ROOT directory? Make sure it is a proper install, not just your build directory.
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 11:46:24 am
That must be the problem. I am just using the build directory. Where is my Install directory (how do I install after building in XCode?).

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 22, 2014, 11:51:19 am
Install directory is what you put in CMAKE_INSTALL_PREFIX.
You install by building the "Install" project in XCode.

Everything is explained in the corresponding tutorial ("Compiling SFML").
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 12:40:03 pm
Aah ok. The CSFML CMake mystery is starting to dawn on me :)

I've set the CMAKE_INSTALL_PREFIX for SFML to a custom path (SFMLiOS/lib/Install/) and built install in XCode, this produces a directory containing the headers, libs and some cmake files where I want it. So far so good.

CMake configure for CSFML is giving the same error. So just to clarify, all I've done with CSFML CMake:
CMAKE_MODULE_PATH is SFMLiOS/lib/Install/cmake/Modules
SFML_ROOT is SFMLiOS/lib/Install/

Exact error:

CMake Error at /Users/myl/Projects/beat/github/SFMLiOS/lib/Install/cmake/Modules/FindSFML.cmake:307 (message):
  Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY
  SFML_NETWORK_LIBRARY SFML_GRAPHICS_LIBRARY SFML_AUDIO_LIBRARY)
Call Stack (most recent call first):
  src/SFML/CMakeLists.txt:24 (find_package)


Configuring incomplete, errors occurred!
See also "/Users/myl/Projects/beat/github/CSFMLiOS/CMakeFiles/CMakeOutput.log".


myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 22, 2014, 12:56:43 pm
Which files does SFMLiOS/lib/Install/lib contain? Make sure you've built SFML statically.
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 01:10:01 pm
I've just verified that BUILD_SHARED_LIBS was false in SFML CMake (Although I guess the IOS true flag enforces that?).

The full listing for the files in the Install directory:
http://pastebin.com/29CH3ryx

Thanks!
myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 22, 2014, 01:16:17 pm
You should make a release build, not a debug one.
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 01:26:17 pm
My mistake. Built for release. The updated file listing:
http://pastebin.com/ZVzh5NLu

I get the same error though :/

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on May 22, 2014, 01:30:04 pm
I have no idea, sorry. However you can manually fill all the -NOTFOUND variables and continue.
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 04:45:31 pm
Thanks Laurent for the -NOTFOUND tip!

I still have no idea what caused the issue, but I filled in the -NOTFOUND paths for the lib files, which now let's me generate and build CSFML statically in XCode based on my iOS SFML libs. Yay!

To build CSFML, I changed the Base SDK to iOS 7.1 for the generated CSFML project. Can you think of anything I forgot or should my CSFML iOS libs be all set for consuming in an iOS project now (champagne bottle popping time)?

I did run into one build error on the way, which i suspect is minor (I commented out the line for now, to let me build).

This line of SFML/Graphics/ConvertRenderStates.hpp throws the attached error:
sfmlStates.blendMode = static_cast<sf::BlendMode>(states->blendMode);

myl
Title: Re: CSFML cmake broken?
Post by: Nexus on May 22, 2014, 04:56:10 pm
The error is related to a recent modification in SFML that has not yet been ported to CSFML.

It's not a minor issue, blending won't work without that. I suggest you use an older SFML revision (b7c536c (https://github.com/SFML/SFML/commit/b7c536c7103cadcb89f7987d236b45010475c724)) until this is implemented.
Title: Re: CSFML cmake broken?
Post by: zsbzsb on May 22, 2014, 05:58:58 pm
The error is related to a recent modification in SFML that has not yet been ported to CSFML.

It's not a minor issue, blending won't work without that. I suggest you use an older SFML revision (b7c536c (https://github.com/SFML/SFML/commit/b7c536c7103cadcb89f7987d236b45010475c724)) until this is implemented.

I plan on implementing this and other fixes to CSFML and SFML.NET in a few weeks as soon as my school gets out for the summer.  :)
Title: Re: CSFML cmake broken?
Post by: myl on May 22, 2014, 06:19:52 pm
It's not a minor issue, blending won't work without that. I suggest you use an older SFML revision (b7c536c (https://github.com/SFML/SFML/commit/b7c536c7103cadcb89f7987d236b45010475c724)) until this is implemented.

By minor I meant that the problem is not related to my CSFML on iOS foray :)

Thanks! I will roll back.

myl
Title: Re: CSFML cmake broken?
Post by: AbelToy on May 27, 2014, 01:02:23 pm
I'm following these. Please inform us when you get it to work! :D
Title: Re: CSFML cmake broken?
Post by: myl on May 27, 2014, 02:24:54 pm
Hey AbelToy.

I haven't had a chance to follow up on this, but I will do it sometime this week :)

myl
Title: Re: CSFML cmake broken?
Post by: myl on May 27, 2014, 02:25:55 pm
Unless you are referring to the blending issue?

Myl
Title: Re: CSFML cmake broken?
Post by: AbelToy on May 27, 2014, 03:36:12 pm
Haha nope, I'm referring to compiling dotnet in order to use SFML.NET with iOS / Android :D
Title: Re: CSFML cmake broken?
Post by: myl on June 03, 2014, 03:57:11 pm
Ok, I had time to get into this today. Looks promising, but I am kinda stuck, maybe Laurent or someone else with better understanding of the CSFML / SFML binding has any ideas?

I'm debugging on the iOS Simulator to start off, so I have built SFML statically with the IOS 7.1 SDK and i386 architecture.  On top of that I've built CSFML from those libraries also against IOS 7.1 SDK and i386 architecture.

When mtouch is compiling my SFML.Net library natively it throws errors like this for every p invoke:

Undefined symbols for architecture i386:
  "sf::CircleShape::setPointCount(unsigned int)", referenced from:
      sfCircleShape_setPointCount(sfCircleShape*, unsigned int) in libcsfml-graphics.a(CircleShape.o)

So it seems that it links with CSFML fine enough, but can't link the C++ function underneath. What could I be missing?

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on June 03, 2014, 04:11:51 pm
Since CSFML is a static library, it doesn't link anything. So you have to link CSFML and SFML in the final binary (SFML.Net).
Title: Re: CSFML cmake broken?
Post by: myl on June 03, 2014, 06:26:57 pm
Since CSFML is a static library, it doesn't link anything. So you have to link CSFML and SFML in the final binary (SFML.Net).

Hmm. I'm confused. I thought CSFML was self-containing SFML? Why do I need to link SFML also then? Anyway, after also linking libsfml-window-s.a and libsfml-graphics-s.a, libfreetype.a and libjpeg.a with mtouch i get a GL related error.

Undefined symbols for architecture i386:
  "sf::ThreadLocal::setValue(void*)", referenced from:
      sf::priv::GlContext::globalInit() in libsfml-window-s.a(GlContext.o)
      sf::priv::GlContext::initialize() in libsfml-window-s.a(GlContext.o)
      sf::priv::GlContext::setActive(bool) in libsfml-window-s.a(GlContext.o)
      sf::priv::GlContext::ensureContext() in libsfml-window-s.a(GlContext.o)
      (anonymous namespace)::getInternalContext() in libsfml-window-s.a(GlContext.o)
      sf::priv::GlContext::create() in libsfml-window-s.a(GlContext.o)
      sf::priv::GlContext::create(sf::ContextSettings const&, sf::priv::WindowImpl const*, unsigned int) in libsfml-window-s.a(GlContext.o)


I've verified that OpenGLES.framework is linked in.

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on June 03, 2014, 08:19:00 pm
Quote
I thought CSFML was self-containing SFML?
Not if it is compiled statically. A static library is simply an archive of compiled files, it can't link to any external library; linking must be done when building a binary (a shared library or an executable).

Quote
i get a GL related error.
I wouldn't call "sf::ThreadLocal::setValue" a GL function ;)
You must link to sfml-system.
Title: Re: CSFML cmake broken?
Post by: myl on June 04, 2014, 02:59:51 pm
Ok. I've tried to simplify things by only linking in libcsfml-window, libsfml-window-s and libsfml-system.s. These should work fine together by themselves, right?

To get through build errors I've also linked in QuartzCore.framework, CoreMotion.framework and OpenGLES.framework. I now get consistent errors when building for Simulator (i386) or when building for iOS device (armv7). It looks like one for every p invoke (41) in sfmlnet-window:
Undefined symbols for architecture armv7:
  "_sfJoystick_getAxisPosition", referenced from:
     -u command line option

(The above error says "for architecture i386" for simulator builds). Full build command and errors: http://pastebin.com/ZS3J5ZqN (http://pastebin.com/ZS3J5ZqN)

I've verified the 3 linked in sfml libs are the correct archs (i386 or armv7) by using lipo like this:
xcrun -sdk iphoneos lipo -info CSFMLiOS/lib/Release/libcsfml-system.a
Architectures in the fat file: CSFMLiOS/lib/Release/libcsfml-system.a are: armv7 armv7s arm64


The funny thing is, if I build without linking in libsfml-window, I get errors like
Undefined symbols for architecture armv7:
  "sf::Mouse::getPosition(sf::Window const&)", referenced from:
      sfMouse_getPosition(sfWindow const*) in libcsfml-window.a(Mouse.o)

Meaning sfMouse_getPosition and the rest actually was located in libcsfml-window.
Title: Re: CSFML cmake broken?
Post by: Laurent on June 04, 2014, 03:06:29 pm
What is this "-u" command line option?
Title: Re: CSFML cmake broken?
Post by: myl on June 04, 2014, 03:23:01 pm
From http://linux.die.net/man/1/clang (http://linux.die.net/man/1/clang):

-Umacroname
Adds an implicit #undef into the predefines buffer which is read before the source file is preprocessed.

Title: Re: CSFML cmake broken?
Post by: Laurent on June 04, 2014, 03:38:27 pm
I'm not sure, but I don't think -U is the same as -u. And why is it used in your project?
Title: Re: CSFML cmake broken?
Post by: myl on June 04, 2014, 03:45:48 pm
I'm not sure, but I don't think -U is the same as -u. And why is it used in your project?
Hah, I was wondering the same, but haven't found a better match yet :) The compile options for clang++ are generated by mtouch, which is the xamarin mono compiler/linker.
Title: Re: CSFML cmake broken?
Post by: Laurent on June 04, 2014, 03:55:11 pm
This forum discussion (http://forums.xamarin.com/discussion/16619/native-linking-failed-undefined-symbol) seems like it could be helpful.
Title: Re: CSFML cmake broken?
Post by: myl on June 04, 2014, 04:55:53 pm
This forum discussion (http://forums.xamarin.com/discussion/16619/native-linking-failed-undefined-symbol) seems like it could be helpful.

Thx Laurent. I'll look into it! Sorry for google proxying you :)

myl
Title: Re: CSFML cmake broken?
Post by: myl on June 09, 2014, 10:15:33 am
I've tried to merge  libcsfml-window, libsfml-window-s and libsfml-system.s together using libtool to see if the mtouch compiler likes it better to be fed a single lib instead of three, and then I got an interesting error:

libtool libsfml-system-s.a libsfml-window-s.a ../../../CSFMLiOS/lib/Release/libcsfml-window.a -o fatlibcsfml-window.a
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning for architecture: i386 same member name (Context.o) in output file used for input files: ../../../CSFMLiOS/lib/Release/libcsfml-window.a(Context.o) and: libsfml-window-s.a(Context.o) due to use of basename, truncation and blank padding
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning for architecture: i386 same member name (Joystick.o) in output file used for input files: libsfml-window-s.a(Joystick.o) and: ../../../CSFMLiOS/lib/Release/libcsfml-window.a(Joystick.o) due to use of basename, truncation and blank padding
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning for architecture: i386 same member name (Keyboard.o) in output file used for input files: libsfml-window-s.a(Keyboard.o) and: ../../../CSFMLiOS/lib/Release/libcsfml-window.a(Keyboard.o) due to use of basename, truncation and blank padding
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning for architecture: i386 same member name (Mouse.o) in output file used for input files: ../../../CSFMLiOS/lib/Release/libcsfml-window.a(Mouse.o) and: libsfml-window-s.a(Mouse.o) due to use of basename, truncation and blank padding
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning for architecture: i386 same member name (VideoMode.o) in output file used for input files: libsfml-window-s.a(VideoMode.o) and: ../../../CSFMLiOS/lib/Release/libcsfml-window.a(VideoMode.o) due to use of basename, truncation and blank padding
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning for architecture: i386 same member name (Window.o) in output file used for input files: libsfml-window-s.a(Window.o) and: ../../../CSFMLiOS/lib/Release/libcsfml-window.a(Window.o) due to use of basename, truncation and blank padding

So this would explain why mtouch linking fails if it's attempting something like this. What would be the best way to go about these naming clash issues? Is there perhaps a setting in CSFML XCode project that will allow me to include SFML in the CSFML libraries?

myl
Title: Re: CSFML cmake broken?
Post by: myl on June 10, 2014, 03:05:22 pm
Ok, it turns out that the libcsfml-window.a i'm trying to link with is missing the C externs, and that is what is making mtouch complain.
nm command for iOS built libcsfml-window:
http://pastebin.com/Tzvv0uZA
Compared to OSX built libcsfml-window.dylib:
http://pastebin.com/73ajMtUN

I'm looking to get definitions like
T _sfWindow_createUnicode

Any ideas how to make CSFML build for iOS with the usual externs?

myl
Title: Re: CSFML cmake broken?
Post by: myl on June 18, 2014, 12:33:55 pm
Hey Laurent (and anybody else down with CSFML).

Bump. Anybody got any ideas why the C externs are missing?

myl
Title: Re: CSFML cmake broken?
Post by: Laurent on June 18, 2014, 01:01:47 pm
Nop, sorry.
Title: Re: CSFML cmake broken?
Post by: rcurtis on September 25, 2014, 04:48:04 pm
Has this issue been resolved yet?  I've been trying to configure CSFML with CMake on Windows for a the past half hour and it never seems to find the SFML libs it is interested in.  I have to manually tell it where to find the SFML dependencies (glew, freetype, etc...) and even after that it blows up with:

CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindSFML.cmake:344 (message):
  Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY
  SFML_NETWORK_LIBRARY SFML_GRAPHICS_LIBRARY SFML_AUDIO_LIBRARY)
Call Stack (most recent call first):
  src/SFML/CMakeLists.txt:26 (find_package)
 
Title: Re: CSFML cmake broken?
Post by: Laurent on September 25, 2014, 05:01:47 pm
Are you sure this is the same issue? Which version of SFML / CSFML are you compiling?
Title: Re: CSFML cmake broken?
Post by: rcurtis on September 25, 2014, 05:03:17 pm
I am compiling the latest source from github for all 3 projects (SFML, CSFML, and the .NET bindings).  CSFML never makes it past the 'configure' step with CMake.
Title: Re: CSFML cmake broken?
Post by: rcurtis on September 25, 2014, 05:59:02 pm
My issue was solved (Thanks to Tank) by running the install target with SFML, clearing the CMake cache for the CSFML project, manually setting the SFML_ROOT var to the newly installed directory, and running configure again.
Title: Re: CSFML cmake broken?
Post by: grok on December 10, 2014, 08:23:03 pm
I have another issue (I am running Ubuntu).
I built the latest SFML from the repository.
Now, when I try to build the latest CSFML I get this:
Quote
SFML found but version too low (requested: 2, found: 1.x.x)

I am absolutely sure that I have no SFML 1 installed. What am I doing wrong?
I tried to specify SFML_ROOT to the cmake but nothing changed.

Looks like it ignores SFML_ROOT I specified and as a result it uses "/usr/include/SFML/Config.hpp" which is from SFML 2.0 (previous version).
Weird.
Title: Re: CSFML cmake broken?
Post by: grok on December 11, 2014, 07:10:19 am
I specified both SFML_ROOT and SFML_INCLUDE_DIR and it worked.

now I am having the following:
Quote
/usr/bin/ld: warning: libsfml-window.so.2, needed by /usr/local/lib/libcsfml-window.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libsfml-system.so.2, needed by /usr/local/lib/libcsfml-window.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libsfml-graphics.so.2, needed by /usr/local/lib/libcsfml-graphics.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libsfml-audio.so.2, needed by /usr/local/lib/libcsfml-audio.so, not found (try using -rpath or -rpath-link)

Am I right that CSFML is not up-to-date? I mean, SFML is 2.2.0 while CSFML is 2.1?
Thank you for clarifications.
Title: Re: CSFML cmake broken?
Post by: Laurent on December 11, 2014, 08:16:53 am
Indeed CSFML is not up-to-date, but this doesn't seem to be the problem.
Title: Re: CSFML cmake broken?
Post by: grok on December 11, 2014, 08:46:30 am
I see.
As a quick and dirty hack I renamed all the compiled libraries to match the version and my toy project finally recompiled OK. I understand that it is not the proper method to get around though.

UPD:
and, btw, FindSFML cmake config is not accurate. In case it finds the previous version of SFML (i.e. 2.1), it reports
Quote
SFML found but version too low (requested: 2, found: 1.x.x)
it should be
Quote
"... , found 2.1"
or alike.
Title: Re: CSFML cmake broken?
Post by: Laurent on December 11, 2014, 12:04:28 pm
The script has been updated to match the new 2.2 versionning scheme, so there's a possibility that it no longer works well with previous versions. I'll report it and I'll keep you informed.