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

scrcpy-noconsole compiled #1975

Open
douxiaoping opened this issue Dec 15, 2020 · 24 comments
Open

scrcpy-noconsole compiled #1975

douxiaoping opened this issue Dec 15, 2020 · 24 comments

Comments

@douxiaoping
Copy link

I configured windows_noconsole to be true in meson_options. Ninja-cx compiled, but it still didn't work.
image

@douxiaoping
Copy link
Author

#define WINDOWS_NOCONSOLE
I defined this, and ninja-CX didn't work either

@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2020

(Please post console content as text instead of screenshot.)

What do you mean "it still didn't work"? If you double click on the generated scrcpy.exe, it opens a new terminal?

Directory already configured

(Here your command did not work, either rm -rf x before the command, or use meson configure.)

@douxiaoping
Copy link
Author

this is meson_options.txt
option('compile_app', type: 'boolean', value: true, description: 'Build the client')
option('compile_server', type: 'boolean', value: true, description: 'Build the server')
option('crossbuild_windows', type: 'boolean', value: false, description: 'Build for Windows from Linux')
option('windows_noconsole', type: 'boolean', value: true, description: 'Disable console on Windows (pass -mwindows flag)')
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
option('hidpi_support', type: 'boolean', value: true, description: 'Enable High DPI support')
option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')
option('server_debugger_method', type: 'combo', choices: ['old', 'new'], value: 'new', description: 'Select the debugger method (Android < 9: "old", Android >= 9: "new")')

rm-rf X will still pop up the terminal interface after compilation
Is it configured incorrectly there

@douxiaoping
Copy link
Author

douxiaoping commented Dec 15, 2020

belen@DESKTOP-S47BQP1 MINGW64 ~/scrcpy
$ meson configure
WARNING: The source directory instead of the build directory was specified.
WARNING: Only the default values for the project are printed, and all command line parameters are ignored.

Core properties:
  Source dir D:/msys64/home/belen/scrcpy

Main project options:

  Core options            Default Value                                                                                               Possible Values                                               Description
  ------------            -------------                                                                                               ---------------                                               -----------
  auto_features           auto                                                                                                        [enabled, disabled, auto]                                     Override value of all 'auto' features
  backend                 ninja                                                                                                       [ninja, vs, vs2010, vs2015, vs2017, vs2019, xcode]            Backend to use
  buildtype               debug                                                                                                       [plain, debug, debugoptimized, release, minsize, custom]      Build type to use
  debug                   true                                                                                                        [true, false]                                                 Debug
  default_library         shared                                                                                                      [shared, static, both]                                        Default library type
  force_fallback_for      []                                                                                                                                                                        Force fallback for those subprojects
  install_umask           0022                                                                                                        [preserve, 0000-0777]                                         Default umask to apply on permissions of installed files
  layout                  mirror                                                                                                      [mirror, flat]                                                Build directory layout
  optimization            0                                                                                                           [0, g, 1, 2, 3, s]                                            Optimization level
  strip                   false                                                                                                       [true, false]                                                 Strip targets on install
  unity                   off                                                                                                         [on, off, subprojects]                                        Unity build
  unity_size              4                                                                                                           >=2                                                           Unity block size
  warning_level           2                                                                                                           [0, 1, 2, 3]                                                  Compiler warning level to use
  werror                  false                                                                                                       [true, false]                                                 Treat warnings as errors
  wrap_mode               default                                                                                                     [default, nofallback, nodownload, forcefallback]              Wrap mode
  cmake_prefix_path       []                                                                                                                                                                        List of additional prefixes for cmake to search
  pkg_config_path         [D, \msys64\mingw64\lib\pkgconfig;D, \msys64\mingw64\share\pkgconfig]                                                                                                     List of additional paths for pkg-config to search
  build.cmake_prefix_path []                                                                                                                                                                        List of additional prefixes for cmake to search
  build.pkg_config_path   [D, \msys64\mingw64\lib\pkgconfig;D, \msys64\mingw64\share\pkgconfig]                                                                                                     List of additional paths for pkg-config to search

  Backend options         Default Value                                                                                               Possible Values                                               Description
  ---------------         -------------                                                                                               ---------------                                               -----------
  backend_max_links       0                                                                                                           >=0                                                           Maximum number of linker processes to run or 0 for no limit

  Base options            Default Value                                                                                               Possible Values                                               Description
  ------------            -------------                                                                                               ---------------                                               -----------
  b_colorout              always                                                                                                      [auto, always, never]                                         Use colored output
  b_coverage              false                                                                                                       [true, false]                                                 Enable coverage tracking.
  b_lto                   false                                                                                                       [true, false]                                                 Use link time optimization
  b_ndebug                false                                                                                                       [true, false, if-release]                                     Disable asserts
  b_pch                   true                                                                                                        [true, false]                                                 Use precompiled headers
  b_pgo                   off                                                                                                         [off, generate, use]                                          Use profile guided optimization
  b_pie                   false                                                                                                       [true, false]                                                 Build executables as position independent
  b_sanitize              none                                                                                                        [none, address, thread, undefined, memory, address,undefined] Code sanitizer to use
  b_staticpic             true                                                                                                        [true, false]                                                 Build static libraries as position independent

  Compiler options        Default Value                                                                                               Possible Values                                               Description
  ----------------        -------------                                                                                               ---------------                                               -----------
  c_args                  []                                                                                                                                                                        Extra arguments passed to the c compiler
  c_link_args             []                                                                                                                                                                        Extra arguments passed to the c linker
  c_std                   c11                                                                                                         [none, c89, c99, c11, c17, c18, c2x, gnu89, gnu99, gnu11,     C language standard to use
                                                                                                                                       gnu17, gnu18, gnu2x]
  c_winlibs               [-lkernel32, -luser32, -lgdi32, -lwinspool, -lshell32, -lole32, -loleaut32, -luuid, -lcomdlg32, -ladvapi32]                                                               Standard Win libraries to link against
  build.c_args            []                                                                                                                                                                        Extra arguments passed to the c compiler
  build.c_link_args       []                                                                                                                                                                        Extra arguments passed to the c linker
  build.c_std             none                                                                                                        [none, c89, c99, c11, c17, c18, c2x, gnu89, gnu99, gnu11,     C language standard to use
                                                                                                                                       gnu17, gnu18, gnu2x]
  build.c_winlibs         [-lkernel32, -luser32, -lgdi32, -lwinspool, -lshell32, -lole32, -loleaut32, -luuid, -lcomdlg32, -ladvapi32]                                                               Standard Win libraries to link against

  Directories             Default Value                                                                                               Possible Values                                               Description
  -----------             -------------                                                                                               ---------------                                               -----------
  bindir                  bin                                                                                                                                                                       Executable directory
  datadir                 share                                                                                                                                                                     Data file directory
  includedir              include                                                                                                                                                                   Header file directory
  infodir                 share/info                                                                                                                                                                Info page directory
  libdir                  lib                                                                                                                                                                       Library directory
  libexecdir              libexec                                                                                                                                                                   Library executable directory
  localedir               share/locale                                                                                                                                                              Locale data directory
  localstatedir           var                                                                                                                                                                       Localstate data directory
  mandir                  share/man                                                                                                                                                                 Manual page directory
  prefix                  D:/msys64/mingw64                                                                                                                                                         Installation prefix
  sbindir                 sbin                                                                                                                                                                      System executable directory
  sharedstatedir          com                                                                                                                                                                       Architecture-independent data directory
  sysconfdir              etc                                                                                                                                                                       Sysconf data directory

  Testing options         Default Value                                                                                               Possible Values                                               Description
  ---------------         -------------                                                                                               ---------------                                               -----------
  errorlogs               true                                                                                                        [true, false]                                                 Whether to print the logs from failing tests
  stdsplit                true                                                                                                        [true, false]                                                 Split stdout and stderr in test logs

  Project options         Default Value                                                                                               Possible Values                                               Description
  ---------------         -------------                                                                                               ---------------                                               -----------
  compile_app             true                                                                                                        [true, false]                                                 Build the client
  compile_server          true                                                                                                        [true, false]                                                 Build the server
  crossbuild_windows      false                                                                                                       [true, false]                                                 Build for Windows from Linux
  hidpi_support           true                                                                                                        [true, false]                                                 Enable High DPI support
  portable                false                                                                                                       [true, false]                                                 Use scrcpy-server from the same directory as the scrcpy executable
  prebuilt_server                                                                                                                                                                                   Path of the prebuilt server
  server_debugger         false                                                                                                       [true, false]                                                 Run a server debugger and wait for a client to be attached
  server_debugger_method  new                                                                                                         [old, new]                                                    Select the debugger method (Android < 9: "old", Android >= 9: "new")
  windows_noconsole       true                                                                                                        [true, false]                                                 Disable console on Windows (pass -mwindows flag)

WARNING: The source directory instead of the build directory was specified.
WARNING: Only the default values for the project are printed, and all command line parameters are ignored.

@douxiaoping
Copy link
Author

I use the following instruction, is the instruction wrong?Please help to have a look!Thank you for the
meson x --buildtype release --strip -Db_lto=true

@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2020

You should not modify meson_options.txt, but pass the parameter to meson:

meson x -Dwindows_noconsole=true

@douxiaoping
Copy link
Author

Use this directive to change the config file.I compiled with NinjA-Cx and still didn't generate the Scrcpy-noconsole

$ meson x --buildtype release --strip -Db_lto=true -Dwindows_noconsole=true

#define WINDOWS_NOCONSOLE

@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2020

I compiled with NinjA-Cx and still didn't generate the Scrcpy-noconsole

No but it should generate scrcpy.exe which is a "no console" version.

See

cp "$(WIN64_NOCONSOLE_BUILD_DIR)"/app/scrcpy.exe "$(DIST)/$(WIN64_TARGET_DIR)/scrcpy-noconsole.exe"

@douxiaoping
Copy link
Author

Scrcpy.exe was produced, but after the operation or the first pop-up terminal to cast screen。Makefile.crosswindows also exists in the instructions you say.Do not know the reason for the inversion cannot generate no Console software

@douxiaoping
Copy link
Author

douxiaoping commented Dec 15, 2020

Could you please help me to see if this process is correct?I checked with meson Configrue X that it had been modified.The generated EXe is not the No Console。

belen@DESKTOP-S47BQP1 MINGW64 ~/test
$ rm -rf x

belen@DESKTOP-S47BQP1 MINGW64 ~/test
$ meson x --buildtype release --strip -Db_lto=true -Dwindows_noconsole=true
Using 'PKG_CONFIG_PATH' from environment with value: 'D:\\msys64\\mingw64\\lib\\pkgconfig;D:\\msys64\\mingw64\\share\\pkgconfig'
Using 'PKG_CONFIG_PATH' from environment with value: 'D:\\msys64\\mingw64\\lib\\pkgconfig;D:\\msys64\\mingw64\\share\\pkgconfig'
The Meson build system
Version: 0.56.0
Source dir: D:/msys64/home/belen/test
Build dir: D:/msys64/home/belen/test/x
Build type: native build
Project name: scrcpy
Project version: 1.16
C compiler for the host machine: cc (gcc 10.2.0 "cc (Rev5, Built by MSYS2 project) 10.2.0")
C linker for the host machine: cc ld.bfd 2.35.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: D:\msys64\mingw64\bin/pkg-config.EXE (1.7.3)
Using 'PKG_CONFIG_PATH' from environment with value: 'D:\\msys64\\mingw64\\lib\\pkgconfig;D:\\msys64\\mingw64\\share\\pkgconfig'
Run-time dependency libavformat found: YES 58.45.100
Using 'PKG_CONFIG_PATH' from environment with value: 'D:\\msys64\\mingw64\\lib\\pkgconfig;D:\\msys64\\mingw64\\share\\pkgconfig'
Run-time dependency libavcodec found: YES 58.91.100
Using 'PKG_CONFIG_PATH' from environment with value: 'D:\\msys64\\mingw64\\lib\\pkgconfig;D:\\msys64\\mingw64\\share\\pkgconfig'
Run-time dependency libavutil found: YES 56.51.100
Using 'PKG_CONFIG_PATH' from environment with value: 'D:\\msys64\\mingw64\\lib\\pkgconfig;D:\\msys64\\mingw64\\share\\pkgconfig'
Run-time dependency sdl2 found: YES 2.0.12
Library ws2_32 found: YES
Configuring config.h using configuration
Program ./scripts/build-wrapper.sh found: YES (bash D:/msys64/home/belen/test/server/./scripts/build-wrapper.sh)
Build targets in project: 3

Found ninja-1.10.2 at D:\msys64\mingw64\bin/ninja.EXE

belen@DESKTOP-S47BQP1 MINGW64 ~/test
$ ninja -Cx
ninja: Entering directory `x'
[0/26] Generating scrcpy-server with a custom command

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 3s
25 actionable tasks: 1 executed, 24 up-to-date
[12/26] Compiling C object app/scrcpy.exe.p/src_sys_win_command.c.obj
In file included from ../app/src/sys/win/command.c:6:
../app/src/sys/win/command.c: In function 'build_cmd':
../app/src/sys/win/command.c:17:14: warning: unknown conversion type character 'l' in format [-Wformat=]
   17 |         LOGE("Command too long (%" PRIsizet " chars)", len - 1);
      |              ^~~~~~~~~~~~~~~~~~~~~
../app/src/util/log.h:10:62: note: in definition of macro 'LOGE'
   10 | #define LOGE(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
      |                                                              ^~~~~~~~~~~
../app/src/sys/win/command.c:17:14: warning: too many arguments for format [-Wformat-extra-args]
   17 |         LOGE("Command too long (%" PRIsizet " chars)", len - 1);
      |              ^~~~~~~~~~~~~~~~~~~~~
../app/src/util/log.h:10:62: note: in definition of macro 'LOGE'
   10 | #define LOGE(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
      |                                                              ^~~~~~~~~~~
[25/26] Linking target app/scrcpy.exe

belen@DESKTOP-S47BQP1 MINGW64 ~/test

image

@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2020

It seems ok.

The difference between console and noconsole is basically a link flag. I had to change it on a MinGW upgrade on Debian: 18f2e33

I never tested to build the "no console" Windows version from Windows (I always cross-compile from Linux).

@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2020

It seems that you can create a file scrcpy-noconsole.vbs file containing:

CreateObject("Wscript.Shell").Run "cmd /c scrcpy.exe", 0, false

It will start the normal scrcpy.exe but without starting a console. It works on my test machine.

Does someone know if it's expected to work on all Windows? (cc @npes87184)
If it's the case, I will remplace that noconsole.exe garbage by this vbs file.

@douxiaoping
Copy link
Author

douxiaoping commented Dec 15, 2020

I'm using a screen-free device with a built-in service, so I want to compile without ADB.Exe without terminal has not been able to be programmed @npes87184 您这边在win10的msys下能实现吗?

@npes87184
Copy link
Contributor

I'm using a screen-free device with a built-in service, so I want to compile without ADB.Exe without terminal has not been able to be programmed @npes87184 您这边在win10的msys下能实现吗?

Sorry, I always cross-compile from Linux, too.

@npes87184
Copy link
Contributor

It seems that you can create a file scrcpy-noconsole.vbs file containing:

CreateObject("Wscript.Shell").Run "cmd /c scrcpy.exe", 0, false

It will start the normal scrcpy.exe but without starting a console. It works on my test machine.

Does someone know if it's expected to work on all Windows? (cc @npes87184)
If it's the case, I will remplace that noconsole.exe garbage by this vbs file.

Sorry, I am not familiar with this.

@rom1v
Copy link
Collaborator

rom1v commented Dec 16, 2020

Sorry, I am not familiar with this.

OK. Does it work on your Windows?

@Artur202030
Copy link

OK. Does it work on your Windows?

works, but it's better to leave everything as it is and not change anything

@rom1v
Copy link
Collaborator

rom1v commented Dec 18, 2020

works, but it's better to leave everything as it is and not change anything

Why? If it works, I much prefer a one-line script than compiling another binary with ifdefs. It simplifies a lot.

@Artur202030
Copy link

Why?

program start delay

@rom1v
Copy link
Collaborator

rom1v commented Dec 20, 2020

How long does it take? Few milliseconds?

@Artur202030
Copy link

I mean - the time for the appearance of mirroring on the desktop reaches 1 second or more. The times are not always the same.

@rom1v
Copy link
Collaborator

rom1v commented Dec 20, 2020

The start time is mainly the execution of the app_process on the device and codec initialization. The wrapper vbs script is negligible. (Isn't it for you?)

@rom1v rom1v closed this as completed Dec 20, 2020
@rom1v rom1v reopened this Dec 20, 2020
rom1v added a commit that referenced this issue Dec 22, 2020
This simplifies the build system.

Refs <#1975 (comment)
rom1v added a commit that referenced this issue Dec 22, 2020
This simplifies the build system.

Refs <#1975 (comment)>
@jeansagi
Copy link

jeansagi commented Jan 14, 2021

It seems that you can create a file scrcpy-noconsole.vbs file containing:

CreateObject("Wscript.Shell").Run "cmd /c scrcpy.exe", 0, false

It will start the normal scrcpy.exe but without starting a console. It works on my test machine.
Does someone know if it's expected to work on all Windows? (cc @npes87184)
If it's the case, I will remplace that noconsole.exe garbage by this vbs file.

Sorry, I am not familiar with this.

You can't pass parameters to scrcpy.exe this way!! The only way to pass parameters is hard-coding them.

J.

@rom1v
Copy link
Collaborator

rom1v commented Jan 14, 2021

You can't pass parameters to scrcpy.exe this way!! The only way to pass parameters is hard-coding them.

Yes, this should be improved: https://stackoverflow.com/a/17443309/1987178

But the only purpose of no-console is to start scrcpy without console by double-clicking on a file, so it should not be a big deal if the parameters are hardcoded.

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

5 participants