How to create an executable C file for Windows -
i know question has been asked several times , took @ many of them like
unfortunately, none of them worked me.
my situation
i've installed ubuntu , windows on notebook.
- let's developed simple
"hello,world!"
program using text editor in c. - in ubuntu, i've compiled using gcc
$ gcc -o hello.out -g -wall -pedantic hello.c
- i executed
'./output.out'
- and got result
hello, world!
what tried
so kind of cross-developed here. switched windows , kept going.
now, try make executable file in order run on windows. know windows can't handle '$ ./output.out'
, alright, let's make executable then.
under windows, i've
- installed cygwin
- in cygwin, compiled using gcc
$ gcc -o hello.exe -g -wall -pedantic hello.c
note: wrote hello.exe instead of hello.out or hello.c
- in cygwin, executed
'$ ./output.exe'
- and got result
hello, world!
note: @ point, works shell under windows because installed cygwin , set path etc. means can open command line, go directory in 'hello.exe'
located , execute typing '> hello.exe'
i thought it, took hello.exe'
, moved notebook (not local machine). tried execute didn't work.
at first, got cygwin1.dll missing message. after fixing it, error appears.
what i'm trying accomplish
to make long story short: reason wrote want give detailed of situation.
basically, i'm trying create executable c file, windows user execute without having development tools.
in eclipse , java, export program making runnable -jar file. user has install latest java se version running.
additionally, tried compile program in visual studio didn't work either.
any suggestions? lot!
cygwin gcc produce executable linked cygwin1.dll. not usable without that.
gcc hello.c -o hello-cygwin.exe $ ldd hello-cygwin.exe ntdll.dll => /cygdrive/c/windows/system32/ntdll.dll (0x77bd0000) kernel32.dll => /cygdrive/c/windows/system32/kernel32.dll (0x77ab0000) kernelbase.dll => /cygdrive/c/windows/system32/kernelbase.dll (0x7fefdc60000) sysfer.dll => /cygdrive/c/windows/system32/sysfer.dll (0x75650000) cygwin1.dll => /usr/bin/cygwin1.dll (0x180040000)
if need standalone program, solution use mingw compiler (it available on cygwin cross compiler windows)
$ x86_64-w64-mingw32-gcc.exe hello.c -o hello-mingw64.exe $ ldd hello-mingw64.exe ntdll.dll => /cygdrive/c/windows/system32/ntdll.dll (0x77bd0000) kernel32.dll => /cygdrive/c/windows/system32/kernel32.dll (0x77ab0000) kernelbase.dll => /cygdrive/c/windows/system32/kernelbase.dll (0x7fefdc60000) sysfer.dll => /cygdrive/c/windows/system32/sysfer.dll (0x75650000) msvcrt.dll => /cygdrive/c/windows/system32/msvcrt.dll (0x7fefdf40000)
you can move resulting program on windows machine don't have cygwin installed.
Comments
Post a Comment