Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running (or linking) with GLFW #1428

Open
arthurBricq opened this issue Jul 24, 2024 · 1 comment
Open

Error when running (or linking) with GLFW #1428

arthurBricq opened this issue Jul 24, 2024 · 1 comment

Comments

@arthurBricq
Copy link

Hello everyone, and thanks in advance for the support.

I have been trying to compile small example of mine with OpenGL+GLFW+GLAD. The C++ code is accessible here: https://github.com/arthurBricq/RubicsCube/, alongside with the emscripten scripts that I use to compile and run (https://github.com/arthurBricq/RubicsCube/tree/main/build_emscripten). Of course the C++ executable works.

By following several tutorials, mostly the officials and this one I successfully managed to compile my code. The problem is that when I run the code (with http local server to open the generated .html file), I get an error : Exception thrown, see JavaScript console. But the exception in the console seems very very obscure to me...

It seems to be Aborted(native code called abort()) but really I couldn't find more about the error.

image

Here's my CMakeLists.txt

cmake_minimum_required( VERSION 3.5 )
project(Tuto1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Release)

if (EMSCRIPTEN)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s WASM=1")
    set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif ()


if(NOT EMSCRIPTEN) 
    # not adding glfw when compiling with emscripten
    set(OpenGL_GL_PREFERENCE GLVND)
    find_package(OpenGL REQUIRED)
    find_package(glfw3 REQUIRED)
    include_directories( ${OPENGL_INCLUDE_DIRS} )
endif()

include_directories("./glad/include")
include_directories("./glm")

set( GLFW_BUILD_DOCS OFF CACHE BOOL  "GLFW lib only" )
set( GLFW_INSTALL OFF CACHE BOOL  "GLFW lib only" )
set( GLAD_GL "" )

add_executable(Hello3D main3d.cpp glad/src/glad.c shader.cpp)
target_link_libraries(Hello3D ${OPENGL_LIBRARIES} glfw)

My compilation script is

ROOT="/home/arthur/dev/deps/emsdk/upstream/emscripten"
$ROOT/emcmake cmake ..
$ROOT/emmake make

And its succesfull output is the following

image

So, considering the warnings, I am assuming that there is a linking problem. But I really did not the solution on the already existing issues of this forum.

Thanks in advance

PS: I use Ubuntu

@kripken
Copy link
Member

kripken commented Jul 25, 2024

Some tips are here:

https://emscripten.org/docs/porting/Debugging.html

In particular, build with -g to get proper symbol names. That would show function names in the stack trace, so you would see what is calling abort().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants