Winelib - console app

Winelib - console app

本文关键字:app console Winelib      更新时间:2023-10-16

im开发了一个在Linux上运行并使用Wine Windows DLL的控制台应用程序。

在运行.EXE控制台应用程序时,我能够调用DLL,但我将获得一些意外的输出。

例如:

err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000131-0000-0000-c000-000000000046}
err:ole:marshal_object couldn't get IPSFactory buffer for interface {6d5140c1-7436-11ce-8034-00aa006009fa}
err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x80004002
err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 80004002
err:ole:get_local_server_stream Failed: 80004002
err:winediag:nulldrv_CreateWindow Application tried to create a window, but no driver could be loaded.
err:winediag:nulldrv_CreateWindow The graphics driver is missing. Check your build!
err:winediag:nulldrv_CreateWindow Application tried to create a window, but no driver could be loaded.
err:winediag:nulldrv_CreateWindow The graphics driver is missing. Check your build!
err:ole:apartment_createwindowifneeded CreateWindow failed with error 0
err:ole:apartment_createwindowifneeded CreateWindow failed with error 0
err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000131-0000-0000-c000-000000000046}
err:ole:apartment_createwindowifneeded CreateWindow failed with error 14007
err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hres=0x800736b7
err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, 800736b7
err:ole:get_local_server_stream Failed: 800736b7
err:winediag:nulldrv_CreateWindow Application tried to create a window, but no driver could be loaded.
err:winediag:nulldrv_CreateWindow The graphics driver is missing. Check your build!
err:winediag:nulldrv_CreateWindow Application tried to create a window, but no driver could be loaded.
err:winediag:nulldrv_CreateWindow The graphics driver is missing. Check your build!
err:winediag:nulldrv_CreateWindow Application tried to create a window, but no driver could be loaded.
err:winediag:nulldrv_CreateWindow The graphics driver is missing. Check your build!
Could not load wine-gecko. HTML rendering will be disabled.

似乎葡萄酒期望.exe成为GUI应用。

我使用cmake进行编译。这是我的cmake说明:

# --- Script Setup
cmake_minimum_required (VERSION 2.8)
#if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
#   message(FATAL_ERROR "In-source builds are not allowed.")
#endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
# Disable in-source builds and modifications
# to the source tree.
#set(CMAKE_DISABLE_SOURCE_CHANGES ON)
#set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
# Enable compiler tests.
enable_testing()
set(CMAKE_CXX_COMPILER wineg++)
set(CMAKE_CCC_COMPILER winegcc)
project(CREDIT_SERVICE C CXX)
if(NOT CMAKE_BUILD_TYPE)
    # Build debug by default.
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose build type (options are None, Debug, Release, RelWithDebInfo and MinSizeRel)." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# --- Compiler Properties
set(CREDIT_SERVICE_MAJOR_VERSION 1)
set(CREDIT_SERVICE_MINOR_VERSION 0)
set(CREDIT_SERVICE_PATCH_VERSION 0)
set(CREDIT_SERVICE_BUILD_VERSION 0)
set(CREDIT_SERVICE_VERSION ${COIN_MAJOR_VERSION}.${CREDIT_SERVICE_MINOR_VERSION}.${CREDIT_SERVICE_PATCH_VERSION}.${CREDIT_SERVICE_PATCH_VERSION})
message(STATUS "Building COIN version ${COIN_VERSION} using build type '${CMAKE_BUILD_TYPE}'.")
message(STATUS "    Source directory is '${PROJECT_SOURCE_DIR}'.")
message(STATUS "    Build directory is '${PROJECT_BINARY_DIR}'.")
# --- Compiler Flags
add_definitions( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS )
# Enable most warnings.
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wshadow -Wundef -Wpointer-arith -Wcast-align -Wwrite-strings")
#add version 0x600 as windows define.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x600")
# Use C++11.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Enable/disable optimisation depending on build type.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
# Add version as preprocessor defines.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOIN_VERSION=${COIN_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOIN_MAJOR_VERSION=${COIN_MAJOR_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOIN_MINOR_VERSION=${COIN_MINOR_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOIN_PATCH_VERSION=${COIN_PATCH_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOIN_BUILD_VERSION=${COIN_BUILD_VERSION}")

# Enable/disable profiling information.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
# --- Subdirectories
# All headers are in the /include directory.
include_directories (
    "${PROJECT_SOURCE_DIR}/include"
    )
link_directories ("/usr/local/lib"
    )
# Examples.
add_subdirectory(UnitTest)
# Library code.
add_subdirectory(config4cpp)
add_subdirectory(configure)
add_subdirectory(src)

我尝试添加:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /SUBSYSTEM:console")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --subsystem console")

,但cmake尚未识别这些。

我该如何告诉葡萄酒它是一个控制台应用程序,并且不需要GUI?

好吧,如果您确定问题是在子系统上,那么您可以使用

更改它
editbin.exe /subsystem:console app.exe

editbin工具带有MSVC。您也可以在十六进制编辑器中编辑文件,但首先需要找出其中的子系统字段的偏移。