I'm using SDL in a simple program with QT Creator under windows operating system. But When I build the code, I encounter the following linkage error.
MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
I got through the code and found that the main()
is not recognized in my .cpp
file, since the same keyword has been referenced in SDL_main.h
, as shown below:
#define main SDL_main
/** The prototype for the application's main() function */
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
When I click on the main function in my .cpp file, I jump to the definition in SDL_main.h which verifies that there is a kinda conflict.
So, I guess the linker does not recognize the main() in my .cpp file. Here is my code:
#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;
}
What's going on here and How I can fix this issue in a justifiable manner. Any help would be appreciated.
Update:
Some guys say to use #undef main
but when I do so, the following error pops up which is expected:
cannot initialize SDL