A dockerized C++ windows console application exited with code 3221225781
up vote
1
down vote
favorite
I Have written a very simple c++ hello world program
#pragma once
#include <iostream>
#include <fstream>
int main()
{
std::cout << "Hello Docker world!n";
return 0;
}
This is build as a release x64 windows console application and thus produces an exe
than I dockerize this program using the following dockerfile
FROM microsoft/windowsservercore
ADD ./DockerHello.exe /DockerHello.exe
# Run exe when the container launches
CMD C:DockerHello.exe
However when i use docker run it will show nothing and when i use docker ps -a I see that it has exited with code 3221225781
From some online searching I understand that this apparently means that I am missing some dll or so, but I have no idea how to find out which?
Can anybody help me? Or tell me how I can get a simple c++ console application working in docker?
c++ docker
|
show 1 more comment
up vote
1
down vote
favorite
I Have written a very simple c++ hello world program
#pragma once
#include <iostream>
#include <fstream>
int main()
{
std::cout << "Hello Docker world!n";
return 0;
}
This is build as a release x64 windows console application and thus produces an exe
than I dockerize this program using the following dockerfile
FROM microsoft/windowsservercore
ADD ./DockerHello.exe /DockerHello.exe
# Run exe when the container launches
CMD C:DockerHello.exe
However when i use docker run it will show nothing and when i use docker ps -a I see that it has exited with code 3221225781
From some online searching I understand that this apparently means that I am missing some dll or so, but I have no idea how to find out which?
Can anybody help me? Or tell me how I can get a simple c++ console application working in docker?
c++ docker
How did you linkDockerHello.exe
for the runtime? Did you use/MT
or/MD
, if using MSVC? If you don't have the MSVC runtime in the Docker container and linked with/MD
, it could fail to find the DLLs it requires.
– Alexander Huszagh
Nov 22 at 12:54
I am using MSVS 2017. I do not understand what you mean by linking with /MD or /MT so it could very well be my problem
– user180146
Nov 22 at 13:05
Every C or C++ application needs a runtime, a library that contains the core functionality of the C standard library (or C++), and MSVC allows you to statically link to a runtime when compiling code, so the runtime does not need to be installed on the computer the code is run on: msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
– Alexander Huszagh
Nov 22 at 13:07
If you've ever wondered why you need to install "Visual C++ Redistributable Packages for Visual Studio 20XX" sometimes when running a new application, it's because the code was linked to a shared runtime (/MD
), and so Windows needs to install that version of the runtime (a DLL) to use the code.
– Alexander Huszagh
Nov 22 at 13:09
1
It was set to /MD I made it /MT and now it works. Thank you.
– user180146
Nov 22 at 13:22
|
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I Have written a very simple c++ hello world program
#pragma once
#include <iostream>
#include <fstream>
int main()
{
std::cout << "Hello Docker world!n";
return 0;
}
This is build as a release x64 windows console application and thus produces an exe
than I dockerize this program using the following dockerfile
FROM microsoft/windowsservercore
ADD ./DockerHello.exe /DockerHello.exe
# Run exe when the container launches
CMD C:DockerHello.exe
However when i use docker run it will show nothing and when i use docker ps -a I see that it has exited with code 3221225781
From some online searching I understand that this apparently means that I am missing some dll or so, but I have no idea how to find out which?
Can anybody help me? Or tell me how I can get a simple c++ console application working in docker?
c++ docker
I Have written a very simple c++ hello world program
#pragma once
#include <iostream>
#include <fstream>
int main()
{
std::cout << "Hello Docker world!n";
return 0;
}
This is build as a release x64 windows console application and thus produces an exe
than I dockerize this program using the following dockerfile
FROM microsoft/windowsservercore
ADD ./DockerHello.exe /DockerHello.exe
# Run exe when the container launches
CMD C:DockerHello.exe
However when i use docker run it will show nothing and when i use docker ps -a I see that it has exited with code 3221225781
From some online searching I understand that this apparently means that I am missing some dll or so, but I have no idea how to find out which?
Can anybody help me? Or tell me how I can get a simple c++ console application working in docker?
c++ docker
c++ docker
asked Nov 22 at 12:51
user180146
112
112
How did you linkDockerHello.exe
for the runtime? Did you use/MT
or/MD
, if using MSVC? If you don't have the MSVC runtime in the Docker container and linked with/MD
, it could fail to find the DLLs it requires.
– Alexander Huszagh
Nov 22 at 12:54
I am using MSVS 2017. I do not understand what you mean by linking with /MD or /MT so it could very well be my problem
– user180146
Nov 22 at 13:05
Every C or C++ application needs a runtime, a library that contains the core functionality of the C standard library (or C++), and MSVC allows you to statically link to a runtime when compiling code, so the runtime does not need to be installed on the computer the code is run on: msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
– Alexander Huszagh
Nov 22 at 13:07
If you've ever wondered why you need to install "Visual C++ Redistributable Packages for Visual Studio 20XX" sometimes when running a new application, it's because the code was linked to a shared runtime (/MD
), and so Windows needs to install that version of the runtime (a DLL) to use the code.
– Alexander Huszagh
Nov 22 at 13:09
1
It was set to /MD I made it /MT and now it works. Thank you.
– user180146
Nov 22 at 13:22
|
show 1 more comment
How did you linkDockerHello.exe
for the runtime? Did you use/MT
or/MD
, if using MSVC? If you don't have the MSVC runtime in the Docker container and linked with/MD
, it could fail to find the DLLs it requires.
– Alexander Huszagh
Nov 22 at 12:54
I am using MSVS 2017. I do not understand what you mean by linking with /MD or /MT so it could very well be my problem
– user180146
Nov 22 at 13:05
Every C or C++ application needs a runtime, a library that contains the core functionality of the C standard library (or C++), and MSVC allows you to statically link to a runtime when compiling code, so the runtime does not need to be installed on the computer the code is run on: msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
– Alexander Huszagh
Nov 22 at 13:07
If you've ever wondered why you need to install "Visual C++ Redistributable Packages for Visual Studio 20XX" sometimes when running a new application, it's because the code was linked to a shared runtime (/MD
), and so Windows needs to install that version of the runtime (a DLL) to use the code.
– Alexander Huszagh
Nov 22 at 13:09
1
It was set to /MD I made it /MT and now it works. Thank you.
– user180146
Nov 22 at 13:22
How did you link
DockerHello.exe
for the runtime? Did you use /MT
or /MD
, if using MSVC? If you don't have the MSVC runtime in the Docker container and linked with /MD
, it could fail to find the DLLs it requires.– Alexander Huszagh
Nov 22 at 12:54
How did you link
DockerHello.exe
for the runtime? Did you use /MT
or /MD
, if using MSVC? If you don't have the MSVC runtime in the Docker container and linked with /MD
, it could fail to find the DLLs it requires.– Alexander Huszagh
Nov 22 at 12:54
I am using MSVS 2017. I do not understand what you mean by linking with /MD or /MT so it could very well be my problem
– user180146
Nov 22 at 13:05
I am using MSVS 2017. I do not understand what you mean by linking with /MD or /MT so it could very well be my problem
– user180146
Nov 22 at 13:05
Every C or C++ application needs a runtime, a library that contains the core functionality of the C standard library (or C++), and MSVC allows you to statically link to a runtime when compiling code, so the runtime does not need to be installed on the computer the code is run on: msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
– Alexander Huszagh
Nov 22 at 13:07
Every C or C++ application needs a runtime, a library that contains the core functionality of the C standard library (or C++), and MSVC allows you to statically link to a runtime when compiling code, so the runtime does not need to be installed on the computer the code is run on: msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
– Alexander Huszagh
Nov 22 at 13:07
If you've ever wondered why you need to install "Visual C++ Redistributable Packages for Visual Studio 20XX" sometimes when running a new application, it's because the code was linked to a shared runtime (
/MD
), and so Windows needs to install that version of the runtime (a DLL) to use the code.– Alexander Huszagh
Nov 22 at 13:09
If you've ever wondered why you need to install "Visual C++ Redistributable Packages for Visual Studio 20XX" sometimes when running a new application, it's because the code was linked to a shared runtime (
/MD
), and so Windows needs to install that version of the runtime (a DLL) to use the code.– Alexander Huszagh
Nov 22 at 13:09
1
1
It was set to /MD I made it /MT and now it works. Thank you.
– user180146
Nov 22 at 13:22
It was set to /MD I made it /MT and now it works. Thank you.
– user180146
Nov 22 at 13:22
|
show 1 more comment
3 Answers
3
active
oldest
votes
up vote
0
down vote
accepted
As confirmed in the comments, the issue stems from the runtime library not being present on the Docker image for code compiled from MSVC.
To solve this, you may either:
- Statically link to the runtime, using the
/MT
flag. - Install the correct runtime on the docker image.
Static Linking
The /MT
flag (or variants) must be passed to msbuild, which through Visual Studio can be done as follows (from Microsoft's documentation):
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Expand the C/C++ folder.
Select the Code Generation property page.
Modify the Runtime Library property.
Install Runtime
To install the correct runtime, you must install the redistributable while building of the docker image.
ADD $url /vc_redist.exe
RUN C:vc_redist.exe /quiet /install
For Visual Studio, these are the correct URL (as of today's date, feel free to edit to update):
Where the $url
is the path to the correct Visual Studio Redistributable (links provided below):
- Visual Studio 2017, x86, x86-64
- Visual Studio 2015, x86, x86-64
- Visual Studio 2013, x86, x86-64
Docker Image Selection
As the OP notes in the comments, the microsoft/nanoserver
image is sufficient when using static runtime linking, however, if using shared runtime linking, you should use the microsoft/windowsservercore
image, otherwise, the installation of the redistributable fails.
1
I found that with static linking the image microsoft/nanoserver is enough however when I use the install runtime approach I need to use microsoft/windowsservercore (otherwise install of vc_redist fails) so that might be a factor in choosing either of the two solutions
– user180146
Nov 22 at 14:21
add a comment |
up vote
0
down vote
You can see the problem by using docker logs:
docker logs <container name or ID>
I had found this before but it does not display anything for me
– user180146
Nov 22 at 13:13
add a comment |
up vote
0
down vote
Most probably you are using the wrong docker image. Looking at this issue on github it looks like you need to be using the following Dockerfile
:
FROM microsoft/dotnet-framework:4.6.2
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:vc_redist.x64.exe /quiet /install
ADD ./DockerHello.exe /DockerHello.exe
CMD C:DockerHello.exe
P.S. I don't have windows to test this on, but if you play around with it, it should be working. Maybe it might work with the microsoft/windowsservercore
image as well.
The Docker image isn't the issue, but installing the VC Redistributable is a great guess (and confirmed in the comments).
– Alexander Huszagh
Nov 22 at 13:33
1
Actually i made it microsoft/windowsservercore in order to try and fix it previously. Now that I have it working it seems that microsoft/nanoserver also will do as an image as long as I use static linking
– user180146
Nov 22 at 13:39
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431448%2fa-dockerized-c-windows-console-application-exited-with-code-3221225781%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
As confirmed in the comments, the issue stems from the runtime library not being present on the Docker image for code compiled from MSVC.
To solve this, you may either:
- Statically link to the runtime, using the
/MT
flag. - Install the correct runtime on the docker image.
Static Linking
The /MT
flag (or variants) must be passed to msbuild, which through Visual Studio can be done as follows (from Microsoft's documentation):
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Expand the C/C++ folder.
Select the Code Generation property page.
Modify the Runtime Library property.
Install Runtime
To install the correct runtime, you must install the redistributable while building of the docker image.
ADD $url /vc_redist.exe
RUN C:vc_redist.exe /quiet /install
For Visual Studio, these are the correct URL (as of today's date, feel free to edit to update):
Where the $url
is the path to the correct Visual Studio Redistributable (links provided below):
- Visual Studio 2017, x86, x86-64
- Visual Studio 2015, x86, x86-64
- Visual Studio 2013, x86, x86-64
Docker Image Selection
As the OP notes in the comments, the microsoft/nanoserver
image is sufficient when using static runtime linking, however, if using shared runtime linking, you should use the microsoft/windowsservercore
image, otherwise, the installation of the redistributable fails.
1
I found that with static linking the image microsoft/nanoserver is enough however when I use the install runtime approach I need to use microsoft/windowsservercore (otherwise install of vc_redist fails) so that might be a factor in choosing either of the two solutions
– user180146
Nov 22 at 14:21
add a comment |
up vote
0
down vote
accepted
As confirmed in the comments, the issue stems from the runtime library not being present on the Docker image for code compiled from MSVC.
To solve this, you may either:
- Statically link to the runtime, using the
/MT
flag. - Install the correct runtime on the docker image.
Static Linking
The /MT
flag (or variants) must be passed to msbuild, which through Visual Studio can be done as follows (from Microsoft's documentation):
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Expand the C/C++ folder.
Select the Code Generation property page.
Modify the Runtime Library property.
Install Runtime
To install the correct runtime, you must install the redistributable while building of the docker image.
ADD $url /vc_redist.exe
RUN C:vc_redist.exe /quiet /install
For Visual Studio, these are the correct URL (as of today's date, feel free to edit to update):
Where the $url
is the path to the correct Visual Studio Redistributable (links provided below):
- Visual Studio 2017, x86, x86-64
- Visual Studio 2015, x86, x86-64
- Visual Studio 2013, x86, x86-64
Docker Image Selection
As the OP notes in the comments, the microsoft/nanoserver
image is sufficient when using static runtime linking, however, if using shared runtime linking, you should use the microsoft/windowsservercore
image, otherwise, the installation of the redistributable fails.
1
I found that with static linking the image microsoft/nanoserver is enough however when I use the install runtime approach I need to use microsoft/windowsservercore (otherwise install of vc_redist fails) so that might be a factor in choosing either of the two solutions
– user180146
Nov 22 at 14:21
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
As confirmed in the comments, the issue stems from the runtime library not being present on the Docker image for code compiled from MSVC.
To solve this, you may either:
- Statically link to the runtime, using the
/MT
flag. - Install the correct runtime on the docker image.
Static Linking
The /MT
flag (or variants) must be passed to msbuild, which through Visual Studio can be done as follows (from Microsoft's documentation):
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Expand the C/C++ folder.
Select the Code Generation property page.
Modify the Runtime Library property.
Install Runtime
To install the correct runtime, you must install the redistributable while building of the docker image.
ADD $url /vc_redist.exe
RUN C:vc_redist.exe /quiet /install
For Visual Studio, these are the correct URL (as of today's date, feel free to edit to update):
Where the $url
is the path to the correct Visual Studio Redistributable (links provided below):
- Visual Studio 2017, x86, x86-64
- Visual Studio 2015, x86, x86-64
- Visual Studio 2013, x86, x86-64
Docker Image Selection
As the OP notes in the comments, the microsoft/nanoserver
image is sufficient when using static runtime linking, however, if using shared runtime linking, you should use the microsoft/windowsservercore
image, otherwise, the installation of the redistributable fails.
As confirmed in the comments, the issue stems from the runtime library not being present on the Docker image for code compiled from MSVC.
To solve this, you may either:
- Statically link to the runtime, using the
/MT
flag. - Install the correct runtime on the docker image.
Static Linking
The /MT
flag (or variants) must be passed to msbuild, which through Visual Studio can be done as follows (from Microsoft's documentation):
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
Expand the C/C++ folder.
Select the Code Generation property page.
Modify the Runtime Library property.
Install Runtime
To install the correct runtime, you must install the redistributable while building of the docker image.
ADD $url /vc_redist.exe
RUN C:vc_redist.exe /quiet /install
For Visual Studio, these are the correct URL (as of today's date, feel free to edit to update):
Where the $url
is the path to the correct Visual Studio Redistributable (links provided below):
- Visual Studio 2017, x86, x86-64
- Visual Studio 2015, x86, x86-64
- Visual Studio 2013, x86, x86-64
Docker Image Selection
As the OP notes in the comments, the microsoft/nanoserver
image is sufficient when using static runtime linking, however, if using shared runtime linking, you should use the microsoft/windowsservercore
image, otherwise, the installation of the redistributable fails.
edited Nov 22 at 14:40
answered Nov 22 at 13:40
Alexander Huszagh
6,91321949
6,91321949
1
I found that with static linking the image microsoft/nanoserver is enough however when I use the install runtime approach I need to use microsoft/windowsservercore (otherwise install of vc_redist fails) so that might be a factor in choosing either of the two solutions
– user180146
Nov 22 at 14:21
add a comment |
1
I found that with static linking the image microsoft/nanoserver is enough however when I use the install runtime approach I need to use microsoft/windowsservercore (otherwise install of vc_redist fails) so that might be a factor in choosing either of the two solutions
– user180146
Nov 22 at 14:21
1
1
I found that with static linking the image microsoft/nanoserver is enough however when I use the install runtime approach I need to use microsoft/windowsservercore (otherwise install of vc_redist fails) so that might be a factor in choosing either of the two solutions
– user180146
Nov 22 at 14:21
I found that with static linking the image microsoft/nanoserver is enough however when I use the install runtime approach I need to use microsoft/windowsservercore (otherwise install of vc_redist fails) so that might be a factor in choosing either of the two solutions
– user180146
Nov 22 at 14:21
add a comment |
up vote
0
down vote
You can see the problem by using docker logs:
docker logs <container name or ID>
I had found this before but it does not display anything for me
– user180146
Nov 22 at 13:13
add a comment |
up vote
0
down vote
You can see the problem by using docker logs:
docker logs <container name or ID>
I had found this before but it does not display anything for me
– user180146
Nov 22 at 13:13
add a comment |
up vote
0
down vote
up vote
0
down vote
You can see the problem by using docker logs:
docker logs <container name or ID>
You can see the problem by using docker logs:
docker logs <container name or ID>
answered Nov 22 at 13:06
gabrielpe
82
82
I had found this before but it does not display anything for me
– user180146
Nov 22 at 13:13
add a comment |
I had found this before but it does not display anything for me
– user180146
Nov 22 at 13:13
I had found this before but it does not display anything for me
– user180146
Nov 22 at 13:13
I had found this before but it does not display anything for me
– user180146
Nov 22 at 13:13
add a comment |
up vote
0
down vote
Most probably you are using the wrong docker image. Looking at this issue on github it looks like you need to be using the following Dockerfile
:
FROM microsoft/dotnet-framework:4.6.2
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:vc_redist.x64.exe /quiet /install
ADD ./DockerHello.exe /DockerHello.exe
CMD C:DockerHello.exe
P.S. I don't have windows to test this on, but if you play around with it, it should be working. Maybe it might work with the microsoft/windowsservercore
image as well.
The Docker image isn't the issue, but installing the VC Redistributable is a great guess (and confirmed in the comments).
– Alexander Huszagh
Nov 22 at 13:33
1
Actually i made it microsoft/windowsservercore in order to try and fix it previously. Now that I have it working it seems that microsoft/nanoserver also will do as an image as long as I use static linking
– user180146
Nov 22 at 13:39
add a comment |
up vote
0
down vote
Most probably you are using the wrong docker image. Looking at this issue on github it looks like you need to be using the following Dockerfile
:
FROM microsoft/dotnet-framework:4.6.2
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:vc_redist.x64.exe /quiet /install
ADD ./DockerHello.exe /DockerHello.exe
CMD C:DockerHello.exe
P.S. I don't have windows to test this on, but if you play around with it, it should be working. Maybe it might work with the microsoft/windowsservercore
image as well.
The Docker image isn't the issue, but installing the VC Redistributable is a great guess (and confirmed in the comments).
– Alexander Huszagh
Nov 22 at 13:33
1
Actually i made it microsoft/windowsservercore in order to try and fix it previously. Now that I have it working it seems that microsoft/nanoserver also will do as an image as long as I use static linking
– user180146
Nov 22 at 13:39
add a comment |
up vote
0
down vote
up vote
0
down vote
Most probably you are using the wrong docker image. Looking at this issue on github it looks like you need to be using the following Dockerfile
:
FROM microsoft/dotnet-framework:4.6.2
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:vc_redist.x64.exe /quiet /install
ADD ./DockerHello.exe /DockerHello.exe
CMD C:DockerHello.exe
P.S. I don't have windows to test this on, but if you play around with it, it should be working. Maybe it might work with the microsoft/windowsservercore
image as well.
Most probably you are using the wrong docker image. Looking at this issue on github it looks like you need to be using the following Dockerfile
:
FROM microsoft/dotnet-framework:4.6.2
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe /vc_redist.x64.exe
RUN C:vc_redist.x64.exe /quiet /install
ADD ./DockerHello.exe /DockerHello.exe
CMD C:DockerHello.exe
P.S. I don't have windows to test this on, but if you play around with it, it should be working. Maybe it might work with the microsoft/windowsservercore
image as well.
answered Nov 22 at 13:14
tftd
10.9k53984
10.9k53984
The Docker image isn't the issue, but installing the VC Redistributable is a great guess (and confirmed in the comments).
– Alexander Huszagh
Nov 22 at 13:33
1
Actually i made it microsoft/windowsservercore in order to try and fix it previously. Now that I have it working it seems that microsoft/nanoserver also will do as an image as long as I use static linking
– user180146
Nov 22 at 13:39
add a comment |
The Docker image isn't the issue, but installing the VC Redistributable is a great guess (and confirmed in the comments).
– Alexander Huszagh
Nov 22 at 13:33
1
Actually i made it microsoft/windowsservercore in order to try and fix it previously. Now that I have it working it seems that microsoft/nanoserver also will do as an image as long as I use static linking
– user180146
Nov 22 at 13:39
The Docker image isn't the issue, but installing the VC Redistributable is a great guess (and confirmed in the comments).
– Alexander Huszagh
Nov 22 at 13:33
The Docker image isn't the issue, but installing the VC Redistributable is a great guess (and confirmed in the comments).
– Alexander Huszagh
Nov 22 at 13:33
1
1
Actually i made it microsoft/windowsservercore in order to try and fix it previously. Now that I have it working it seems that microsoft/nanoserver also will do as an image as long as I use static linking
– user180146
Nov 22 at 13:39
Actually i made it microsoft/windowsservercore in order to try and fix it previously. Now that I have it working it seems that microsoft/nanoserver also will do as an image as long as I use static linking
– user180146
Nov 22 at 13:39
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431448%2fa-dockerized-c-windows-console-application-exited-with-code-3221225781%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How did you link
DockerHello.exe
for the runtime? Did you use/MT
or/MD
, if using MSVC? If you don't have the MSVC runtime in the Docker container and linked with/MD
, it could fail to find the DLLs it requires.– Alexander Huszagh
Nov 22 at 12:54
I am using MSVS 2017. I do not understand what you mean by linking with /MD or /MT so it could very well be my problem
– user180146
Nov 22 at 13:05
Every C or C++ application needs a runtime, a library that contains the core functionality of the C standard library (or C++), and MSVC allows you to statically link to a runtime when compiling code, so the runtime does not need to be installed on the computer the code is run on: msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
– Alexander Huszagh
Nov 22 at 13:07
If you've ever wondered why you need to install "Visual C++ Redistributable Packages for Visual Studio 20XX" sometimes when running a new application, it's because the code was linked to a shared runtime (
/MD
), and so Windows needs to install that version of the runtime (a DLL) to use the code.– Alexander Huszagh
Nov 22 at 13:09
1
It was set to /MD I made it /MT and now it works. Thank you.
– user180146
Nov 22 at 13:22