| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2237 人关注过本帖
标题:新人求帮忙LIBCD.lib(crt0.obj) : error LNK2001: unresolved external sym ...
取消只看楼主 加入收藏
greenphoenix
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-11-14
收藏
 问题点数:0 回复次数:1 
新人求帮忙LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug
编译的时候老是出现错误提示,怎么找也不知道错在哪里,请高手帮忙指点
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/005.exe : fatal error LNK1120: 1 unresolved externals
下面是代码:
#include<stdio.h>
#include<windows.h>

LRESULT CALLBACK winlzy(
  HWND hwnd,      
  UINT uMsg,      
  WPARAM wParam,  
  LPARAM lParam   
);



int WINAPI WinMain(
  HINSTANCE hInstance,  
  HINSTANCE hPrevInstance,  
  LPSTR lpCmdLine,      
  int nCmdShow         
)
{
    WNDCLASS wndclass;
    wndclass.cbClsExtra=0;
    wndclass.cbWndExtra=0;
    wndclass.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
    wndclass.hCursor=LoadCursor(NULL,IDC_APPSTARTING);
    wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    wndclass.hInstance=hInstance;
    wndclass.lpfnWndProc=winlzy;
    wndclass.lpszClassName="lzy";
    wndclass.lpszMenuName=NULL;
    wndclass.style=CS_HREDRAW | CS_VREDRAW;
    RegisterClass(&wndclass);
   
    HWND hwnd;
    hwnd=CreateWindow("lzy","weixin",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
                       CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hInstance,NULL);
    ShowWindow(hwnd,SW_NORMAL);
    UpdateWindow(hwnd);
    MSG msg;
    while(GetMessage(&msg,hwnd,0,0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}

LRESULT CALLBACK winlzy(
    HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam
)
    {
        switch(uMsg)
        {
        case WM_PAINT:
            HDC hdc1;
            PAINTSTRUCT ps;
            hdc1=BeginPaint(hwnd,&ps);
            TextOut(hdc1,0,0,"好好学习",strlen("好好学习"));
            EndPaint(hwnd,&ps);
            break;
        case WM_CHAR:
            char szchar[20];
            sprintf(szchar,"char is %d",wParam);
            MessageBox(hwnd,szchar,"weixin",MB_OK);
            break;
        case WM_LBUTTONDOWN:
            MessageBox(hwnd,"mouse clicked","weixin",MB_OK);
            HDC hdc2;
            hdc2=GetDC(hwnd);
            TextOut(hdc2,0,50,"天天向上",strlen("天天向上"));
            ReleaseDC(hwnd,hdc2);
            break;
        case WM_CLOSE:
            if(IDYES==MessageBox(hwnd,"是否真的结束程序?","weixin",MB_YESNO))
            {
                DestroyWindow(hwnd);
            }
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hwnd,uMsg,wParam,lParam);
        }
        return 0;
    }
搜索更多相关主题的帖子: include 
2015-11-14 08:55
greenphoenix
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-11-14
收藏
得分:0 
自己网上百度了下,进入project->setting->Link, 在Project options中将 /subsystem:console改为/subsystem:windows.问题就解决了!
2015-11-16 08:56
快速回复:新人求帮忙LIBCD.lib(crt0.obj) : error LNK2001: unresolved externa ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016164 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved