How do I fix this error?

This is a discussion on How do I fix this error? within the C++ Programming forums, part of the General Programming Boards category; LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 Debug/Lab7.exe : fatal error LNK1120: 1 unresolved externals...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    5

    How do I fix this error?

    LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
    Debug/Lab7.exe : fatal error LNK1120: 1 unresolved externals

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    It looks like you didn't choose the right settings for your C++ program. Instead, you chose settings for a windows program, which is very different than a C++ program.

    My suggestion is to cut and paste your code into Notepad or something similar, then start a new project with a new name, and then paste your code into the new project. If you've never set up a project before, then say so, and I or someone else can post the details on what to do.
    Last edited by 7stud; 12-14-2003 at 01:00 AM.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    5
    This was my first attempt at setting up a project and workspace. I made it a Win32 Application, because that is what my instructor said to make it. Everything compiles fine, but I get the error when linking.
    Last edited by BigMac; 12-14-2003 at 02:04 AM.

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    5
    Code:
    #include <iostream.h>
    #include "Transaction.h"
    #include "BankStatement.h"
     
    void main()
    {
    	BankStatement MyStatement;
    	MyStatement.SetBegBal(15.92f);
    
    	Transaction T1;
    	T1.SetAmount(123.56f);
    	T1.SetCode('D');
    	T1.SetNote("CTPay");
    	Transaction T2(153.86f,'W',"Rent");
    	Transaction T3;
    	T3.SetAmount(75.56f);
    	T3.SetCode('D');
    	T3.SetNote("Tips");
    	Transaction T4(12.56f,'D',"Gift");
    	Transaction T5;
    	T5.SetAmount(73.74f);
    	T5.SetCode('W');
    	T5.SetNote("Date");
    	Transaction T6(145.75f,'D',"Loan");
    	Transaction T7;
    	T7.SetAmount(40.00f);
    	T7.SetCode('W');
    	T7.SetNote("LoanPymt");
    	Transaction T8(21.74f,'W',"Groceries");
    
    	MyStatement.EnterTransaction(T1);
    	MyStatement.EnterTransaction(T2);
    	MyStatement.EnterTransaction(T3);
    	MyStatement.EnterTransaction(T4);
    	MyStatement.EnterTransaction(T5);
    	MyStatement.EnterTransaction(T6);
    	MyStatement.EnterTransaction(T7);
    	MyStatement.EnterTransaction(T8);
    
    	MyStatement.DisplayResults();
    	MyStatement.ArrangeTransactions();
    	MyStatement.PrintArranged();
    }

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    5
    Code:
    #include "Transaction.h"
    #include <string.h>
    
    Transaction::Transaction(float InAmount, char InCode, char InNote[])
    {
    	SetAmount(InAmount);
    	SetCode(InCode);
    	SetNote(InNote);
    }
    
    void Transaction::SetAmount(float NewAmount)
    {
    	Amount = NewAmount;
    }
    
    void Transaction::SetCode(char NewCode)
    {
    	Code = NewCode;
    }
    
    void Transaction::SetNote(char *NewNote)
    {
    
    	strcpy(Note,NewNote);
    
    
    }
    Code:
    #ifndef tran_h
    #define tran_h
    
    #include <iostream.h>
    
    class Transaction  
    {
    public:
    	Transaction(){Amount = 0.0f; Code = 'N'; Note[0] = '\0';}
    
    	Transaction(float InAmount, char InCode, char InNote[]);
    	
    	void SetAmount(float NewAmount);
    
    	float GetAmount(){return Amount;}
    
    	void SetCode(char NewCode);
    
    	char GetCode(){return Code;}
    
    	void SetNote(char *NewNote);
    
    	void PrintNote(){cout<<Note<<endl;}
    
    private:
    	float Amount;
    	char Code;
    	char Note[20];
    };
    
    #endif

  6. #6
    Registered User
    Join Date
    Nov 2003
    Posts
    5
    Code:
    #include "BankStatement.h"
    #include "Transaction.h"
    
    
    //////////////////////////////////////////////////////////////////////
    // Construction/Destruction
    //////////////////////////////////////////////////////////////////////
    
    
    void BankStatement::SetBegBal(float Balance)
    {
    	BegBal = Balance;
    }
    
    void BankStatement::EnterTransaction(Transaction Input)
    {
    	static int num_tran;
    
    	TransactionLog[num_tran] = Input;
    
    	
    }
    
    void BankStatement::DisplayResults()
    {
    	int NumWith = 0;
    	int NumDep = 0;
    	
    	for ( int tran_num = 0; tran_num < 8; tran_num++)
    	{
    		if (tran_num = 0)
    			cout<<"The beginning balance was: "<<BegBal;
    		else
    		{
    			cout<<endl<<"Transaction: "<<tran_num<<" was a "<<" amount "<<" for "<<endl;
    			cout<<" Running Bal: "<<RunningBal[tran_num + 1];
    			if (RunningBal[tran_num + 1] < 0)
    				cout<<endl<<"OVERDRAWN";
    		}
    	}
    
    	NumWith = NumEntries - NumDep;
    
    	cout<<"The ending balance is: "<<EndBal<<endl;
    	cout<<"The number of transactions is: "<<NumEntries<<endl;
    	cout<<"The number of Deposits is: "<<NumDep<<endl;
    	cout<<"The number of Withdrawls is: "<<NumWith<<endl;
    }
    
    void BankStatement::ArrangeTransactions()
    {
    	for ( int x = 0; x < 8; x++)
    	{
    		for ( int x = 0; x < 8; x++)
    		{
    		
    		}		
    	}
    }
    
    void BankStatement::PrintArranged()
    {
    	for ( int x = 0; x < 8; x++)
    	{
    		
    	}
    }
    Code:
    #ifndef bankState_h
    #define bankState_h
    
    #include "Transaction.h"
    
    class BankStatement  
    {
    public:
    	BankStatement() {NumEntries = 0; BegBal = 0.0; EndBal = 0;}
    
    	void SetBegBal(float Balance);
    
    	float GetBegBal() {return BegBal;}
    
    	float GetEndBal() {return EndBal;}
    
    	int GetNumEntries() {return NumEntries;}
    
    	void EnterTransaction(Transaction Input);
    
    	void DisplayResults();
    
    	void ArrangeTransactions();
    
    	void PrintArranged();
    ;
    private:
    	Transaction TransactionLog[10];
    	Transaction Arranged[10];
    	int NumEntries;
    	float RunningBal[10];
    	float BegBal;
    	float EndBal;
    };
    
    #endif

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Make it a Consolse application, not Win32 application.

    >void main()

    Don't use void main. main returns an int:
    int main(void)

    See the Programming FAQ at the bottom of the page for why.

  8. #8
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    I made it a Win32 Application, because that is what my instructor said to make it.
    You sure he/she didn't say to make it a Win23 Console Application? There's a difference.

    Details for setting up a project using VC++ 6:

    The first thing you need to do before you start writing your program is to start a new project. You should close all workspaces before doing that--if any are open--by clicking on File/Close Workspace. Then click on File/New. The projects tab should already be selected and you should make sure the radio button for "Create new workspace" is checked. For a console program(needed for beginning C++ programs), select Win32 Console Application, fill in a project name, then click OK. Then select Empty Project and click Finish. Then click on OK.

    Now you need to create a file for your project. Click on File/New and the Files tab should be selected. Click on C++ Source File. Make sure the "Add to project" check box is checked. Fill in the File Name(with no extension--it will be added for you) and click on OK. At the top left of the Visual C++ window, in the blue border, it will show the project name and then Microsoft Visual C++. The file you created has its name in the blue border at the top of its window.

    Then you type in your code, and when you are done you need to compile it. You can compile your program by clicking on the toolbar button that looks like a box with dots in it and two down arrows with dots above the arrows, or by choosing the build menu item and selecting "Compile your_project.cpp". (If the toolbar button I described isn't visible, you can right click anywhere in the toolbar area and select Build MiniBar to diplay the applicable toolbar buttons.)

    After you compile your program, any errors will be displayed in a separate frame. You can read an error and then click on the error message to take you to the line where the error occured in your code. Once you take care of all the errors, then you can execute your program by clicking on the tool bar button that looks like a red exclamation mark, or by clicking on the Build menu and selecting "Execute your_project.exe". After that, a DOS window will open and the results of your program will be output to the DOS window.

    The project hierarchy goes like this: workspace/project/files. A project is simply a program of some kind made up of various files(for a beginner it will be only one file), and a project workspace is a folder in which all the information relating to a project is stored. When you create a project, a project workspace(a folder) is created automatically, and Visual C++ will maintain all the source code and other files in the project workspace folder. When you want to stop working on a program, you click on File/Close Workspace, and when you want to start working on a previous project, you click on File/Open Workspace or File/Recent Workspaces.

    The only way you can permanently delete files and/or workspaces is to navigate to the folder on your computer and delete one of the files in the folder or the whole folder. Deleting a file in Visual C++ does not remove it from the workspace.

  9. #9
    Registered User
    Join Date
    Sep 2003
    Posts
    135
    Originally posted by 7stud
    You sure he/she didn't say to make it a Win23 Console Application? There's a difference.
    Probably not, Win23 didn't really get off the ground in most parts

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  4. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  5. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21