Skip to content

Error when running self build rust9x-sample executable  #37

@werwolf2303

Description

@werwolf2303

When I run the executable it spits out a dialog with this message: "The procedure entry point InitializeCriticalSectionEx could not be located in the dynamic link library KERNEL32.dll".

VM OS: Windows XP Professional x86
Host: Arch Linux
VM Build OS: Windows 10 Pro x64
MSVC Version: 14.16.27023

I'm using the newest rust9x toolchain

editbin.exe gives me also this warning: "LINK : warning LNK4241: invalid subsystem version number 4"

Cargo.toml

[package]
name = "rust9x_sample"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
# Enables the sockaddr and TCP tests, which in turn add a static dependency on WinSock 2
# (ws2_32.dll). This has to be turned off for Windows NT < 4.0, or for Windows 95 without installed
# WinSock 2.
network = []

[dependencies]

[profile.release]
lto = "thin"
codegen-units = 1
debug = 2
# Unwind support needs at least VC8 (VS2005)
panic = "unwind"
# panic = "abort"

config.toml

[build]

[target.'cfg(target_vendor = "rust9x")']
rustflags = [
  # Show linker args if needed
  # '--print=link-args',

  # statically linked runtime
  '-Ctarget-feature=+crt-static',
  # dynamically linked runtime
  # '-Ctarget-feature=-crt-static',

  # Add search paths
  # '-Clink-args=/LIBPATH:X:\rustprojs\rust9x\r9x-buildtools\vc71\Vc7\lib',
  # '-Clink-args=/LIBPATH:X:\rustprojs\rust9x\r9x-buildtools\vc71\Vc7\PlatformSDK\Lib',
  #'-Clink-args=/LIBPATH:C:\Users\werwolf\Desktop\WindowsXPToolkit\MSVC\14.16.27023\lib',
  #'-Clink-args=/LIBPATH:C:\Users\werwolf\Desktop\WindowsXPToolkit\v7.1A\Lib',

  # (optional) Disable default libs for full control over linked libraries
  # '-Clink-args=/NODEFAULTLIB',

  # Remove default libs that unicows wraps/overrides
  '-Clink-args=/nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool.lib /nod:vfw32.lib /nod:secur32.lib /nod:oleacc.lib /nod:oledlg.lib /nod:sensapi.lib',

  # Then link unicows itself, allowing the linker to resolve symbols to it instead of the wrapped
  # libraries
  '-Clink-arg=unicows.lib',

  # Then add back the default libs that were removed
  '-Clink-args=kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib',
]

justfile

set shell := ['powershell.exe', '-c']

r9x_toolchain := 'rust9x'
r9x_target := 'i586-rust9x-windows-msvc'
r9x_editbin := '..\MSVC\14.16.27023\bin\Hostx86\x86\editbin.exe'

# These settings shoud work for Windows 95+ and NT 3.51+. 
subsystem := 'CONSOLE,4.0'
os_version := '3.1'

build *FLAGS: (do-build 'debug' FLAGS)
release *FLAGS: (do-build 'release' '--release' FLAGS)
do-build PROFILE *FLAGS='': (r9x 'build' '--target' r9x_target FLAGS) (editbin 'target\'+r9x_target+'\'+PROFILE+'\rust9x_sample.exe')
run *FLAGS: (r9x 'run' '--target' r9x_target FLAGS)

r9x $COMMAND *FLAGS:
    cargo +{{ r9x_toolchain }} {{ COMMAND }} {{ FLAGS }}

# PE executables specify the subsystem and subsystem version as well as the required OS version.
#
# `link.exe` has the same switches, but doesn't allow setting them to values that lie outside of the
# supported range of the toolset. `editbin.exe` is a bit more forgiving, only warning about
# "invalid" values (`LINK : warning LNK4241: invalid subsystem version number 4`), but still
# carrying out the change as requested. `/OSVERSION` is entirely undocumented, but still works,
# setting the minimum required OS version. Both values must be in a supported range for the target
# OS to accept and run the executable.
editbin EXECUTABLE:
    & "{{ r9x_editbin }}" {{ EXECUTABLE }} /SUBSYSTEM:{{ subsystem }} /OSVERSION:{{ os_version }} /RELEASE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions