questions about runing a windows console program with wine

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
CptZhao
Newbie
Newbie
Posts: 3
Joined: Mon Apr 09, 2018 2:54 am

questions about runing a windows console program with wine

Post by CptZhao »

Hi guys, I'm a noob in using wine, after the installation of wine 3.5 instructed by the official installation page on Ubuntu, I can install and run a windows program on my Ubuntu like notepad++.
But when I tried to run a windows console program wrote by my own, things aren't going very well.
I've got a very simple windows console program which just print "this is a windows app" and sleep for 1 sec on and on.
But when I tried to run it, wine warned me:

Code: Select all

0009:err:module:import_dll Loading library VCRUNTIME140D.dll (which is needed by L"Z:\\home\\cptzhao\\wine_test\\wine_debug\\wine_test.exe") failed (error c000007b).
0009:err:module:import_dll Loading library ucrtbased.dll (which is needed by L"Z:\\home\\cptzhao\\wine_test\\wine_debug\\wine_test.exe") failed (error c000007b).
0009:err:module:attach_dlls Importing dlls for L"Z:\\home\\cptzhao\\wine_test\\wine_debug\\wine_test.exe" failed, status c0000135
I searched for the problem on the web, and they said I need to install vcrun2015 using winetricks, which I've already installed also I cant confirm both VCRUNTIME140D.dll and ucrtbased.dll are in my system32 folder, but still the program just can't start running.

I've tried using:
wine wine_test.exe
wine start /home/xxx/xxx/wine_test.exe
wine start /d /home/xx/xx/xx

to start the program but doesn't work.

so anyone can help me with it?

PS. the wine_test.exe console program was wrote on a visual studio 2017 community version, and it runs well on my windows machine
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: questions about runing a windows console program with wi

Post by Bob Wya »

CptZhao wrote: I searched for the problem on the web, and they said I need to install vcrun2015 using winetricks, which I've already installed also I cant confirm both VCRUNTIME140D.dll and ucrtbased.dll are in my system32 folder, but still the program just can't start running.
Ahh but, is that a 64-bit WINEPREFIX you are testing with?
If so then 32-bit libraries would go into:

Code: Select all

C:\windows\syswow64
That's Microsoft logic for you... :shock:
so anyone can help me with it?
CptZhao wrote:PS. the wine_test.exe console program was wrote on a visual studio 2017 community version, and it runs well on my windows machine
Can you rebuild it as a release build - rather than a debug build. Then it will only require the standard:

Code: Select all

winetricks vcrun2015
override.

The libraries:

Code: Select all

vcruntime140d.dll ucrtbased.dll
have debugging symbols enabled (hence the D suffix).

I don't think Wine supports these modified (debug) libraries. I can't did up an old forum thread about this - but I don't believe there is any workarounds...
But you can try running copying over the debug-symbol enabled libraries and overriding them - if you like making lots of work for yourself! :lol:
The full vcrun2015 verb winetricks uses is:

Code: Select all

load_vcrun2015()
{
    # https://www.microsoft.com/en-us/download/details.aspx?id=48145
    # 2015/10/12: fdd1e1f0dcae2d0aa0720895eff33b927d13076e64464bb7c7e5843b7667cd14
    w_download https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe fdd1e1f0dcae2d0aa0720895eff33b927d13076e64464bb7c7e5843b7667cd14

    if w_workaround_wine_bug 37781; then
        w_warn "This may fail in non-XP mode, see https://bugs.winehq.org/show_bug.cgi?id=37781"
    fi

    w_override_dlls native,builtin api-ms-win-crt-conio-l1-1-0 api-ms-win-crt-heap-l1-1-0 api-ms-win-crt-locale-l1-1-0 api-ms-win-crt-math-l1-1-0 api-ms-win-crt-runtime-l1-1-0 api-ms-win-crt-stdio-l1-1-0 api-ms-win-crt-time-l1-1-0 atl140 concrt140 msvcp140 msvcr140 ucrtbase vcomp140 vcruntime140

    w_set_winver winxp

    w_try_cd "$W_CACHE"/"$W_PACKAGE"
    w_try "$WINE" vc_redist.x86.exe $W_UNATTENDED_SLASH_Q

    case "$W_ARCH" in
        win64)
            # Also install the 64-bit version
            # 2015/10/12: 5eea714e1f22f1875c1cb7b1738b0c0b1f02aec5ecb95f0fdb1c5171c6cd93a3
            w_download https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe 5eea714e1f22f1875c1cb7b1738b0c0b1f02aec5ecb95f0fdb1c5171c6cd93a3
            if w_workaround_wine_bug 30713 "Manually extracting the 64-bit dlls"; then
                rm -f "$W_TMP"/*  # Avoid permission error
                w_try_cabextract --directory="$W_TMP" vc_redist.x64.exe
                w_try_cabextract --directory="$W_TMP" "$W_TMP/a10"
                w_try_cabextract --directory="$W_TMP" "$W_TMP/a11"
                cp "$W_TMP"/concrt140.dll "$W_SYSTEM64_DLLS"/concrt140.dll
                cp "$W_TMP"/mfc140.dll "$W_SYSTEM64_DLLS"/mfc140.dll
                cp "$W_TMP"/mfc140u.dll "$W_SYSTEM64_DLLS"/mfc140u.dll
                cp "$W_TMP"/mfcm140.dll "$W_SYSTEM64_DLLS"/mfcm140.dll
                cp "$W_TMP"/mfcm140u.dll "$W_SYSTEM64_DLLS"/mfcm140u.dll
                cp "$W_TMP"/msvcp140.dll "$W_SYSTEM64_DLLS"/msvcp140.dll
                cp "$W_TMP"/vcamp140.dll "$W_SYSTEM64_DLLS"/vcamp140.dll
                cp "$W_TMP"/vccorlib140.dll "$W_SYSTEM64_DLLS"/vccorlib140.dll
                cp "$W_TMP"/vcomp140.dll "$W_SYSTEM64_DLLS"/vcomp140.dll
                cp "$W_TMP"/vcruntime140.dll "$W_SYSTEM64_DLLS"/vcruntime140.dll

                cp "$W_TMP"/api_ms_win_crt_conio_l1_1_0.dll "$W_SYSTEM64_DLLS"/api-ms-win-crt-conio-l1-1-0.dll
                cp "$W_TMP"/api_ms_win_crt_heap_l1_1_0.dll "$W_SYSTEM64_DLLS"/api-ms-win-crt-heap-l1-1-0.dll
                cp "$W_TMP"/api_ms_win_crt_locale_l1_1_0.dll "$W_SYSTEM64_DLLS"/api-ms-win-crt-locale-l1-1-0.dll
                cp "$W_TMP"/api_ms_win_crt_math_l1_1_0.dll "$W_SYSTEM64_DLLS"/api-ms-win-crt-math-l1-1-0.dll
                cp "$W_TMP"/api_ms_win_crt_runtime_l1_1_0.dll "$W_SYSTEM64_DLLS"/api-ms-win-crt-runtime-l1-1-0.dll
                cp "$W_TMP"/api_ms_win_crt_stdio_l1_1_0.dll "$W_SYSTEM64_DLLS"/api-ms-win-crt-stdio-l1-1-0.dll
                cp "$W_TMP"/ucrtbase.dll "$W_SYSTEM64_DLLS"/ucrtbase.dll
            else
                w_try "$WINE" vc_redist.x64.exe $W_UNATTENDED_SLASH_Q
            fi
            ;;
    esac
}
Bob
CptZhao
Newbie
Newbie
Posts: 3
Joined: Mon Apr 09, 2018 2:54 am

Re: questions about runing a windows console program with wi

Post by CptZhao »

Thanks Bob, you actually solved my problem, thanks a lot bro.

And I have another question about Wine, if I want to make a docker that have Wine environment, can I install all the run-time or libs that required in no GUI environment?
Cuz I noticed installing wine using the official method while I first run sth, like notepad.exe Wine told me to install mono or other stuff, but they all need a actual GUI window to check and confirmed to install these things, also while installing vcrun2015 it needs GUI either.
Can I do all these things in no GUI environment?
You know I'm using Wine just try to run some windows server programs.
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: questions about runing a windows console program with wi

Post by Bob Wya »

CptZhao wrote:Thanks Bob, you actually solved my problem, thanks a lot bro.

And I have another question about Wine, if I want to make a docker that have Wine environment, can I install all the run-time or libs that required in no GUI environment?
Cuz I noticed installing wine using the official method while I first run sth, like notepad.exe Wine told me to install mono or other stuff, but they all need a actual GUI window to check and confirmed to install these things, also while installing vcrun2015 it needs GUI either.
Can I do all these things in no GUI environment?
You know I'm using Wine just try to run some windows server programs.
No worries... 8)

To run almost any Windows application - Wine is going to require X - in some form.
You can build Wine without X support - but it's probably not going to be much use in that state...

For a headless setup - see: superuser: Run wine totally headless
You can still use AutoIt or AutoHotKey to automate Window events - in this virtual X environment.
If this is required...

Bob
CptZhao
Newbie
Newbie
Posts: 3
Joined: Mon Apr 09, 2018 2:54 am

Re: questions about runing a windows console program with wi

Post by CptZhao »

Bob Wya wrote:
CptZhao wrote:Thanks Bob, you actually solved my problem, thanks a lot bro.

And I have another question about Wine, if I want to make a docker that have Wine environment, can I install all the run-time or libs that required in no GUI environment?
Cuz I noticed installing wine using the official method while I first run sth, like notepad.exe Wine told me to install mono or other stuff, but they all need a actual GUI window to check and confirmed to install these things, also while installing vcrun2015 it needs GUI either.
Can I do all these things in no GUI environment?
You know I'm using Wine just try to run some windows server programs.
No worries... 8)

To run almost any Windows application - Wine is going to require X - in some form.
You can build Wine without X support - but it's probably not going to be much use in that state...

For a headless setup - see: superuser: Run wine totally headless
You can still use AutoIt or AutoHotKey to automate Window events - in this virtual X environment.
If this is required...

Bob
I'll check and try these things out. Again, thanks a lot bro!
Locked