emscripten-core / emscripten-core/emscripten

Porting v4l2

Open
#19,894 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Please include the following in your bug report:

**Version of emscripten/emsdk:**
master

**Failing command line in full:**
cmake_minimum_required (VERSION 3.10)
project (smart_opengl)

find_package(PkgConfig)
if( ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(USE_FLAGS "--bind -s WASM=1 -s USE_SDL=2 -s USE_FREETYPE=1 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${USE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${USE_FLAGS}")
set(CMAKE_EXECUTABLE_SUFFIX .html)
else()
pkg_check_modules(PC_SDL REQUIRED sdl2)
pkg_check_modules(PC_CGAL REQUIRED libv4l2)
pkg_check_modules(PC_OPENGL REQUIRED opengl)
pkg_check_modules(PC_SDL REQUIRED glut)

endif()
#pkg_check_modules(PC_CGAL REQUIRED gl1-mesa)
#pkg_check_modules(OPENGL REQUIRED opengl)
#pkg_check_modules(GL REQUIRED gl)
#find_package(CGAL REQUIRED)

#find_package(Threads REQUIRED)
#set(CMAKE_CXX_COMPILER "em++")
set(EMSCRIPTEN_PATH "/home/momo/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" CACHE PATH "Path to Emscripten toolchain file")
set(EMCC_DEBUG 1)

set (SMART_OPENGL_VERSION_MAJOR 0)
set (SMART_OPENGL_VERSION_MINOR 1)
set(CMAKE_VERBOSE_MAKEFILE ON)

#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -fsanitize=address,undefined -Wformat -Werror=format-security -Werror=array-bounds -D_FORTIFY_SOURCE=2 -fstack-protector-all -fstack-protector-strong -D_REENTRANT")
add_compile_options("-D_REENTRANT -g -fpermissive")
link_libraries("-D_REENTRANT")

configure_file (
"${PROJECT_SOURCE_DIR}/smart_opengl.h.in"
"${PROJECT_BINARY_DIR}/smart_opengl.h"
)

MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} " PROJECT_SOURCE_DIR " ${PROJECT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${PC_PTHREAD_INCLUDE_DIRS} ${PC_SDL_INCLUDE_DIRS} ${PC_CGAL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS} ${GL_INCLUDE_DIRS})

add_executable(smart_sdl camera.cpp) #test.image.cpp) #PixelPusher.cpp)
target_link_libraries(smart_sdl -lSDL2)

target_link_libraries(smart_sdl ${PC_PTHREAD_LIBRARY} ${PC_GLFW_LIBRARY} ${PC_CGAL_LIBRARY} ${OPENGL_LIBRARY_DIRS} ${GL_LIBRARY_DIRS} -lpng -lGL -lGLU -lglfw -lX11 -ldl -lglut)
if( ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set_target_properties(smart_sdl PROPERTIES
SUFFIX ".html"
LINK_FLAGS "-s NO_EXIT_RUNTIME=1 -s OFFSCREEN_FRAMEBUFFER=1 -s USE_GLFW=3 -s USE_WEBGL2=1 -s FULL_ES3=1 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS=[\"png\"] -s EXPORTED_RUNTIME_METHODS=\"['cwrap', 'ccall']\" -s USE_SDL=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 -s ALLOW_MEMORY_GROWTH=1 --std=c++17 --no-check-features"
)
endif()
install (TARGETS smart_sdl DESTINATION bin)
install (FILES ${PROJECT_BINARY_DIR}/smart_opengl.h DESTINATION include)

**Full link command and output with `-v` appended:**
/usr/bin/cmake -S/media/momo/UFDRecovery/cam-v4l2 -B/media/momo/UFDRecovery/cam-v4l2/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /media/momo/UFDRecovery/cam-v4l2/build/CMakeFiles /media/momo/UFDRecovery/cam-v4l2/build//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/media/momo/UFDRecovery/cam-v4l2/build'
make -f CMakeFiles/smart_sdl.dir/build.make CMakeFiles/smart_sdl.dir/depend
make[2]: Entering directory '/media/momo/UFDRecovery/cam-v4l2/build'
cd /media/momo/UFDRecovery/cam-v4l2/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /media/momo/UFDRecovery/cam-v4l2 /media/momo/UFDRecovery/cam-v4l2 /media/momo/UFDRecovery/cam-v4l2/build /media/momo/UFDRecovery/cam-v4l2/build /media/momo/UFDRecovery/cam-v4l2/build/CMakeFiles/smart_sdl.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/media/momo/UFDRecovery/cam-v4l2/build'
make -f CMakeFiles/smart_sdl.dir/build.make CMakeFiles/smart_sdl.dir/build
make[2]: Entering directory '/media/momo/UFDRecovery/cam-v4l2/build'
[ 50%] Building CXX object CMakeFiles/smart_sdl.dir/camera.cpp.o
/home/momo/emsdk/upstream/emscripten/em++ @CMakeFiles/smart_sdl.dir/includes_CXX.rsp --bind -s WASM=1 -s USE_SDL=2 -s USE_FREETYPE=1 "-D_REENTRANT -g -fpermissive" -MD -MT CMakeFiles/smart_sdl.dir/camera.cpp.o -MF CMakeFiles/smart_sdl.dir/camera.cpp.o.d -o CMakeFiles/smart_sdl.dir/camera.cpp.o -c /media/momo/UFDRecovery/cam-v4l2/camera.cpp
em++: warning: linker setting ignored during compilation: 'WASM' [-Wunused-command-line-argument]
em++: warning: linker flag ignored during compilation: '--bind' [-Wunused-command-line-argument]
/media/momo/UFDRecovery/cam-v4l2/camera.cpp:47:10: fatal error: 'linux/videodev2.h' file not found
47 | #include
| ^~~~~~~~~~~~~~~~~~~
1 error generated.
em++: error: '/home/momo/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -I/home/momo/emsdk/upstream/emscripten/cache/sysroot/include/SDL2 -I/home/momo/emsdk/upstream/emscripten/cache/sysroot/include/freetype2 --sysroot=/home/momo/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -I/media/momo/UFDRecovery/cam-v4l2/build -I/media/momo/UFDRecovery/cam-v4l2 "-D_REENTRANT -g -fpermissive" -MD -MT CMakeFiles/smart_sdl.dir/camera.cpp.o -MF CMakeFiles/smart_sdl.dir/camera.cpp.o.d -c /media/momo/UFDRecovery/cam-v4l2/camera.cpp -o CMakeFiles/smart_sdl.dir/camera.cpp.o' failed (returned 1)
make[2]: *** [CMakeFiles/smart_sdl.dir/build.make:80: CMakeFiles/smart_sdl.dir/camera.cpp.o] Error 1
make[2]: Leaving directory '/media/momo/UFDRecovery/cam-v4l2/build'
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/smart_sdl.dir/all] Error 2
make[1]: Leaving directory '/media/momo/UFDRecovery/cam-v4l2/build'
make: *** [Makefile:139: all] Error 2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.