未定义对`WinMain @ 16的引用 [英] undefined reference to `WinMain@16

查看:112
本文介绍了未定义对`WinMain @ 16的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将openCV安装到Eclipse C ++.我安装了Opencv并添加了路径和lib文件,但得到了

  ****重建配置调试以进行项目测试********内部生成器用于构建****g ++ -IC:\ opencv \ build \ include -O0 -g3 -Wall -c -fmessage-length = 0 -osrc \ main.o .. \ src \ main.cppg ++ -LC:\ opencv \ build \ x86 \ vc10 \ lib -LC:\ opencv \ build \ x86 \ vc11 \ lib -otest.exe src \ main.o -lopencv_core247 -lopencv_core247d -lopencv_highgui247 -lopencv_highgui247d -lopencv_imgproc247 -lopencv_imgprocdC:/MinGW/i686-pc-mingw32/lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c :(.text + 0x3c):对WinMain @ 16的未定义引用collect2.exe:错误:ld返回1退出状态发生构建错误,构建已停止 

我知道之前曾有人问过这个问题,但是在每个问题中答案都是忘记包括main()函数".但是我有一个main()函数,但仍然出现此错误.

您知道我该怎么办吗?

解决方案

链接器可能默认情况下使用"Windows"子系统,这意味着主入口点不是您期望的"main"符号,而是"WinMain".

您可以通过在g ++命令行中传递以下参数来指定应用程序的子系统:

-Wl,-subsystem,console

(仅供参考,对于"Windows"子系统,您将使用 -Wl,-subsystem,windows )

您还可以在我相信的链接器配置中的Eclipse项目设置中对此进行设置.

顾名思义,基本上控制台"将创建一个基于控制台的应用程序,其默认入口点为main函数,另一个将创建一个Windows GUI应用程序,其默认入口点为WinMain函数./p>

请尝试一下:)

I'm trying to install openCV to Eclipse C++. I installed Opencv and aded the paths and lib files but I get

**** Rebuild of configuration Debug for project test ****

**** Internal Builder is used for build               ****
g++ -IC:\opencv\build\include -O0 -g3 -Wall -c -fmessage-length=0 -osrc\main.o    ..\src\main.cpp
g++ -LC:\opencv\build\x86\vc10\lib -LC:\opencv\build\x86\vc11\lib -otest.exe src\main.o -lopencv_core247 -lopencv_core247d -lopencv_highgui247 -lopencv_highgui247d -lopencv_imgproc247 -lopencv_imgproc247d
C:/MinGW/i686-pc-mingw32/lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text+0x3c): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
Build error occurred, build is stopped

I know this question has been asked before but in every one of them the answer was "forgetting to include main() function". But I have a main() function and I still get this error.

Do you have any idea what should I do?

解决方案

The linker probably is defaulted to use the "Windows" subsystem, which means that the main entry point is not the "main" symbol as you expect it to be, but rather "WinMain".

You can specify the subsystem of your application by passing the following argument at your g++ command line:

-Wl,-subsystem,console

(FYI, for the "Windows" subsystem, you'd use -Wl,-subsystem,windows)

You can also set this in the Eclipse project settings in the linker configuration somwhere I believe.

Basically "console", as the name suggests, creates a console-based application whose default entry-point is the main-function, the other will create a Windows GUI application whose default entry-point is the WinMain-function.

Please give it a try :)

这篇关于未定义对`WinMain @ 16的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆