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

Unable to compile to executable. #433

Closed
SrMordred opened this issue Apr 8, 2020 · 12 comments
Closed

Unable to compile to executable. #433

SrMordred opened this issue Apr 8, 2020 · 12 comments

Comments

@SrMordred
Copy link

Windows 10

terralib.includepath ="D:/msys64/mingw64/x86_64-w64-mingw32/include/";
C = terralib.includec("stdio.h")
terra hello()
    C.printf("Hello, Lua!")
end
terralib.saveobj("helloterra",{ main = hello })

terra main.t

llvm: program not executable

stack traceback:
	[C]: in function 'saveobj'
	C:\projects\terra\src\terralib.lua:4034: in function 'saveobj'
	main.t:6: in main chunk
@elliottslaughter
Copy link
Member

I'm hoping one of our Windows users can step in to help debug this, as I don't have a working Windows dev environment.

@SrMordred is this dependent on using printf? If you have a version that just does return 0 or something trivial, does that also fail?

@SrMordred
Copy link
Author

Yes, it also fail with just a do nothing function.

@SrMordred
Copy link
Author

It may be related to this:
#323 (comment)
I take a brief look at terralib.lua source and believe that it didnt find where my link.exe path is. (but i thought that it wasnt needed )
Also something i didn´t said before (because i was thinking that maybe was not related. ) when executing terra it give me a error related to not finding a registry path.
"ERRO: O sistema não pôde localizar a chave do Registro ou valor especificado." (in Portuguese).
If this was the case maybe there is a way to define myself the link.exe path ?

@elliottslaughter
Copy link
Member

elliottslaughter commented Apr 9, 2020

Are you running in the Visual Studio command prompt? If not can you try that? I believe Terra does require some environment variables that are set by that command prompt and otherwise certain things cannot be made to work. There was a lot of work that went into #411 to fix this, but I believe it still requires the Visual Studio command prompt since newer Visual Studio versions don't set the right (or any) registry keys.

@SrMordred
Copy link
Author

I tried to run with "vcvarsall.bat", but it didn´t work. Maybe is my env that is messed up.

@SrMordred
Copy link
Author

If i call
print(terralib.getvclinker("x64"))
i get C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\VC\BIN\x86_amd64\link.exe which is not a path that i have.( Nor do i ever installed vs12)

@ErikMcClure
Copy link
Contributor

This means the vclinker code isn't working properly, but it'll be very hard to figure out why it's broken. Can you try compiling something with clang and see if you still get a problem? If Clang can't find your visual studio linker, we won't be able to either, since our code is based on clang.

@SrMordred
Copy link
Author

Yes i can compile with clang properly.
Atm my solution is to generate the llvm bitcode and pass it to clang to generate the exe.

@ErikMcClure
Copy link
Contributor

Actually, the beta1 precompiled EXE was never updated by @elliottslaughter. Are you running the precompiled release? It won't have the necessary updates to work with visual studio at all - you have to compile from source.

@elliottslaughter
Copy link
Member

Just FYI, we made a new release, so this problem should hopefully go away if you try the new binaries: https://github.com/terralang/terra/releases/tag/release-1.0.0-beta2

@SrMordred
Copy link
Author

Yes, its working now, thanks!
(although it fails to link libc (printf), but that´s another issue :P )

@ErikMcClure
Copy link
Contributor

if you are having printf issues on windows, refer to this pull request which attempted to fix it before: #414

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

No branches or pull requests

3 participants