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

build_executable.jl windows support #9973

Closed
dhoegh opened this issue Jan 30, 2015 · 3 comments
Closed

build_executable.jl windows support #9973

dhoegh opened this issue Jan 30, 2015 · 3 comments
Labels
building Build system, or building Julia or its dependencies system:windows Affects only Windows

Comments

@dhoegh
Copy link
Contributor

dhoegh commented Jan 30, 2015

I am trying to build a standalone executable on windows and I'm running into some problems.
I have added gcc as stated in the script.

First of I ran into a problem with a missing string escape when windows paths is written to a userimg file in emit_userimgjl. It causes the userimg to contain an include("folder\folder\file.jl") with only single \. By inserting include("$(escape_string(script_file))") on line:

include(\"$(script_file)\")
the path to the script is correct on windows.

After overcoming this problem I get this error:

INFO: Linking sys.dll
INFO: System image successfully built at C:\Users\Hoegh\Julia-0.4.0-dev_19_1\bin\libeps_to_pdf.dll
WARNING: Building sys.dll on Windows against LLVM < 3.5.0 can cause incorrect backtraces! Delete generated sys.dll to avoid these
problems
INFO: To run Julia with this image loaded, run: julia -J C:\Users\Hoegh\Julia-0.4.0-dev_19_1\bin\libeps_to_pdf.ji

running: gcc -g -Wl,--no-as-needed -IC:\Users\Hoegh\Julia-0.4.0-dev_19_1\include\julia -IC:\Users\Hoegh\src -IC:\Users\Hoegh\src/
upport -IC:\Users\Hoegh\usr/include C:\Users\Hoegh\AppData\Local\Temp\jul9D3B.tmp\start_func.c -o C:\Users\Hoegh\Julia-0.4.0-dev_
9_1\bin\eps_to_pdf.exe -Wl,-rpath,C:\Users\Hoegh\Julia-0.4.0-dev_19_1\bin -LC:\Users\Hoegh\Julia-0.4.0-dev_19_1\bin -ljulia -leps
to_pdf
ERROR: LoadError: could not spawn `gcc -g -Wl,--no-as-needed '-IC:\Users\Hoegh\Julia-0.4.0-dev_19_1\include\julia' '-IC:\Users\Ho
gh\src' '-IC:\Users\Hoegh\src/support' '-IC:\Users\Hoegh\usr/include' 'C:\Users\Hoegh\AppData\Local\Temp\jul9D3B.tmp\start_func.c
 -o 'C:\Users\Hoegh\Julia-0.4.0-dev_19_1\bin\eps_to_pdf.exe' '-Wl,-rpath,C:\Users\Hoegh\Julia-0.4.0-dev_19_1\bin' '-LC:\Users\Hoe
h\Julia-0.4.0-dev_19_1\bin' -ljulia -leps_to_pdf`: no such file or directory (ENOENT)
 in _jl_spawn at process.jl:216 (repeats 2 times)
while loading C:\Users\Hoegh\Julia-0.4.0-dev_19_1\share\julia\build_executable.jl, in expression starting on line 247

When I run the command manually i get:

C:\Users\Hoegh\Julia-0.4.0-dev_19_1>gcc -g -Wl,--no-as-needed -IC:\Users\Hoegh\Julia-0.4.0-dev_19_
1\include\julia -IC:\Users\Hoegh\src -IC:\Users\Hoegh\src/support -IC:\Users\Hoegh\usr/include C:\
Users\Hoegh\AppData\Local\Temp\jul9D3B.tmp\start_func.c -o C:\Users\Hoegh\Julia-0.4.0-dev_19_1\bin
\eps_to_pdf.exe -Wl,-rpath,C:\Users\Hoegh\Julia-0.4.0-dev_19_1\bin -LC:\Users\Hoegh\Julia-0.4.0-de
v_19_1\bin -ljulia -leps_to_pdf
In file included from C:\Users\Hoegh\Julia-0.4.0-dev_19_1\include\julia/uv.h:59:0,
                 from C:\Users\Hoegh\Julia-0.4.0-dev_19_1\include\julia/ios.h:5,
                 from C:\Users\Hoegh\Julia-0.4.0-dev_19_1\include\julia/libsupport.h:12,
                 from C:\Users\Hoegh\Julia-0.4.0-dev_19_1\include\julia/julia.h:10,
                 from C:\Users\Hoegh\AppData\Local\Temp\jul9D3B.tmp\start_func.c:1:
C:\Users\Hoegh\Julia-0.4.0-dev_19_1\include\julia/uv-win.h:241:3: error: unknown type name 'SRWLOCK'

The file I try to compile looks like:

function main()
    println("test")
end

@few do you have any idea what's wrong?

@few
Copy link
Contributor

few commented Jan 30, 2015

The SRWLOCK error sounds like this: joyent/libuv#263
So try adding -D_WIN32_WINNT=0x0600 to the gcc command line.

@dhoegh
Copy link
Contributor Author

dhoegh commented Jan 30, 2015

@few, Awesome it worked, I will give it a more thorough test tomorrow. The things I have found that needs to be changed to get windows support is:

  • -D_WIN32_WINNT=0x0600 commandline argument to gcc
  • inserting include(\"$(escape_string(script_file))\") on line:
    include(\"$(script_file)\")
  • The reference to gcc should be as in
    winrpmgcc = joinpath(WinRPM.installdir,"usr","$(Sys.ARCH)-w64-mingw32",
    "sys-root","mingw","bin","gcc.exe")
    if success(`$winrpmgcc --version`)
    to get the one installed by WinRPM. I have used one that came prepackaged with Anaconda. Maybe you could use the whole find_system_linker from build_sysimg.jl to get the correct gcc on both windows and unix.

@vtjnash
Copy link
Member

vtjnash commented Jan 31, 2015

(presumably that should be -D_WINVER=0x0502 == Win XP SP2)

@ihnorton ihnorton added system:windows Affects only Windows building Build system, or building Julia or its dependencies labels Jan 31, 2015
dhoegh added a commit to dhoegh/julia that referenced this issue Jan 31, 2015
dhoegh added a commit to dhoegh/julia that referenced this issue Feb 1, 2015
dhoegh added a commit to dhoegh/julia that referenced this issue Feb 1, 2015
dhoegh added a commit to dhoegh/julia that referenced this issue Feb 1, 2015
dhoegh added a commit to dhoegh/julia that referenced this issue Feb 1, 2015
dhoegh added a commit to dhoegh/julia that referenced this issue Feb 1, 2015
tkelman added a commit that referenced this issue Feb 10, 2015
Fix windows support for `build_executable.jl`. fix #9973
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

4 participants