Simple code refuses to compile ...

Hello,

I have installed LLVM-3.8.0-r243265-win64 for my Windows 7 Professional 64-bit and tried to compile a simple program called "test.c" (below);

int main(void) {
     return 0;
}

The command issued to compile it was; "clang.exe .\test.c" (without quotes).
The error message(s) thrown back are;
clang.exe: error: unable to execute command: program not executable
clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)

May I please know what I could do to get this resolved and working on my system?

Thanks,

~Mayuresh

+new list

Hi Kim,

Hi Mayuresh,

I have installed LLVM-3.8.0-r243265-win64 for my Windows 7 Professional
64-bit and tried to compile a simple program called "test.c" (below);

int main(void) {
    return 0;
}

The command issued to compile it was; "clang.exe .\test.c" (without quotes).
The error message(s) thrown back are;
clang.exe: error: unable to execute command: program not executable
clang.exe: error: linker command failed with exit code 1 (use -v to see
invocation)

Assuming you're not using MinGW/Cygwin, the Clang driver is looking
for Visual Studio's linker, LINK.EXE to generate an executable for the
program.

Do you have Visual Studio installed? Which version? Have you tried
`-v` as suggested to see what Clang is trying to do?

No, I am not using MinGW/Cygwin, neither do I have Visual Studio installed.
I tried the '-v' to see what happens (as suggested), and it threw back a whole lot of information which I could not understand.

Is there any way to install "only" LINK.EXE?
If yes, any particular place where I could look for the installable? MSDN!

~Mayuresh

No, I don't think Microsoft ship their linker separately.

Your best bet is probably to install Visual C++ Express.

You might be able to copy over isolated files from the install
directory (LINK.EXE and all its DLL dependencies), but that's not
likely to work very well.

- Kim

Okay, did some hunting and reading, looks like Microsoft has something called "Microsoft SDK for Windows 7".
That contains the linker and a bunch of other tools.

Thanks for that tip about Visual C++ Express, it showed me what else could be possible. :slight_smile:

Best,

~Mayuresh

Cool. I hope it works, I'm not sure how Clang searches for the tools,
but you can probably figure that out from the source code at:
http://clang.llvm.org/doxygen/Tools_8cpp_source.html#l08770

- Kim

Alright, it worked! but only partially, i.e. link.exe when executed from within the "Windows SDK 7.1 Command Prompt" works just fine, but not from any other console, not even after adding in the path to the SDK to the environment variable.
And, for the life of me, I just can't find "LINK.EXE" anywhere on the system, but, open up the "Windows SDK 7.1 Command Prompt" and execute it, and bam, it just works.

So, I tried running "clang.exe" from within the "Windows SDK 7.1 Command Prompt" but it gave the same old error message (below);
clang.exe: error: unable to execute command: program not executable
clang.exe: error: linker command failed with exit code 1 (use -v to see invocation)

After all this, I am quite tempted to be patient till the moment I get to return to my preferred system, i.e. FreeBSD. :slight_smile:

~Mayuresh

Hi,