Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7967099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:36:33+00:00 2026-06-04T06:36:33+00:00

I have been getting this error: ‘unresolved external symbol main referenced in function _

  • 0

I have been getting this error: ‘unresolved external symbol main referenced in function __tmainCRTStartup’ when I attempt to compile my c++ console application. I have done some searching and all I could find was changing my ‘linker’ from windows to console or vice versa. This didn’t work, I even tried creating a new console application.

I am unsure as to what is causing this, is it possible that template <typename T> is causing confusion as it appears in both files? Any help here would be much appreciated.

Code Below:

Main.cpp:

#include <iostream>
#include "tools.h"
using namespace tools;

template <typename T>
int main()
{
T input1;
T input2;

std::cout << "Enter in 1st number: " << endl;
std::cin >> input1;
std::cout << "Enter in 2nd number: " << endl;
std::cin >> input2;
std::cout << "num1 - num2 = [" << numberDifference(input1, input2) << "]" << endl;
getchar();
getchar();

return 0;
}

Tools.h:

#include <iostream>
namespace tools
{
template <typename T>
T numberDifference(T num1, T num2)
{
    if(num1 > num2)
        return num1 - num2;
    else
        return num2 - num1;
}
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:36:34+00:00Added an answer on June 4, 2026 at 6:36 am

    Remove the template definition for your main function.

    Or at least call it from a proper main function.

    e.g.

    template< typename T >
    int templated_main( int c, char** argv )
    {
        // What was in your original main function....
    
    }
    
    int main( int c, char** argv )
    {
        return templated_main<int>( c, argv );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we've been getting this error lately and have no idea why, we are not
I have been getting this error message when I step into some methods Do
I have been getting this error every since importing my existing project into a
I have been getting this error when trying to parse HTML with a script
I have been getting this annoying error/bug in Visual Studio 2008 quite a bit
I have been getting this error for quite some time now and Google has
I have been getting this error and have no idea how to fix it.
I have been getting this error in Ruby 1.9, Rails 3.0, ActiveRecord 3.0: incompatible
I keep getting this error and i have been trying everything for about a
Thus far you guys have been wildly helpful with me getting this little ditty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.