[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Link Error

Posted on 2004-04-04
8
Medium Priority
?
357 Views
Last Modified: 2012-05-04
Hi,

I am getting the following link errors:

Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Project2.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Any ideas on this?

Ryan

0
Comment
Question by:RySk8er30
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 10753233
With the vast information you have given about the project type, all that remains is pointing you to http://support.microsoft.com/default.aspx?scid=kb;en-us;125750 ("PRB: Error LNK2001: '_WinMain@16': Unresolved External Symbol")
0
 

Author Comment

by:RySk8er30
ID: 10753322
I'm still confused.
0
 
LVL 86

Expert Comment

by:jkr
ID: 10753402
Me too. And, even worse, my crystal ball is on repair.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:RySk8er30
ID: 10753414
I have a couple of files...here they are...

Bank.cpp

#include <conio.h> //Used for getche();
#include <windows.h> //Used for system("cls");
#include <fstream.h> //Used for infile and outfile
#include "Time.h"
#include "Account.h"
#include "Utility.h"
#include <iostream.h>

void main() {

      //Prototype Declarations
      void intro();

      //Local Variables
      Account currAcct;

      //Implementation
      intro();
      currAcct.verifyAcct();

}

void intro() { //Function which prints introduction page.

      /*

      Function Name: Intro
      Purpose: To display an introduction page
      Parameters:
            Input: none
            Input & Output: none
            Output: none
      Return Value: void
      Data Members Accessed: none
      Data Members Modified: none
      Non-local Variables Used: none
      Functions Called: none

      */

      //Local Variables
      Time t;
      
      lower();
      cout << CENTER << char(201) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(187) << endl;
      cout << CENTER << char(186) << "                                     " << char(186) << endl;
      cout << CENTER << char(186) << "        Welcome to Ryan's Bank       " << char(186) << endl;
      cout << CENTER << char(186) << "                                     " << char(186) << endl;
      cout << CENTER << char(186) << "           Do you trust me?          " << char(186) << endl;
      cout << CENTER << char(186) << "                                     " << char(186) << endl;
      cout << CENTER << char(200) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(205) << char(188) << endl;
      cout << CENTER << endl;
      cout << t.getDateAndTime();
      pause();

} //End intro Function

Utility.h...

#include <conio.h> //used for getche();
#include <windows.h>
#include "Constants.h" //used for CENTER, ClearScreen(),
#include <iostream.h> //used for cout;
#include <iomanip.h>
#include <stdlib.h> //used for atof()
#include <math.h> //used for atof()
#include <string.h> //used for strlen()

static void pause () {

      cout << CENTER << " " <<       "     Press any key to continue...    " << flush;
      getche();
      ClearScreen;

}

static void lower () {

      cout << "\n\n\n\n\n\n\n" << endl;

}

static int getPin () {

      int pinNum = 0;
      char pinChar[5];
      int i = 0;
      char temp;

      do {

            cout << flush;
            temp = getch();

            switch (temp) {

                  case toascii(48):
                  case toascii(49):
                  case toascii(50):
                  case toascii(51):
                  case toascii(52):
                  case toascii(53):
                  case toascii(54):
                  case toascii(55):
                  case toascii(56):
                  case toascii(57):
                        cout << "*";
                        pinChar[i] = temp;
                        ++i;
                        break;
                  case toascii(8):
                        if (i==0) {
                              cout << "";
                        } else {
                              cout << "\b \b";
                              --i;
                        }
                        break;
                  default:
                        MessageBeep(0xFFFFFFFF);
            }

      }while (i < 4);
      
      pinChar[i] = '\0';

      for (int n = 0; n < 4; n++) {
            
            pinNum = pinNum*10 + (toascii(pinChar[n]) - 48);

      }

      return pinNum;

}

static int getNumOnly () {

      int acctNum = 0;
      char acctChar[5];
      int i = 0;
      char temp;

      do {

            cout << flush;
            temp = getch();

            switch (temp) {

                  case toascii(48):
                  case toascii(49):
                  case toascii(50):
                  case toascii(51):
                  case toascii(52):
                  case toascii(53):
                  case toascii(54):
                  case toascii(55):
                  case toascii(56):
                  case toascii(57):
                        cout << temp;
                        acctChar[i] = temp;
                        ++i;
                        break;
                  case toascii(8):
                        if (i==0) {
                              cout << "";
                        } else {
                              cout << "\b \b";
                              --i;
                        }
                        break;
                  default:
                        MessageBeep(0xFFFFFFFF);
            }

      }while (i < 4);
      
      acctChar[i] = '\0';

      for (int n = 0; n < 4; n++) {
            
            acctNum = acctNum*10 + (toascii(acctChar[n]) - 48);

      }

      return acctNum;

}

static double getCurr () {

      double currNum = 0;
      char currChar[50];
      int i = 0;
      char temp;
      int dec = 0;
      bool exit = false;

      do {

            currChar[i];
            cout << flush;
            temp = getch();
      
                  switch (temp) {

                        case toascii(48):
                        case toascii(49):
                        case toascii(50):
                        case toascii(51):
                        case toascii(52):
                        case toascii(53):
                        case toascii(54):
                        case toascii(55):
                        case toascii(56):
                        case toascii(57):
                              cout << temp;
                              currChar[i] = temp;
                              ++i;
                              --dec;
                              break;
                        case toascii(8):
                              if (i==0) {
                                    cout << "";
                              } else {
                                    cout << "\b \b";
                                    --i;
                              }
                              --dec;
                              break;
                        case toascii(46):
                              cout << temp;
                              currChar[i] = temp;
                              ++i;
                              dec = 2;
                              break;
                        default:
                              MessageBeep(0xFFFFFFFF);
                  }

      }while ((dec != 0) && temp != toascii(13));

      currNum = atof(currChar);

      return currNum;

}

static void center (char string[]) {

      unsigned int len = strlen(string);
      int space = (80 - len)/2;

      for (int i = 0; i < space; i++) {
            cout << " ";
      }

      cout << string << endl;

}

Account.cpp

#include "Utility.h" //used for lower(), pause(), getPin(), center(), getNumOnly()
#include "Constants.h" //used for PER_STR, CENTER, ClearScreen();
#include <stdlib.h> //used for itoa()
#include <fstream.h> //used for ifstream();
#include <string.h>  //used for strcat();
#include <iostream.h>


class Account {

public:
      Account::Account(); //Constructor
      Account::Account(int acctNum, double balance, char *firstName, char *middleInital, char *lastName, int pin, char *acctFile); //Overloaded Constructor
      Account::~Account(); //Destructor
      Account::Account(Account &p); //Copy Constructor
      Account::verifyAcct();

private:
      int acctNum;
      double balance;
      char firstName[PER_STR];
      char middleInital[1];
      char lastName[PER_STR];
      int pin;
      char acctFile[PER_STR];
};

Account::Account() { //Constructor

      acctNum = 1234;
      balance = 0;
      firstName[PER_STR] = '\0';
      middleInital[1] = '\0';
      lastName[PER_STR] = '\0';
      pin = 1234;
      acctFile[PER_STR] = '\0';

} //End Constructor

Account::Account(int acctNum, double balance, char *firstName, char *middleInital, char *lastName, int pin, char *acctFile) { //Overlaoded Constructor

      acctNum = acctNum;
      balance = balance;
      firstName = firstName;
      middleInital = middleInital;
      lastName = lastName;
      pin = pin;
      acctFile = acctFile;

} //End Overloaded Constructor



Account::Account(Account &p) { //Copy Constructor

      p.acctNum = acctNum;
      p.balance = balance;
      p.firstName[PER_STR] = firstName[PER_STR];
      p.middleInital[1] = middleInital[1];
      p.lastName[PER_STR] = lastName[PER_STR];
      p.pin = pin;
      p.acctFile[PER_STR] = acctFile[PER_STR];

} //End Copy Constructor

Account::~Account() { //Destructor

} //End Destructor

Account::verifyAcct() {

      bool exit = false;

      do {

      lower();
      center("Please enter your four digit account number: ");
      cout << endl << setw(37) << " ";
      acctNum = getNumOnly();
      cout << endl << endl;
      center("Please enter your four digit pin number: ");
      cout << endl << setw(37) << " ";
      pin = getPin();

      _itoa(acctNum, acctFile, 10);

      strcat(acctFile, ".txt");

      ifstream infile;

      //Tries to open the file.  If it does not exist, it does not create one.
      infile.open(acctFile, ios::out|ios::nocreate);
      
      //If the account does not exist, prompt user to create one.
      
      if (!infile) {
            ClearScreen;
            lower();
            center("Invalid account...");
            cout << endl << endl;
            pause();
            ClearScreen;
      }

      infile >> acctNum;
      infile >> balance;
      infile >> lastName;
      infile >> firstName;

      //Closes the file
      infile.close();

      } while (!exit);


}

Constants.h

#define ClearScreen system("cls")
#define PER_STR 50
#define CENTER setw(22)

Time.h

class Time {
private:
      int year,
            month,
            day,
            dayOfWeek,
            hour24,
            hour12,
            minute,
            second;
      char timeCode[8];
      char ampm[3];
      char mos[10];
      char dOWeek[10];

public:
      // Constructors
      Time();
      Time(int year, int mos, int day, int hour, int min, int sec);
      Time(char * tCode);
      ~Time(); // Destructor
      void reset(); // to reset to current time
      char * getTimeCode();
      int getYear();
      int getMonthAsInt();
      char * getMonthAsString();
      int getDay();
      int getDayOfWeekAsInt();
      char * getDayOfWeekAsString();
      int getHour24();
      int getHour12();
      char * getAMPM();
      int getMinute();
      int getSecond();
      char * getDate();
      char * getTime();
      char * getDateAndTime();
};


Here are the errors:

Bank.obj : error LNK2001: unresolved external symbol "public: __thiscall Time::~Time(void)" (??1Time@@QAE@XZ)
Bank.obj : error LNK2001: unresolved external symbol "public: char * __thiscall Time::getDateAndTime(void)" (?getDateAndTime@Time@@QAEPADXZ)
Bank.obj : error LNK2001: unresolved external symbol "public: __thiscall Time::Time(void)" (??0Time@@QAE@XZ)
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/Project2.exe : fatal error LNK1120: 4 unresolved externals

Ryan
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 10753466
Well, the key is that you are using a console application and not a GUI - go to the project settings, pick the "Link" tab and see the text field at teh bottom. Locate '/subsystem:windows' nd make that read '/subsystem:console', this will fix the 'WinMain' problem. As for the 'Time' related errors - do you have a 'time.cpp' file and if so, did you add that to your project?
0
 

Author Comment

by:RySk8er30
ID: 10753500
Hi,

I have a time.h file, adn a time.obj file.  That is all I have been given.  I have added it to my project.

Ryan
0
 

Author Comment

by:RySk8er30
ID: 10753518
Hi,

It actually works now.  I must have choose a Windows Application instead of a Console Application.  Thank you for your help (except for the sarcasm).

Ryan
0
 
LVL 86

Expert Comment

by:jkr
ID: 10753983
Thank you!

> except for the sarcasm

Well, that IMHO was appropriate and hearty :o)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question