Helpful Information
 
 
Category: Computer Programming
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:

/* 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;
}

teufelfisch,

I would be helpful if you posted the link errors.

Fivesidecube

Link Error : Undefined symbol : [email protected]@[email protected] (apstring :: apstring()) in test.cpp

Link Error : Undefined symbol : [email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected]@@@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 : [email protected]@YAXXZ (void crypt()) in test.cpp

Link Error : Undefined symbol : [email protected]@[email protected] (apstring::~apstring()) in test.cpp

Link Error : Undefined symbol : [email protected]@YAXXZ (void inFile()) in test.cpp

Link Error : Undefined symbol : [email protected]@[email protected] (apstring::~apstring()) in test.cpp

Don't know how much that will help.

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?

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










privacy (GDPR)