RSATom / wcjs-gs

[proof-of-concept] WebChimera.js GStreamer editon
GNU Lesser General Public License v2.1
42 stars 7 forks source link

Windows build #7

Closed cell2749 closed 1 year ago

cell2749 commented 7 years ago

Trying to npm install the this library to use gstreamer sink in electron application, but running into too many problems. Cmake/visual studio/pkg-config...

Now I got to the point where cmake is giving me an error:

-- Checking for one of the modules 'gstreamer-1.0' CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPkgConfig.cmake:634 (message): None of the required 'gstreamer-1.0' found Call Stack (most recent call first): CMakeLists.txt:8 (pkg_search_module)

-- Checking for one of the modules 'gstreamer-app-1.0' CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPkgConfig.cmake:634 (message): None of the required 'gstreamer-app-1.0' found Call Stack (most recent call first): CMakeLists.txt:9 (pkg_search_module)

-- Checking for one of the modules 'gstreamer-video-1.0' CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindPkgConfig.cmake:634 (message): None of the required 'gstreamer-video-1.0' found Call Stack (most recent call first): CMakeLists.txt:10 (pkg_search_module)

I have gstreamer installed, but the executables are named gst-launch, gst-play and etc. I wonder if I need to install something additionally. Also I don't have any executables named -app or -video. I wonder if I need to install some older version of gstreamer?

RSATom commented 7 years ago

Please try install packages with -dev suffix.

cell2749 commented 7 years ago

Well I think that helped me to get past the pkg-config module issue. I had to also specify environment variable

PKG_CONFIG_LIBDIR to C:\gstreamer\1.0\x86_64\lib\pkgconfig

(specifying PKG_CONFIG_PATH did not work). After which the compiler complained about not finding glibconfig.h, which I decided to copy from

C:\gstreamer\1.0\x86_64\lib\glib-2.0\include

to

C:\gstreamer\1.0\x86_64\include\glib-2.0

and it resolved the next issue. However currently I am receiving

LINK : fatal error LNK1181: cannot open input file 'gstreamer-1.0.lib'

I found explanation to this from microsoft: https://support.microsoft.com/en-us/help/815645/you-receive-a-fatal-error-lnk1181-error-message-when-you-build-a-managed-c-application

Which states that I should open project with VS and configure LIBPATH for the project through that interface or specify LIB environment variable. Specifying LIB does not help. So I am now stuck and not sure what to do...

I am specifying LIB in system variables, should I specify it somewhere else? or What should I open with Visual Studio? or Is there some file that holds the LIBPATH configuration, which I could edit through something as simple as notepad?

P.S. The project to be opened with VS I assume is the wcjs-gs source code or something related to it.

RSATom commented 7 years ago

I've missed you are trying to do It on Windows... I've never tried build it on Windows. Don't sure I can help you.

cell2749 commented 7 years ago

Yes. Okay, thank you. Sorry did not mention it.

cell2749 commented 7 years ago

I think I made some progress. I noticed that when I run

npm install wcjs-gs

there are two cmake functions executed

cmake that makes the build files and cmake --build which builds something. I was trying to get the build pass without errors and executed pure cmake in the wcjs-gs/build folder, while cmake --build in the project directory. I managed to pass full path to the libraries in CMakeLists.txt like this:

cmake_minimum_required( VERSION 2.8 )

project( wcjs-gs )

add_definitions( -std=c++11 )

find_package( PkgConfig REQUIRED )
pkg_search_module( GSTREAMER REQUIRED gstreamer-1.0 )
pkg_search_module( GSTREAMER_APP REQUIRED gstreamer-app-1.0 )
pkg_search_module( GSTREAMER_VIDEO_META REQUIRED gstreamer-video-1.0 )

file( GLOB SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    src/[^.]*.cpp
    src/[^.]*.h
    README.md
    package.json
    )

include_directories( ${CMAKE_JS_INC} deps )
add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/deps/nah )

# Fetch LIB environment variable in windows. Holds path to the gstreamer libs.
file(TO_CMAKE_PATH $ENV{LIB} LIB)

#Remap the pkgconfig variables to contain full path
foreach( _variableName ${GSTREAMER_LIBRARIES} )
    list(APPEND GSTREAMER_LIBRARIES_LIB ${LIB}/${_variableName}.lib)
endforeach()

foreach( _variableName ${GSTREAMER_APP_LIBRARIES} )
    list(APPEND GSTREAMER_APP_LIBRARIES_LIB ${LIB}/${_variableName}.lib)
endforeach()

foreach( _variableName ${GSTREAMER_VIDEO_META_LIBRARIES} )
    list(APPEND GSTREAMER_VIDEO_META_LIBRARIES_LIB ${LIB}/${_variableName}.lib)
endforeach()

add_library( ${PROJECT_NAME} SHARED ${SOURCE_FILES} )
set_target_properties( ${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node" )
target_include_directories( ${PROJECT_NAME} PUBLIC ${GSTREAMER_INCLUDE_DIRS} )
target_link_libraries( ${PROJECT_NAME} ${CMAKE_JS_LIB} nah ${GSTREAMER_LIBRARIES_LIB} ${GSTREAMER_APP_LIBRARIES_LIB} ${GSTREAMER_VIDEO_META_LIBRARIES_LIB} )

#foreach( _variableName ${GSTREAMER_LIBRARIES} )
#    message( STATUS "${_variableName}=${${_variableName}}" )
#endforeach()

The build passes without errors. However, in electron I am getting Error: Could not locate the bindings file...

I think this is due to the fact that I need to execute npm rebuild and/or electron-rebuild -f --w wcjs-gs but I am getting errors in electron-rebuild due to my node-gyp or node-libcurl and npm rebuild does not seem to work properly (no errors but no bindings either). Therefore I have not got to the point of testing if build actually works.

What worries me is that the default enviroment for building is set to nw.js. Do I need to have something in my package.json file that would specify the electron environment for the wcjs-gs? I am talking about this in the rebuild.js:

var options = {
        runtime: process.env.npm_config_wcjs_runtime || undefined,
        runtimeVersion: process.env.npm_config_wcjs_runtime_version || undefined,
        arch: process.env.npm_config_wcjs_arch || undefined
    };

Where does it fetch the process.env.npm_config from?

RSATom commented 7 years ago

I think you could find useful info about build for different engines in WebChimera.js readme, and build scripts