Thread: Unresolved External... -_-

  1. #1
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533

    Unresolved External... -_-

    My code and Errors are below, when I Build this I get the unresolved External errors, why? However, when I Compile I don't get any errors...

    WHY!?
    Code:
    #include <iostream.h>
    #include <windows.h>
    #include <iomanip.h>
    double area_(const double&r);
    double area_(const double&h,const double&w);
    double area_(const double&b1,const double&b2, const double&h);
    int full_screen(void);
    int kill_cursor(void);
    void clrscrn(void);
    
    
    const double PI = 3.14159265358979323;
    
    
    int main(int argc, char* argv[])
    {
    	double price=0;
    	double r=0, height=0, width=0, base1=0, base2=0;
    	int choice;
    	clrscrn();
    	full_screen();
    	kill_cursor();
    	cout<<setprecision(2)<<setiosflags(0x1000 | 0x0100);
    	cout<<"Choose:"<<endl
    		<<"1. Circular Pizza Calculations.\n"
    		<<"2. Rectangular Pizza Calculations. \n"
    		<<"3. Trapazoidal Pizza Calculations. \n"
    		<<"choice: ";
    	cin>>choice;
    	cout<<"\n";
    	switch(choice)
    	{
    	case 1: cout<<"Enter the radius: ";
    		cin>>r;
    		cout<<"\n";
    		price = area_(r);
    		cout<<"The price per square inch is: "<<price<<endl;
    		break;
    	case 2: cout<<"Enter the height: ";
    		cin>>height;
    		cout<<"\nEnter the width: ";
    		cin>>width;
    		cout<<"\n";
    		price = area_(height,width);
    		cout<<"The price per square inch is: "<<price<<endl;
    		break;
    	case 3: cout<<"Enter the length of base1: ";
    		cin>>base1;
    		cout<<"\nEnter the length of bas2: ";
    		cin>>base2;
    		cout<<"\nEnter the height: ";
    		cin>>height;
    		cout<<"\n";
    		price = area_(base1,base2,height);
    		cout<<"The price per square inch is: "<<price<<endl;
    		break;
    	default: cout<<"Not valid choice\n";
    	}
    	return 0;
    }
    		
    	
    
    
    
    
    double area_(double&r)
    {
    	double price, area1, aPrice;
    	cout<<"\nEnter the price in for the pizza you paid: ";
    	cin>>price;
    	cout<<endl;
    	area1 = PI * r * r;
    	aPrice = price / area1;
    	return aPrice;
    }
    double area_(double &h, double &w)
    {
    	double price, area1, aPrice;
    	cout<<"\nEnter the price in for the pizza you paid: ";
    	cin>>price;
    	cout<<endl;
    	area1 = w * h;
    	aPrice = price / area1;
    	return aPrice;
    }
    double area_(double &b1, double &b2, double &h)
    {
    	double price, area1, aPrice;
    	cout<<"\nEnter the price in for the pizza you paid: ";
    	cin>>price;
    	cout<<endl;
    	area1 = (b1+b2) * h * 0.5;
    	aPrice = price / area1;
    	return aPrice;
    }
    int full_screen()
    {
    	keybd_event(VK_MENU,0x38,0,0);
    	keybd_event(VK_RETURN,0x1c,0,0);
    	keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
    	keybd_event(VK_MENU,0x38,KEYEVENTF_KEYUP,0);
    	return 0;
    }
    int kill_cursor()
    {
    	CONSOLE_CURSOR_INFO cci;
    	cci.dwSize=1;
    	cci.bVisible = FALSE;
    	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);
    	return 0;
    }
    
    void clrscrn()
    {
    	COORD coordScreen={ 0, 0};
    	DWORD cCharsWritten;
    	CONSOLE_SCREEN_BUFFER_INFO csbi;
    	DWORD dwConSize;
    	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    
    	GetConsoleScreenBufferInfo(hConsole, &csbi);
    	dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    	FillConsoleOutputCharacter(hConsole,TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
    	GetConsoleScreenBufferInfo(hConsole, &csbi);
    	FillConsoleOutputAttribute(hConsole,csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
    	SetConsoleCursorPosition(hConsole, coordScreen);
    }

    Code:
    --------------------Configuration: homework4 - Win32 Debug--------------------
    Compiling...
    main.cpp
    Linking...
    main.obj : error LNK2001: unresolved external symbol "double __cdecl area_(double const &,double const &,double const &)" (?area_@@YANABN00@Z)
    main.obj : error LNK2001: unresolved external symbol "double __cdecl area_(double const &,double const &)" (?area_@@YANABN0@Z)
    main.obj : error LNK2001: unresolved external symbol "double __cdecl area_(double const &)" (?area_@@YANABN@Z)
    Debug/homework4.exe : fatal error LNK1120: 3 unresolved externals
    Error executing link.exe.
    
    homework4.exe - 4 error(s), 0 warning(s)
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Code:
    double area_(const double&r);
    double area_(const double&h,const double&w);
    double area_(const double&b1,const double&b2, const double&h);
    The functions are defined as taking const references, while their implementation (really different definition, so it's not their implementation at all, they are not implemented.) aren't using const. See the difference?

    Code:
    double area_(double&r)
    Last edited by SilentStrike; 10-20-2002 at 10:15 PM.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Besides the above pointing out that your function prototypes and function definitions do not match up, a constant would be:
    const .075
    const "Foo"
    etc.
    The world is waiting. I must leave you now.

  4. #4
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    DOH!!!
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM
  5. Unresolved external symbols in OGL
    By Shadow12345 in forum Game Programming
    Replies: 4
    Last Post: 08-04-2002, 09:46 PM