VC调试常见错误一:error LNK2001: unresolved external symbol _WinMain@16

fatal error LNK1120: 1 unresolved externals Debug/11.exe : fatal error LNK1120: 1 unresolved externals解决办法: 这是调用动态库出现的问题,分两类。第一类是本工程的编译环境设置问题,另一类是库文件出问题。 libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Windows项目要使用Win... 阅读详情

一,问题描述
error LNK2001: unresolved external symbol _WinMain@16
debug/main.exe:fatal error LNK 1120:1 unresolved externals
error executing link.exe;

二,产生这个问题可能的原因
1.  你用vc建了一个控制台程序,它的入口函数应该是main, 而你使用了WinMain.

2,你用vc建了一个Win32程序,它的入口函数应该是WinMain, 而你使用了main

3.  你用vc打开了一个.c/.cpp 文件,然后直接编译这个文件,这个文件中使用了WinMian而不是main作为入口函数。vc这时的默认设置是针对控制台程序的。

三, 解决方法

1. 最省事的方法,如果建立的控制台程序,主函数用main();如果是Win32程序,主函数就要用WinMain

或者:
1.进入project->setting->c/c++, 在category中选择preprocessor,在processor definitions中删除_CONSOLE, 添加_WINDOWS

2.进入project->setting->Link, 在Project options中将 /subsystem:console改为/subsystem:windows.

3.保存设置,Rebuild All.

VS2005中的设置请参考对应项进行设置

四,VS2005中的设置
1.菜单中选择 Project->Properties, 弹出Property Pages窗口

2.在左边栏中依次选择:Configuration Properties->C/C++->Preprocessor,然后在右边栏的Preprocessor Definitions对应的项中删除_CONSOLE, 添加_WINDOWS.

3.在左边栏中依次选择:Configuration Properties->Linker->System,然后在右边栏的SubSystem对应的项改为Windows(/SUBSYSTEM:WINDOWS)

4.Rebuild All. Ok ?

说明:以上方法太过麻烦,不便于项目的转换,例如在编写小项目时,可能想在Windows和Console项目间来回转换。下面推荐一种更为简单的:

1.菜单中选择 Project->Properties, 弹出Property Pages窗口

2.在左边栏中依次选择:Configuration Properties->Linker->System,然后在右边栏的SubSystem对应的项改为未设置。

这种删除/SUBSYSTEM链接程序开关的做法很少有人注意到。这是因为链接器会根据源代码中的函数进行正确是操作,链接程序检查代码中存在4个函数(WinMain、wWinMain、main、wmain)中的哪一个,根据检查结果来确定可执行程序应该是哪一个子系统,并且确定可执行程序中应该嵌入哪个C/C++启动函数。

测试:(环境:vs2005,编程语言vc)
1.用文本编辑器编写如下代码:

view plaincopy to clipboardprint?
// test.c  
#i nclude <windows.h>  
 
int APIENTRY WinMain(HINSTANCE hInstance,  
                     HINSTANCE hPrevInstance,  
                     LPSTR     lpCmdLine,  
                     int       nCmdShow)  
{  
 MessageBox(NULL, "Hello!", "title", MB_OK);  
} 
// test.c
#i nclude <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 MessageBox(NULL, "Hello!", "title", MB_OK);
}

 

假设把文件包存为test.c.

2.用vs2005建一个Win32 Console Application, 注意在Application Settings设置为Empty project. 然后把test.c添加到工程中去。

3.vs2005建立的工程默认是支持UNICODE的,我不用这个,所以在菜单中选择 Project->Properties, 弹出Property Pages窗口。在左边栏中依次选择:Configuration Properties->General,然后把右边栏的Character Set 改为Use Multi-Byte Character Set.

4.编译,出现如下错误:
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
C:/test/Debug/test.exe : fatal error LNK1120: 1 unresolved externals

5.按照上述VS2005中的设置方法进行设置,然后再编译,错误消失了吧!

解决error LNK2001: unresolved external symbol 立即下载

相关推荐

关于VC6.0中 运行错误 unresolved external symbol _WinMain@16的解决

关于VC6.0中 运行错误 unresolved external symbol _WinMain@16的解决

unresolved external symbol _WinMain@16的解决方法

unresolved external symbol _WinMain@16的解决方法(转) 当我们在使用VC开发C++的时候会遇到一些连接错误,这些错误比编译错误要难改正,笔者今天就遇到这样一个错误 1.问题描叙: error LNK2001: unresolved external symbol _WinMain@16 debug/main.exe:fatal e

Simael的专栏 9140

大麦网抢票协议逆向分析:从Web安全到高并发风控实战

在当今高并发Web应用场景下,理解网络协议交互与反爬虫机制是后端开发和系统架构设计的核心技能。其基本原理涉及客户端与服务器之间通过HTTP/HTTPS协议进行数据交换,关键环节包括请求参数构造、身份认证与会话管理。这一技术的核心价值在于保障系统安全与公平性,通过动态令牌、签名算法及设备指纹等多重手段,有效抵御自动化脚本攻击。典型应用场景包括票务系统、电商秒杀等需要严格管控资源访问的高并发业务。本文以热门票务平台为例,深入剖析其**请求链与令牌体系**及**行为生物特征分析**等风控策略,通过实战演示协议逆向

weixin_34354173的博客 451

error LNK2001: unresolved external symbol _WinMain@16

一,问题描述 error LNK2001: unresolved external symbol _WinMain@16 debug/main.exe:fatal error LNK 1120:1 unresolved externals error executing link.exe; 二,产生这个问题可能的原因 1、 你用vc建了一个控制台程序,它的入口函数应该是main, 而你使用了Win...

FakeProgrammers_tf的博客 794

新手必看:如何用R/qtl快速完成QTL定位分析(附实战代码)

本文为新手提供了使用R/qtl进行QTL定位分析的完整实战指南。内容涵盖从环境搭建、数据准备与清洗,到核心分析流程(包括遗传图谱计算、单QTL扫描、置换检验确定阈值)以及进阶结果可视化的全步骤。通过清晰的代码示例,帮助读者快速掌握这一数量遗传学关键分析技术,实现从数据到QTL峰值的完整分析闭环。

y7z8a的博客 498

Day470&471.Netty概述&Netty高性能架构设计 -netty

Netty概述 一、原生 NIO 存在的问题 NIO 的类库和 API 繁杂,使用麻烦:需要熟练掌握 Selector、ServerSocketChannel、SocketChannel、ByteBuffer等。 需要具备其他的额外技能:要熟悉 Java 多线程编程,因为 NIO 编程涉及到 Reactor 模式,你必须对多线程和网络编程非常熟悉,才能编写出高质量的 NIO 程序。 开发工作量和难度都非常大:例如客户端面临断连重连、网络闪断、半包读写、失败缓存、网络拥塞和异常流的处理等等。 JDK NIO

阿昌爱Java 1571

vc中error LNK2001:unresolved external symbol _WinMain@16的解决方法

转载:一问题描述:error LNK2001: unresolved external symbol _WinMain@16debug/main.exe:fatal error LNK 1120:1 unresolved externals error executing link.exe;二产生这个问题可能的原因:1, 你用vc建了一个控制台程序,它的入口函数应该是main, 而

xiaoGang的专栏 2184

个人信息保护合规审计人员(中级)能力测试试卷

本文是关于个人信息保护合规审计的考试指南,包含选择题、判断题、简答题和案例分析题。选择题考察《个人信息保护法》的关键条款,如敏感信息处理、跨境传输、委托处理等合规要求。判断题测试对个人信息处理规则的理解,如撤回同意、公开信息处理等。简答题要求阐述审计流程、个人权利、委托处理义务等内容。案例分析题以互联网企业为例,分析违规行为并提出整改建议,涉及数据收集、第三方共享、自动化决策等问题。全文旨在帮助中级审计人员掌握个人信息保护的法律规定和审计实务,提升合规审计能力。

qq_41525079的博客 547

VC++连接错误2001 error LNK2001: unresolved external symbol _WinMain@16

VC++链接错误: error LNK2001: unresolved external symbol _WinMain@16(转)2009-09-16 10:39学习VC++时经常会遇到链接错误LNK2001,该错误非常讨厌,因为对于编程者来说,最好改的错误莫过于编译错误,而一般说来发生连接错误时,编译都已通过。产生连接错误的原因非常多,尤其LNK2001错误,常常使人不明其所以然。如果不深入地

学习随笔 933

2025反爬终极方案:Python破解Cloudflare v2行为指纹,设备伪装+轨迹模拟拦截率压至1%

Cloudflare v2的反爬逻辑越来越接近“人类行为识别”,单纯的技术破解已失效,核心竞争力变成“模拟真实用户的能力”。本文的终极方案本质是“全方位复刻人类行为”——从设备指纹到操作轨迹,从网络特征到交互模式,让爬虫成为“无法被区分的真实用户”。这套方案的优势是“通用性强”,不仅适用于Cloudflare v2,也能破解大多数高反爬网站(如小红书、知乎、跨境电商)的行为检测;且代码可直接复用,新手只需替换目标URL和数据提取逻辑,就能快速落地。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2353

分立器件---电感介绍(7000字)

电感基础整理

HW-BASE的博客 2350

c语言错误发LNK2001,c语言调试时出现的错误及调整方法

c语言调试时出现的错误及调整方法 VC 中 LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 错误 2009-10-09 11:11学习 VC++时经常会遇到链接错误 LNK2001,而一般说来发生连接错误时,编译都已通过。产生连接错误的原因非常多,尤其 LNK2001 错误,常常使人不明其...

weixin_42455621的博客 922

基于Gossip算法的柔性互联自治微网群分布式协调控制策略:复现代码与详细解释

摘要(149字): 本文基于Gossip算法实现了柔性互联微网群(MMG)的分布式协调控制策略仿真。研究构建了包含3个微网、10个分布式电源(DG)的MATLAB/Simulink模型,采用双层控制架构:上层通过柔性交流开关(FAS)实现微网间功率协调,下层利用Gossip算法完成DG间的边际成本一致性控制。重点开发了异步通信的Gossip算法核心函数,实现了分布式电源的自主边际成本估计与功率分配。仿真验证了系统在负荷变化和DG故障等工况下的协调控制能力,结果表明该策略能有效维持微网群的经济运行与功率平衡。

huanghm88的专栏 281

c语言错误发LNK2001,C语言调试时出现的错误及调整方法

VC中LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16错误2009-10-09 11:11学习VC++时经常会遇到链接错误LNK2001,而一般说来发生连接错误时,编译都已通过。产生连接错误的原因非常多,尤其LNK2001错误,常常使人不明其所以然。产生LNK2001错误的原因:一个是由于编...

weixin_28694295的博客 960

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

VC6.0 error LNK2001: unresolved external symbol _main解决办法

转自 圣诞老人小帮手  VC6.0 error LNK2001: unresolved external symbol _main解决办法 学习VC++时经常会遇到链接错误LNK2001,该错误非常讨厌,因为对于编程者来说,最好改的错误莫过于编译错误,而一般说来发生连接错误时,编译都已通过。产生连接错误的原因非常多,尤其LNK2001错误,常常使人不明其所以然。如果不深

fleih的博客 668

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

VC错误 LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

原因:新建工程的时候选项选错,应该是Win32 Console Application控制台程序 解决办法:在菜单栏中找到 Project->Setting(设置)->Link (连接),在Project Option(工程选项)框里找到/subsystem:windows 双击之后修改成/subsystem:console ...

xixiaodou的博客 629

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

VC6.0在Windows 11上完整可用的路径信任重建指南

Visual C++ 6.0作为经典的32位原生开发工具,其核心能力并非源于现代IDE特性,而是基于静态链接、硬编码路径与注册表驱动的轻量级编译链。理解其依赖的临时目录、注册表键和LIB/INCLUDE路径三要素,是实现跨系统兼容的关键。VC6.0自带CL.EXE、LINK.EXE等完整工具链,所谓‘无法编译’多因环境变量未生效或注册表重定向错位所致。该方案不依赖补丁或降级系统,适用于嵌入式固件维护、工业PLC源码复现及DOS/Win9x引擎逆向等需真实二进制输出的工程场景,本质是重建一套VC6.0可信任的

weixin_27743991的博客 271

编译错误,如何解决error LNK2001: unresolved external symbol

导致“errorLNK2001: unresolved external symbol”的原因为getStats此方法的链接库来没有找到。很可能是工程中引用了第三方开源库或者自己编译生成的库,且只用了头文件,而没有将对应的lib文件路径加入到工程中。 具体解决方源法为(此方法针对vs系列集成开发环境): 1.如果还未引入头文件,那么可以右键点击2113项目,然后点击“属性”。 2.点击“C/C++”,选择5261“常规”,然后在右侧的“附加包含目录”选择你的第三4102方库(或者自己编译生成库).

neufeifatonju的博客 1万+

VS2005"unresolved external symbol..."错误分析

一,问题描述error LNK2001: unresolved external symbol _WinMain@16debug/main.exe:fatal error LNK 1120:1 unresolved externals error executing link.exe;二,产生这个问题可能的原因1, 你用vc建了一个控制台程序,它的入口函数应该是main, 而你

世事难料,保持低调 3600
上一篇: /bin/sh^M: bad interpreter: No such file or directory
下一篇: Linux内核发展回顾--软件世界 邹震
骑行的蜗牛
博客等级 码龄21年 107粉丝 86原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值