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

Document deployment dependencies for native image #7747

Closed
anthonyvdotbe opened this issue Nov 7, 2023 · 12 comments
Closed

Document deployment dependencies for native image #7747

anthonyvdotbe opened this issue Nov 7, 2023 · 12 comments
Assignees
Labels

Comments

@anthonyvdotbe
Copy link

anthonyvdotbe commented Nov 7, 2023

Describe the issue
On Windows, I had to install the Microsoft Visual C++ 2015-2022 Redistributable to get my native image working on a host other than the one I built the image on. I assumed native images didn't have any deployment dependencies. It would be good to mention these in Getting Started with Native Image.

Steps to reproduce the issue

  • create a native image (e.g. this one)
  • attempt to run it on a host without the Visual C++ Redistributable (e.g. a fresh Windows 11 installation)

Expected: prints the hello world message
Actual: exits with code -1073741515 and doesn't print anything

Describe GraalVM and your environment:

  • GraalVM version: native-image 21.0.1 2023-10-17
  • JDK major version: 21
  • OS: Windows 11 (Microsoft Windows 10.0.22621)
  • Architecture: AMD64

More details
@selhagani I've updated with the requested info

@selhagani
Copy link
Member

Hi @anthonyvdotbe Could you please share a reproducer with me? Could you also share with me the version of graalVM, the host, and the OS version?

@selhagani selhagani self-assigned this Nov 7, 2023
@selhagani
Copy link
Member

Hi @anthonyvdotbe I have just tested on a fresh installation of windows and it worked just fine for me. On my end having Microsoft Visual C++ 2015-2022 Redistributable is not a requirement to run the executable.

@anthonyvdotbe
Copy link
Author

anthonyvdotbe commented Nov 20, 2023

So either our executables are different, or your installation of Windows somehow already contains the redistributable.

This is my executable (renamed to .zip because GitHub doesn't allow uploading .exe files):
helloworld.zip

And below is a screencast of me reproducing the issue. The initial terminal window is on the host, to show the commands I ran to create the executable. Everything else is in a fresh Windows Sandbox (the only customization I did, is to make the host's Downloads folder accessible within the Windows Sandbox).

PS: mentions result in a notification on my smartphone, so please only mention me if you need an urgent response (which is unlikely) or if I'm not yet participating in the thread (as the author of this issue, I'm notified of any comments already), thanks

output.mp4

@selhagani
Copy link
Member

Actually your issue is indeed normal. You are required to have Visual Studio and Microsoft Visual C++(MSVC) installed on windows to run your application. It is also mentioned in the documentation. If you go to the windows section of the documentation You'll find that it is mentioned there.

@anthonyvdotbe
Copy link
Author

I understand that Visual Studio et al. are required to build an application with native image. What is not documented, is that the resulting .exe is not self-sufficient. In other words: I cannot just send executables built with GraalVM to other people. I'll need to explain them how to install the Visual C++ Redistributable or create an installer to do it for them (and in that case, I could just as well use JDK's jlink and jpackage instead of GraalVM Native Image). This fact is not documented in the docs, so please reopen this issue.

@selhagani selhagani reopened this Nov 20, 2023
@selhagani
Copy link
Member

I get you now. I'll keep investigating on my end and I'll keep you posted. Thank you!

@selhagani
Copy link
Member

Could you please specify if the environment you shared with me in the beginning is the one where you try to run your executable? if yes then could you share info of the environment where you built your native image?
I would also like to get more detail about the error you are encountering. Could you please open event viewer on your windows machine then go to windows logs then find the error corresponding to your issue and send me the details of the error?

@anthonyvdotbe
Copy link
Author

Could you please specify if the environment you shared with me in the beginning is the one where you try to run your executable? if yes then could you share info of the environment where you built your native image?

No.

I would also like to get more detail about the error you are encountering. Could you please open event viewer on your windows machine then go to windows logs then find the error corresponding to your issue and send me the details of the error?

To reproduce: open a Windows Sandbox, download the executable I attached above and change its extension to .exe again (or build the executable yourself if you don't trust the attachment), and try to run it.

@oubidar-Abderrahim
Copy link
Member

  • Visual C++ Redistributable or Visual Studio Build Tools are only required on the machine used to build the native image, they are not a requirement for running previously generated images.
  • Native Windows-generated images are not statically linked, meaning they may need specific dependencies (DLL files) based on each use case. Usually, the native image builder extracts these DLLs and puts them in the same directory as you generated EXE file.
  • If installing Visual C++ Redistributable or Visual Studio Build Tools resolves the issue, that does not mean they are necessary for a native image to run, that could also indicate that the missing DLL was installed via these tools.
  • Since our team was able to run a HelloWorld example on a freshly installed Windows machine without the need to install any extra dependency, I'm afraid we won't be able to assist you unless you're willing to help us. You can do so by sharing what are the exact version of Windows used for building the image and for running it (I'm assuming what was provided in the description above is the running environment, so kindly provide details on the build environment)
  • We do not accept unknown executables for reproducing issues for security reasons, please whenever you need to share a code with us, create a public repository on Github and share with us the steps to build or share the code directly if it's small enough.
  • Finally, please keep in mind that GraalVM is an open-source project. As such, you are more than welcome to contribute code and improve our documentation. We also welcome feedback and suggestions from the community, as long as it is respectful.

@anthonyvdotbe
Copy link
Author

  • Visual C++ Redistributable or Visual Studio Build Tools are only required on the machine used to build the native image, they are not a requirement for running previously generated images.
  • Native Windows-generated images are not statically linked, meaning they may need specific dependencies (DLL files) based on each use case. Usually, the native image builder extracts these DLLs and puts them in the same directory as you generated EXE file.

In my case, following the instructions to build a helloworld executable from a class, it doesn't.

  • If installing Visual C++ Redistributable or Visual Studio Build Tools resolves the issue, that does not mean they are necessary for a native image to run, that could also indicate that the missing DLL was installed via these tools.
  • Since our team was able to run a HelloWorld example on a freshly installed Windows machine without the need to install any extra dependency, I'm afraid we won't be able to assist you unless you're willing to help us. You can do so by sharing what are the exact version of Windows used for building the image and for running it (I'm assuming what was provided in the description above is the running environment, so kindly provide details on the build environment)

Let me clarify what I mean with "freshly installed Windows machine": a Windows installation using this ISO or a Windows Sandbox instance.
The Windows versions are as given above, both on the host where I'm building and on the host where I'm running.

  • We do not accept unknown executables for reproducing issues for security reasons, please whenever you need to share a code with us, create a public repository on Github and share with us the steps to build or share the code directly if it's small enough.

I'm just using the one from the guide:

Save this code into file named HelloWorld.java:

 public class HelloWorld {
     public static void main(String[] args) {
         System.out.println("Hello, Native World!");
     }
 }

Compile it and build a native executable from the Java class:

javac HelloWorld.java
native-image HelloWorld
  • Finally, please keep in mind that GraalVM is an open-source project. As such, you are more than welcome to contribute code and improve our documentation. We also welcome feedback and suggestions from the community, as long as it is respectful.

@selhagani
Copy link
Member

The issue you're facing is pretty much the same as This one.
Basically, this behavior is to be expected so it isn't really a bug but more of a new feature. Feel free to follow up on any further discussions about this on the first issue.

@kristofdho
Copy link

@selhagani closing this as expected, not a bug, and a new feature at the same time is not the right resolution if the entire premise of the issue is to point out that this is not documented anywhere.
Is it expected to be undocumented?
Is it a feature that this is undocumented?
I doubt it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants