<分区>
我在 Windows 操作系统下使用 QT Creator 的简单程序中使用 SDL。但是当我构建代码时,遇到以下链接错误。
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
我通过代码发现 main()
在我的 .cpp
文件中无法识别,因为在 SDL_main 中引用了相同的关键字.h
,如下图:
#define main SDL_main
/** The prototype for the application's main() function */
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
当我单击 .cpp 文件中的主函数时,我跳转到 SDL_main.h 中的定义,它验证是否存在某种冲突。
所以,我猜链接器无法识别我的 .cpp 文件中的 main()。 这是我的代码:
#include <QtCore>
#include <opencv2/opencv.hpp>
#include "vlcvideocapture.h"
int main()
{
clsVlcVideoCapture videoCapture("ip.camera");
int key = 0;
while(key != 27) {
cv::Mat frame;
int frameNumber = videoCapture.grabFrame(frame);
if(frameNumber == -1)
continue;
cv::imshow("frame", frame);
key = cv::waitKey(30);
}
return 0;
}
这里发生了什么以及我如何以合理的方式解决这个问题。 任何帮助将不胜感激。
更新:
有些人说使用 #undef main
但是当我这样做时,会弹出以下错误,这是预期的:
cannot initialize SDL