vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.78k stars 2.16k forks source link

Windows Compilation Instructions #413

Closed joe-conigliaro closed 5 years ago

joe-conigliaro commented 5 years ago

Edited. The instructions that were here are no longer current. Instructions can now be found https://github.com/vlang

SongTianZuo commented 5 years ago

function string os__home_dir()

`string os__home_dir() {

string home = os__getenv(tos2("HOME"));

ifdef windows

//home = os__getenv(tos2("HOMEDRIVE"));

//home = string_add(home, os__getenv(tos2("HOMEPATH")));

int max = 256;

byte *buf = v_malloc(max);

GetModuleFileName(NULL, buf, max);

int nLen=strlen(buf);

byte p; p= buf+nLen; while(p!=buf) { if((p == '\') || (p == '//')) { p='\x00'; break; } p--; } nLen=strlen(buf); home = tos(buf, nLen); home = string_add(home, tos2("/../../../"));

endif

;

home = string_add(home, tos2("/"));

return home; }`

joe-conigliaro commented 5 years ago

@SongTianZuo whats this for, were you having other problem with os__home_dir?

SongTianZuo commented 5 years ago

chage the string os__home_dir funtion , make it works in Flexible Path 'anywhere'/code/v , not need in %home%/code/v

joe-conigliaro commented 5 years ago

chage the string os__home_dir funtion , make it works in Flexible Path 'anywhere'/code/v , not need in %home%/code/v

Ahh yes

medvednikov commented 5 years ago

Thanks.

I finally got access to a Windows machine, I'll make it work.

Windows line endings are now supported, by the way.

joe-conigliaro commented 5 years ago

@medvednikov cool thanks! just need to do something about getline() and backtrace() (maybe CaptureStackBackTrace() on win?)

nachoverdon commented 5 years ago

Mind sharing the binary?

ntrel commented 5 years ago

Thanks, but I still get errors:

./vc -o v .
(char code=0) pos=4594 len=4821
panic: array.v:228
invalid character ``
exit():

This error points to the end of the file, which is a \0 char. I have windows line endings as Alex said they work now. I also tried fixing this myself before seeing this pull, and even editing v.c to ignore the \0 I get other runtime panics.

joe-conigliaro commented 5 years ago

@ntrel actually that's still line ending error because for me it fixed that. EDITED

joe-conigliaro commented 5 years ago

@medvednikov My last post that was about printf isn't relevant any more, I woke up and now it's working again ( i dunno if i was half asleep or tripping) but I didn't even do a pull from the repo so i dunno what the hell is going on lol.

@nachoverdon I guess if you really want, I don't like the idea of distributing binaries though

liov commented 5 years ago

I get the vc.exe,but i can't compile any .v file

joe-conigliaro commented 5 years ago

I get the vc.exe,but i can't compile any .v file

Any errors?

liov commented 5 years ago

Any errors? no error,but i can‘t get binary file

joe-conigliaro commented 5 years ago

@liov if you run vc.exe does it do anything?

liov commented 5 years ago

@liov if you run vc.exe does it do anything?

I think it's compiled, but there's no output

joe-conigliaro commented 5 years ago

@liov hrm If i think what it could be i'll let you know, there are also other issues with windows at the moment, I'm trying to work some out. Maybe stick wish WSL for now

joe-conigliaro commented 5 years ago

@medvednikov what do you think is happening here? vtov

kunjiang commented 5 years ago

Thanks, but I still get errors:

./vc -o v .
(char code=0) pos=4594 len=4821
panic: array.v:228
invalid character ``
exit():

This error points to the end of the file, which is a \0 char. I have windows line endings as Alex said they work now. I also tried fixing this myself before seeing this pull, and even editing v.c to ignore the \0 I get other runtime panics.

I have the same error, but replace all characters: \r\n to \n, then compile it ok, but build nothing, it will not generate v file. I use MinGW, gcc to compile.

Snipaste_2019-06-25_00-21-38

and

Snipaste_2019-06-25_00-24-21

Hades32 commented 5 years ago

So, to make it most reproducable I tried to do this inside docker and then wanted to cross-compile to compiler to windows from linux, BUT this is what I get on MASTER and on 0.1.16:

root@5cbe9bf96f09:/etc/vlang# v -o v.exe -os windows compiler                                                                                       Cross compiling for Windows...
clang: error: no such file or directory: '/root//.vmodules//v.exe.c'
clang: error: no input files                                                                                                                        Cross compilation for Windows failed. Make sure you have clang installed.

For some reason it is searching for the intermediate C file in the modules folder...

When I just copy the file there, I get this:

root@5cbe9bf96f09:/etc/vlang# v -o v.exe -os windows compiler                                                                                       Cross compiling for Windows...
/root//.vmodules//v.exe.c:15:10: fatal error: 'windows.h' file not found
#include <windows.h>
         ^~~~~~~~~~~                                                                                                                                1 error generated.
Cross compilation for Windows failed. Make sure you have clang installed.

I did install the winroot.zip from v0.1.10, BUT this really doesn't container the windows.h file... So, no idea how this even is supposed to work.

I think the best would be if this project had some CI for building the releases - let me know if you need support there.

medvednikov commented 5 years ago

All Windows issues were fixed.