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 - cmathai

Pages: [1]
1
General / Re: CMAKE error missing dependencies of SFML
« on: October 26, 2023, 12:34:33 am »
Thanks!!!

That was the problem  :)

2
General / Re: CMAKE error missing dependencies of SFML
« on: October 25, 2023, 10:36:43 pm »
OK I made some more progress. Basically the original issue was because I was not linking the target against SFML dependencies (which I missed, although described in https://www.sfml-dev.org/tutorials/2.6/start-vc.php)

Here is the issue I have now - I built a static version of SFML myself. I took an SFML toy example, but got a lot of link errors when building my application.

Here are the steps I followed (and how I fixed it)
  • Downloaded SFML 2.6.0 source from https://www.sfml-dev.org/files/SFML-2.6.0-sources.zip
  • Use Cmake GUI and Visual Studio 2019 to build SFML

    Where is the source code: C:/SFML-2.6.0-sources/SFML-2.6.0
    Where to build the libraries: C:/SFML_static_2.6.0
    Click on Configure. Uncheck BUILD_SHARED_LIBS, and check SFML_USE_STATIC_STD_LIBS. Click on Configure again. Click on Generate. This generates a visual studio solution SFML.sln. Open it and build the release version of SFML. This builds a static version of SFML in C:\SFML_static_2.6.0\lib\Release

  • Edit SFMLConfig.cmake in 'C:\SFML_static_2.6.0\SFMLConfig.cmake' (where SFML gets built)

    Add the paths lib/Release and the paths to SFML dependencies. To FIND_SFML_PATHS , add


    "${CMAKE_CURRENT_LIST_DIR}/lib/Release" (where SFML libraries are built)
    "C:/SFML-2.6.0-sources/SFML-2.6.0/extlibs/libs-msvc-universal/x64" (SFML dependencies shipped with SFML source)

  • Create a toy example. I created main.cpp with the code in https://www.sfml-dev.org/tutorials/2.6/start-vc.php
    In the same location, create CMakeLists.txt with the following content (code taken from https://en.sfml-dev.org/forums/index.php?topic=24070.0)

    cmake_minimum_required(VERSION 3.23)
    project(SFMLTest)
    ## If you want to link SFML statically
    set(SFML_STATIC_LIBRARIES TRUE)
    ## In most cases better set in the CMake cache
    set(SFML_DIR "C:/SFML_static_2.6.0")
    find_package(SFML 2.6 COMPONENTS graphics audio REQUIRED)
    add_executable(SFMLTest main.cpp)
    target_link_libraries(SFMLTest sfml-graphics sfml-audio)

  • Generate VS 2019 solution
    cmake -G "Visual Studio 16 2019" -A x64 -B build
  • Open SFMLTest.sln in 'build' folder, and Build the solution.

The last step gives a lot of link errors. Eg:-

Error LNK2038 mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj SFMLTest sfml-graphics-s.lib(Color.obj)
   

To fix this, I did the following.
Right click SFMLTest, click on properties.
C/C++ > Code Generation > Runtime Library is set to 'Multi-threaded DLL (/MD)'.

I changed it to 'Multi-threaded (/MT)' .

What I do not understand is, if I use the the pre-built version of SFML for VS 2019 from https://www.sfml-dev.org/files/SFML-2.6.0-windows-vc16-64-bit.zip, it works out of the box. And interestingly, when I check the solution generated with this, I still have Multi-threaded DLL (/MD), but it works. I am curious about why this works.

So I can't quite figure out what I am doing wrong. Any help is appreciated.

3
General / Re: CMAKE error missing dependencies of SFML
« on: October 25, 2023, 05:21:33 am »
I have the same issue too.

This doesnt happen with SFML built as shared library.

I have this problem when SFML is built as a static library.

4
Thanks!

5
General discussions / SFML 2.6.0 warnings treated as error with vs 2019
« on: October 24, 2023, 02:13:24 am »
Hello, I noticed I when I try to compile SFML with VS 2019, I get the following compilation warning (that gets treated as an error)

Severity   Code   Description   Project   File   Line   Suppression State
Warning   C4242   '=': conversion from 'int' to 'unsigned char', possible loss of data   sfml-graphics   C:\SFML-2.6.0-sources\SFML-2.6.0\extlibs\headers\stb_image\stb_image.h   3425   

I noticed this is because, j->marker in stbi__decode_jpeg_image is unsigned char while stbi__skip_jpeg_junk_at_end returns an int. In the method stbi__skip_jpeg_junk_at_end, I see we should really be returning an unsigned char, but return int instead. Specifically changing
static int stbi__skip_jpeg_junk_at_end(stbi__jpeg *j) to
static unsigned char stbi__skip_jpeg_junk_at_end(stbi__jpeg *j)
and
int x = stbi__get8(j->s); to
unsigned char x = stbi__get8(j->s); fixes the problem.

There is a similar issue with arguments passed to stbi__mul2shorts_valid (method takes short, but passing in int)

Should I open an issue ?

Pages: [1]