Why Isn't My C Code Being Compiled To An EXE

2019-07-31 14:15发布

I'm just starting out writing trying to write a simple program in C and I am using Visual Studios to do so. I heard that it does compile C as well as C++. And I know that it does because it says it compiles. The only problem is that when I go to the output directory, there isn't a .exe file in the directory! It has the following:

  • BuildLog.html
  • mt.dep
  • test1.obj
  • vc90.idb
  • vc90.pdb

But that is all! No EXE. I've looked through all the options and made sure that it is set to compile to an exe and i checked the output file. That is $(OutDir)\$(ProjectName).exe. But alas, no exe appears. Any ideas?

Also when i try to hit f5 and run with debut i get an error that says

This application has failed to start because MSVCR90.DLL was not found. Re-installing the application may fix this problem

5条回答
贪生不怕死
2楼-- · 2019-07-31 14:52

The simplest thing to do is just start over, making sure you choose the right kind of project.

To compile plain old C code with Visual Studio, choose Visual C++ > General > Empty Project from the New Project menu. This creates 3 empty folders: Header Files, Resource Files, and Source Files. Right click on Source Files, choose Add > New Item. Then add a main.cpp, rename it to main.c, and start coding.

查看更多
Luminary・发光体
3楼-- · 2019-07-31 15:10

is it a C/C++ console application? did you use the project wizard to create it?

do you have a function like

#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
    printf("Hello, world!\n");
    return 0;
}

in a .c module, typically main.c?

what happens when you hit F5 to run-with-debug? what does your build log look like?

查看更多
beautiful°
4楼-- · 2019-07-31 15:13

By default when you're creating a new C++ project within a new solution, you're getting folder structure like this:

C:\Projects\YourSolution C:\Projects\YourSolution\YourCppProject

YourSolution contains YourSolution.sln and YourCppProject contains YourCppProject.vcproj.

When you build the solution, all intermediate files from YourCppProject are getting stored under YourCppProject\Debug or YourCppProject\Release, but resulting YourCppProject.exe goes under YourSolution\Debug or YourSolution\Release.

Your $(OutDir) is configured by General -> Output Directory. Check project configuration for YourCppProject and see that it uses $(SolutionDir) for the output.

查看更多
倾城 Initia
5楼-- · 2019-07-31 15:15

Sounds like you only hit compile, that will give you you're .obj file, but you still need to click build.

查看更多
女痞
6楼-- · 2019-07-31 15:17

http://msdn.microsoft.com/en-us/library/ms235299.aspx

Note:

It is not supported to redistribute C/C++ applications that are built without a manifest. Visual C++ libraries cannot be used by C/C++ applications without a manifest binding the application to these libraries. For more information, see Choosing a Deployment Method.

If the DLL is not reachable and Windows cannot load this DLL for your application, you may get the following error message:

This application has failed to start because MSVCR90.dll was not found. Re-installing the application may fix this problem.

To resolve these errors, you must make sure that your application is built correctly and Visual C++ libraries are correctly deployed on the target system. To identify the root cause of these run-time errors, follow the steps outlined in Troubleshooting C/C++ Isolated Applications and Side-by-side Assemblies.

HTH

查看更多
登录 后发表回答