Tuesday, 30 June 2009

MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

Check following. ( with boost library )

one of the stupid thing you might have done is that you did not had a main function. (try compiling following code)

#include <boost\regex.hpp>
#include <iostream>
#include <string>

int main (int argc, char ** argv[])
    std::string line;
    boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );

    while (std::cin)
        std::getline(std::cin, line);
        boost::smatch matches;
        if (boost::regex_match(line, matches, pat))
            std::cout << matches[2] << std::endl;

    return 0;

1. you need to have the Configuration Properties > linker > system = Console

2. Linker > General  > additional libraries pointing to your libraries directory " the boost *.lib" ex. C:\Program Files\boost\boost_1_38\lib

3. C/C++ > General > Additional Included Directories "Points to the boost folder" ex.C:\Program Files\boost\boost_1_38\

- Mihir Patel

1 comment:

  1. Thank you very much! I made the very stupid mistake of having a Main function instead of a main function... It would have had me stumped for a very long time if I didn't find this page.