注册 登录
编程论坛 VC++/MFC

小弟初学,还请各位指点,编译时main函数问题,

Only4Simky 发布于 2011-06-11 01:04, 647 次点击
程序代码:
#include <iostream.h>


const float PI = 3.1416;
float fCir_L(float);
float fCir_S(float);


main()
{
    float r,s,l;
    cout<<"r=";
    cin>>r;
    cout<<fCir_L(r);
    cout<<"\n";
    cout<<fCir_S(r);
}

float fCiir_L(float x)
{
    float z=-1.0;
    if (x>=0.0)
        z=2*x*PI;
    return z;
}

float fCir_S(float a)
{
    float z=-1.0;
    if (a>=0.0)
        z=a*a*PI;
    return z;
}



编译环境是Win 7 64bit
Visual Studio 2010

编译时候给的信息:

1>------ Build started: Project: nimei, Configuration: Debug Win32 ------
1>Build started 2011/6/11 0:13:27.
1>InitializeBuildStatus:
1>  Touching "Debug\nimei.unsuccessfulbuild".
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>c:\users\sirius4simky\documents\visual studio 2010\Projects\nimei\Debug\nimei.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.18
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Google 了一下,说是无法找到main函数,据说在Project Properties里面引用一个库?
没有找到具体的操作,
还有说在linker 里面添加main为入口点,也木有找到这个地方,
请问各位应该怎么解决?
3 回复
#2
yuccn2011-06-11 10:19
程序代码:
#include <iostream>
using namespace std;

const float PI = 3.1416;
float fCir_L(float);
float fCir_S(float);

void main()
{
    float r; //,s,l;
    cout<<"r=";
    cin>>r;
    cout<<fCir_L(r);
    cout<<"\n";
    cout<<fCir_S(r);
}

float fCir_L(float x)
{
    float z=-1.0;
    if (x>=0.0)
        z=2*x*PI;
    return z;
}

float fCir_S(float a)
{
    float z=-1.0;
    if (a>=0.0)
        z=a*a*PI;
    return z;
}
楼主的函数什么和定义不统一啊 float fCir_S(float);
,下面却是:
float fCiir_L(float x)
以后多细心点。^_^
#3
Only4Simky2011-06-11 16:11
回复 2楼 yuccn
感激不尽,
按楼上的源码,
添加了,
Using namespace std;

void main()

然后把
fCiir_L(float x)

修改为
fCir_L(float x)


可是错误依旧啊,

1>Build started 2011/6/11 16:05:33.
1>InitializeBuildStatus:
1>  Touching "Debug\nimei.unsuccessfulbuild".
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>c:\users\sirius4simky\documents\visual studio 2010\Projects\nimei\Debug\nimei.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.25
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


还是老错误,

麻烦您了,再帮我看看?
或者这个是编译器版本的问题么,
#4
Only4Simky2011-06-12 01:57
问题已解决,粗心了,cpp文件木有放到Source里面去,
1