Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: need some help

  1. #1
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need some help

    I need some help..

    I am starting a cryptography program in C++, but have hit a snag with my linker. Any time I try to compile the backbone of the program, I get about six "link error: undefined symbol ... " errors.

    This is the first time I have seen these errors from the software I use (Metrowerks Code Warrior).

    Source:
    Code:
    /* Author:		teufelfisch
       Filename:	"test.cpp"
       Last Mod:	5/22/02		*/
    
    //  [Includes]
    #include <iostream>
    #include <fstream>
    #include "./stuff/apstring.h"
    using namespace std;
    
    //  [Classes]
    enum inType { UFILE, STRING };
    
    //  [Prototypes]
    void   crypt();		//Actual cryptography SR
    inType promptU();	//Prompts user for type: read from string or file
    void   inString();	//Gets string from user to be crypted
    void   inFile();	//Reads file to be crypted
    
    //  [Definitions]
    inType promptU()
    {	char marm;
    	inType retType;
    	bool exitFlag = true;
    	
    	do
    	{	cout << endl << "Type of input (f/s): ";
    		cin  >> marm;
    		marm = toupper(marm);
    		
    		if (marm == 'F')
    			retType = UFILE;
    		else
    		{	if (marm == 'S')
    				retType = STRING;
    			else
    			{	cout << endl << "Invalid type. Please specify file or string.";
    				exitFlag = false;	}
    		}
    	}
    	while (exitFlag == false);
    	
    	return retType;
    }
    
    void inString()
    {	apstring ustring;
    	cout << endl << "Please type the text to be encrypted." << endl;
    	getline(cin, ustring);
    	cout << "EncryptingÖ ";
    	crypt();
    }
    
    //  [Main Task Block]
    
    int main(void)
    {	inType type = promptU();
    	type == UFILE ? inFile() : inString(); //doesn't work??
    
    return 0;
    }
    Recycle Your Pets

  • #2
    New Coder
    Join Date
    Sep 2002
    Location
    Up North (UK)
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    teufelfisch,

    I would be helpful if you posted the link errors.

    Fivesidecube

  • #3
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Link Error : Undefined symbol : ??0apstring@@QAE@XZ (apstring :: apstring()) in test.cpp

    Link Error : Undefined symbol : ?getline@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@std@@AAV12@AAVapstring@@@Z (class std::basic_istream<char, struct std::char_traits<char>> & getline (class std::basic_istream<char, struct std::char_traits<char>> &, class apstring &)) in test.cpp

    Link Error : Undefined symbol : ?crypt@@YAXXZ (void crypt()) in test.cpp

    Link Error : Undefined symbol : ??1apstring@@QAE@XZ (apstring::~apstring()) in test.cpp

    Link Error : Undefined symbol : ?inFile@@YAXXZ (void inFile()) in test.cpp

    Link Error : Undefined symbol : ??1apstring@@QAE@XZ (apstring::~apstring()) in test.cpp

    Don't know how much that will help.
    Recycle Your Pets

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    there is something wrong with your functions. your compiler can't find them. try putting all of them in one file and see if it works. And not only the prototypes (the full functions).

    I think the problem is that the file where you've put the functions
    crypt, inFile and the datatype apstring is not compiled.
    You need to make a project or something so that the compiler knows which files to compile.

    Also, what is in apstring.h?

  • #5
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    apstring.h is basically for strings- I learned with it. I like the way it works, so I decided to go back to it.

    All of this is already in a project.

    Oh, wow. I just fixed the problem myself. I needed to add "apstring.cpp" to the project, it seems "apstring.h" is dependent on that file.

    Tnx for helping anyways
    teufelfisch
    Recycle Your Pets


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •