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

Embedding Julia in a Windows application without console #28820

Closed
GunnarFarneback opened this issue Aug 22, 2018 · 2 comments · Fixed by #29374
Closed

Embedding Julia in a Windows application without console #28820

GunnarFarneback opened this issue Aug 22, 2018 · 2 comments · Fixed by #29374
Labels
embedding Embedding Julia using the C API regression Regression in behavior compared to a previous version

Comments

@GunnarFarneback
Copy link
Contributor

GunnarFarneback commented Aug 22, 2018

If you call jl_init() from a Windows application without a console, Julia 0.7 and 1.0 will abort the application after trying and failing to duplicate an invalid stdio handle. Julia 0.6 was less strict (and possibly less correct) about this but at least the apparent result was that things worked and stdout/stderr output just disappeared.

This doesn't seem like an unreasonable use case for embedding and jl_init should handle it gracefully. If it can't easily be fixed it should at least be documented.

The easiest workaround I have found is to call AllocConsole() before jl_init(), with the predictable drawback that you get a window that you might not want. As a workaround for the workaround you can hide the console window with ShowWindow(GetConsoleWindow(), SW_HIDE), but not without a brief flickering between creation and hiding.

For more details, see https://discourse.julialang.org/t/embedding-jl-init-exits-on-windows-for-julia-0-7/13819

@JeffBezanson JeffBezanson added the embedding Embedding Julia using the C API label Sep 5, 2018
@jaakkor2
Copy link
Contributor

I am seeing on Windows 7 (on a bit different context)
error initializing stdin in uv_dup: Unknown system error 6 (Unknown system error 6 6)
in Julia v1.0.0, whereas Julia v0.6-series worked fine.

If stdin is not available, Julia should not stop.

@jaakkor2
Copy link
Contributor

If I replace this line
https://github.com/JuliaLang/julia/blob/v1.0.0/src/init.c#L375
with ;, the problem is gone for me.

Correctness of this solution is unclear to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedding Embedding Julia using the C API regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants