Reputation: 1260
I am compiling several C++ sources using cl.exe
(Visual Studio 2010 Express). The sources are compiling fine and it generates the respective obj
files, but after the last line of "Generating code..." it throws the infamous LNK1104
error, but of the weirdest kind I have ever seen:
Generating Code...
LINK : fatal error LNK1104: cannot open file 'Color.exe'
Now, Color.exe
does not exist, I do not want it to exist, I am not telling cl to create it, neither do I even tell it to link at all, I only want to compile. Color.obj
happens to be the first output file of the compiler (alphabetical order), so I assume this problem is kinda linked to it.
The command line of my cl.exe
invocation looks like follows (I trimmed the includes, they aren't part of the problem):
cl /nologo /Ox /EHsc /I[...] "D:\Projects\Java\JSFML\src\cpp\Intercom\*.cpp" "D:\Projects\Java\JSFML\src\cpp\JNI\*.cpp" /FoD:\Projects\Java\JSFML\out\obj\
The working directory is the MS Visual Studio directory. I assume that it cannot "open" Color.exe
because it cannot write in that directory. However, my question is: why would cl
even want to create it? I'm not telling it to link?
Upvotes: 0
Views: 1703
Reputation: 181047
The default of most (if not all) C/C++ compilers is to perform the linking step unless you explicitly tell them not to.
If you take a look at this page which covers "cl.exe", you'll find an option, /c
(compile only, no link) that will turn that behavior off for you.
Upvotes: 2
Reputation: 283793
You are telling it to link. If you don't want to link, use the /c
option (for compile-only).
Upvotes: 2