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

Pages: [1]
1
General / SIGSEGV when using SFML on Android
« on: December 02, 2023, 11:19:54 am »
I've a game using SFML and they work very well on computer and now I want to port it to Android. Compiling and building are successfully and the APK has been created and I installed to my Samsung S5 Exynos running in LineageOS 14.1 (Android 7.1.2) to test. Then I have this error:

12-02 13:20:51.953 24780 24780 E libEGL  : validate_display:101 error 3001 (EGL_NOT_INITIALIZED)
12-02 13:20:51.954 24780 24780 E libEGL  : validate_display:99 error 3008 (EGL_BAD_DISPLAY)
12-02 13:20:51.954 24780 24780 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x24 in tid 24780 (ames.cyberchess)
12-02 13:20:51.955  3600  3600 W         : debuggerd: handling request: pid=24780 uid=10081 gid=10081 tid=24780
12-02 13:20:52.034 23099 24195 I Icing   : Usage reports ok 1, Failed Usage reports 0, indexed 0, rejected 0
12-02 13:20:52.057 23099 23127 I Icing   : IndexChimeraService.getServiceInterface callingPackage=com.google.android.gms componentName=null serviceId=30
12-02 13:20:52.074 24805 24805 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-02 13:20:52.074 24805 24805 F DEBUG   : LineageOS Version: 14.1-20181109-NIGHTLY-k3gxx
12-02 13:20:52.074 24805 24805 F DEBUG   : Build fingerprint: samsung/k3gxx/k3g:6.0.1/MMB29K/G900HXXU1CPF2:user/release-keys
12-02 13:20:52.074 24805 24805 F DEBUG   : Revision: 0
12-02 13:20:52.074 24805 24805 F DEBUG   : ABI: arm
12-02 13:20:52.075 24805 24805 F DEBUG   : pid: 24780, tid: 24780, name: ames.cyberchess  >>> com.cyberdaystudio.games.cyberchess <<<
12-02 13:20:52.075 24805 24805 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x24
12-02 13:20:52.075 24805 24805 F DEBUG   :     r0 00000024  r1 00000024  r2 00000000  r3 7ffffff8
12-02 13:20:52.075 24805 24805 F DEBUG   :     r4 bed4c3d8  r5 00000000  r6 00000000  r7 bed4c3d0
12-02 13:20:52.075 24805 24805 F DEBUG   :     r8 00000000  r9 b4284f38  sl b2d17950  fp bed4c6d8
12-02 13:20:52.075 24805 24805 F DEBUG   :     ip b2cf9888  sp bed4c3c8  lr b2c7f153  pc b2c7f1ae  cpsr 60070030
12-02 13:20:52.094 24805 24805 F DEBUG   :
12-02 13:20:52.094 24805 24805 F DEBUG   : backtrace:
12-02 13:20:52.094 24805 24805 F DEBUG   :     #00 pc 000451ae  /data/app/com.cyberdaystudio.games.cyberchess-1/lib/arm/libsfml-system.so (_ZN2sf5MutexD2Ev+21)
12-02 13:20:52.094 24805 24805 F DEBUG   :     #01 pc 0004514f  /data/app/com.cyberdaystudio.games.cyberchess-1/lib/arm/libsfml-system.so (_ZN2sf4LockC2ERNS_5MutexE+10)
12-02 13:20:52.094 24805 24805 F DEBUG   :     #02 pc 0000c5f5  /data/app/com.cyberdaystudio.games.cyberchess-1/lib/arm/libsfml-window.so (_ZN2sf4priv10EglContextC1EPS1_+84)
12-02 13:20:52.094 24805 24805 F DEBUG   :     #03 pc 00006eff  /data/app/com.cyberdaystudio.games.cyberchess-1/lib/arm/libsfml-window.so (_ZN2sf4priv9GlContext12initResourceEv+94)
12-02 13:20:52.094 24805 24805 F DEBUG   :     #04 pc 00008d17  /data/app/com.cyberdaystudio.games.cyberchess-1/lib/arm/libsfml-window.so (_ZN2sf10GlResourceC1Ev+6)
12-02 13:20:52.094 24805 24805 F DEBUG   :     #05 pc 00049a99  /data/app/com.cyberdaystudio.games.cyberchess-1/lib/arm/libsfml-graphics.so (_ZN2sf7TextureC2Ev+24)
12-02 13:20:52.094 24805 24805 F DEBUG   :     #06 pc 0000791c  /data/app/com.cyberdaystudio.games.cyberchess-1/lib/arm/libcyberchess.so (offset 0xa000)
12-02 13:20:52.182 23099 24195 I Icing   : Usage reports ok 0, Failed Usage reports 0, indexed 0, rejected 0
12-02 13:20:52.223 23099 24195 I Icing   : Indexing com.google.android.gms-apps from com.google.android.gms
12-02 13:20:52.285 23099 24195 I Icing   : Indexing done com.google.android.gms-apps
12-02 13:20:52.289 23099 24195 I Icing   : Indexing com.google.android.gms-apps from com.google.android.gms
12-02 13:20:52.293 23099 24195 I Icing   : Indexing done com.google.android.gms-apps
12-02 13:20:52.738 24780 24780 W ames.cyberchess: type=1701 audit(0.0:1358): auid=4294967295 uid=10081 gid=10081 ses=4294967295 subj=u:r:untrusted_app:s0:c512,c768 reason="memory violation" sig=11
12-02 13:20:52.747  3600  3600 W         : debuggerd: resuming target 24780
12-02 13:20:52.749  4145 24815 W ActivityManager:   Force finishing activity com.cyberdaystudio.games.cyberchess/.MainActivity

I have using the code to test and I have same error:

main.cpp:

#include "main_point.h"

void ShowWindow() {  
     sf::VideoMode screen(sf::VideoMode::getDesktopMode());    

      sf::RenderWindow window(screen, "");

      window.setFramerateLimit(30);

}

main_point.h:

// SFML Library include
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>

void ShowWindow();

jni.cpp:

#include <jni.h>
#include "main_point.h"

extern "C" {
    void
    Java_com_cyberdaystudio_games_cyberchess_MainActivity_showWindow(JNIEnv *env, jclass clazz) {
        ShowWindow();
    }
}

AndroidManifest.xml:

<?xml version=&#39;1.0&#39;?>
<manifest xmlns:a=&#39;http://schemas.android.com/apk/res/android&#39;
   package=&#39;com.cyberdaystudio.games.cyberchess&#39;
   a:versionCode=&#39;0&#39;
   a:versionName=&#39;0&#39;>
    <uses-sdk
       a:minSdkVersion="21"
       a:targetSdkVersion="34"/>
    <application
       a:label="CyberChess">
        <activity
           a:name=&#39;com.cyberdaystudio.games.cyberchess.MainActivity&#39;
           a:exported="true">
            <intent-filter>
                <category a:name=&#39;android.intent.category.LAUNCHER&#39;/>
                <action a:name=&#39;android.intent.action.MAIN&#39;/>
            </intent-filter>
        </activity>
    </application>
</manifest>

MainActivity.java:

package com.cyberdaystudio.games.cyberchess;

import android.app.Activity;
import java.lang.System;
import android.os.Bundle;

public class MainActivity extends Activity {
    // do nothing, successfully

    String[] libs = {
        "c++_shared",
        "sfml-activity",
        "sfml-audio",
        "sfml-graphics",
        "sfml-network",
        "sfml-system",
        "sfml-window",
        "openal",
        "cyberchess"
    };
    private static native void showWindow();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        for (String lib : libs) {
            System.loadLibrary(lib);
        }
        showWindow();
    }
}

Here is my host environment:

# ANDROID
BUILD_TOOLS=/mnt/Linux/build-tools/34.0.0
ANDROID_PLATFORM=/mnt/Linux/platforms/android-34
ANDROID_NDK=/mnt/Linux/ndk/26.1.10909125

My machine is Linux:
Linux duythanh-VivoBook-ASUSLaptop-X409FA-X409FA 6.2.0-37-generic #38~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov  2 18:01:13 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

I have tried to read backtrace, and I guess the crash occurs when SFML library destructing
sf::Mutex
object. But I'm not have any idea to fix now.

I cloned the SFML from official git repository, checkout to branch 2.6.x and tried again. Still not work.

Is this an error of SFML 2.6.x? How can I make SFML work on Android?

2
General / Integrate ImGui with SFML 2.6.x on Linux?
« on: November 24, 2023, 05:13:17 pm »
The first time I posted here. I followed tutorial from https://edw.is/using-imgui-with-sfml-pt1 and .

But I'm getting this error:

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In lambda function:
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:272:55: error:const class sf::Window’ has no member named ‘getSystemHandle’
  272 |                             return ctx->window->getSystemHandle() == window.getSystemHandle();
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:272:83: error:const class sf::Window’ has no member named ‘getSystemHandle’
  272 | return ctx->window->getSystemHandle() == window.getSystemHandle();
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘void ImGui::SFML::Shutdown(const sf::Window&):
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:490:35: error:const class sf::Window’ has no member named ‘getSystemHandle’
  490 |         (s_currWindowCtx->window->getSystemHandle() == window.getSystemHandle());
      |                                   ^~~~~~~~~~~~~~~
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:490:63: error:const class sf::Window’ has no member named ‘getSystemHandle’
  490 | rWindowCtx->window->getSystemHandle() == window.getSystemHandle());
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In lambda function:
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:495:55: error:const class sf::Window’ has no member named ‘getSystemHandle’
  495 |                             return ctx->window->getSystemHandle() == window.getSystemHandle();
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:495:83: error:const class sf::Window’ has no member named ‘getSystemHandle’
  495 | return ctx->window->getSystemHandle() == window.getSystemHandle();
      |                                                 ^~~~~~~~~~~~~~~

/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘bool ImGui::SFML::UpdateFontTexture():
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:534:24: error: no matching function for call to ‘sf::Texture::create(unsigned int, unsigned int)
  534 |     if (!texture.create(static_cast<unsigned>(width), static_cast<unsigned>(height))) {
      |          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mnt/Linux/cyberchess/3rdparty/SFML/include/SFML/Graphics/RenderTexture.hpp:33,
                 from /mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:7:
/mnt/Linux/cyberchess/3rdparty/SFML/include/SFML/Graphics/Texture.hpp:115:24: note: candidate:bool sf::Texture::create(const sf::Vector2u&)
  115 |     [[nodiscard]] bool create(const Vector2u& size);
      |                        ^~~~~~
/mnt/Linux/cyberchess/3rdparty/SFML/include/SFML/Graphics/Texture.hpp:115:24: note:   candidate expects 1 argument, 2 provided
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘void ImGui::Image(const sf::Sprite&, const sf::Vector2f&, const sf::Color&, const sf::Color&):
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:709:54: error: cannot convert ‘const sf::Texture’ to ‘const sf::Texture*’ in initialization
  709 |     const sf::Texture* texturePtr = sprite.getTexture();
      |                                     ~~~~~~~~~~~~~~~~~^~
      |                                                      |
      |                                                      const sf::Texture
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘bool ImGui::ImageButton(const sf::Sprite&, const sf::Vector2f&, int, const sf::Color&, const sf::Color&):
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:771:54: error: cannot convert ‘const sf::Texture’ to ‘const sf::Texture*’ in initialization
  771 |     const sf::Texture* texturePtr = sprite.getTexture();
      |                                     ~~~~~~~~~~~~~~~~~^~
      |                                                      |
      |                                                      const sf::Texture
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp: In function ‘ImGuiKey {anonymous}::keycodeToImGuiKey(sf::Keyboard::Key):
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:1178:24: error: ‘Quote’ is not a member of ‘sf::Keyboard
 1178 |     case sf::Keyboard::Quote:
      |                        ^~~~~
/mnt/Linux/cyberchess/3rdparty/SFML/imgui/imgui-SFML.cpp:1198:24: error: ‘Tilde’ is not a member of ‘sf::Keyboard
 1198 |     case sf::Keyboard::Tilde:
      |                        ^~~~~
make: *** [Makefile:30: /mnt/Linux/cyberchess/build/cyberchess] Error 1

Here is my Makefile:

CC=g++ # GNU g++
ROOT_DIR=$(PWD)
SRC_DIR=$(ROOT_DIR)/src
SFML_DIR=$(ROOT_DIR)/3rdparty/SFML
IMGUI_SFML_DIR=$(ROOT_DIR)/3rdparty/SFML/imgui
SFML_BUILD_DIR=$(SFML_DIR)/build

SRC_FILE=$(SRC_DIR)/main.cpp

BUILD_DIR=$(ROOT_DIR)/build
BUILD_EXEC=$(BUILD_DIR)/cyberchess

INCLUDE_DIR=$(ROOT_DIR)/include

CXXFLAGS=-std=c++17
LDFLAGS= -fpermissive -static-libgcc -static-libstdc++ -lsfml-audio-s -lsfml-network-s -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lX11 -lXrandr -lXi -lXcursor -ludev -lopengl32

.PHONY: all always clean sfml

always:
        @chmod +x $(ROOT_DIR)/prepare.sh && $(ROOT_DIR)/prepare.sh
        @rm -rf $(BUILD_EXEC)
        @mkdir -p $(BUILD_DIR)
        @mkdir -p $(SFML_BUILD_DIR)

all: always sfml $(BUILD_EXEC)

$(BUILD_EXEC): $(IMGUI_SFML_DIR)/imgui_draw.cpp $(IMGUI_SFML_DIR)/imgui_tables.cpp $(IMGUI_SFML_DIR)/imgui_widgets.cpp $(IMGUI_SFML_DIR)/imgui.cpp $(IMGUI_SFML_DIR)/imgui-SFML.cpp $(SRC_FILE)
        @rm -rf $(BUILD_EXEC)
        @$(CC) $(CXXFLAGS) -I$(INCLUDE_DIR) -I$(SFML_DIR)/include -I$(IMGUI_SFML_DIR) -I$(SFML_BUILD_DIR)/include $^ -L$(SFML_BUILD_DIR)/lib -Wl,-rpath,$(SFML_BUILD_DIR) -o $@ $(LDFLAGS)

sfml:
        cd $(SFML_DIR) && cmake . -DCMAKE_INSTALL_PREFIX=$(SFML_BUILD_DIR) && make && sudo make install && cd ..

clean:
        @rm -rf $(BUILD_DIR)
        @cd $(SFML_DIR) && make clean

I'm not sure what I wrong. But both of tutorials for Windows, so ImGui for SFML only for Windows?

Here is my machine:


Pages: [1]
anything