AP Programming Question

jmcoreymv

Diamond Member
Oct 9, 1999
4,264
0
0
Im using VC++ 6 and Im trying to use the AP String class but when I link it, I get a bunch of unresolved external errors. The compile however is fine. And its a really simple program which im copying out of the lesson so I know its not my code. What causes unresolved symbols and stuff like that?
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
Post your code here.
Apstring has some weird ass errors sometimes, that usually have nothing to do with the class itself.
 

tweakmm

Lifer
May 28, 2001
18,436
4
0


<< Apstring has some weird ass errors sometimes, that usually have nothing to do with the class itself. >>

 

Gunslinger08

Lifer
Nov 18, 2001
13,234
2
81
Just use cstring

Dunno if it's available in VC++, but it works the same in Borland (only thing my crappy school can afford).

Josh
 

jmcoreymv

Diamond Member
Oct 9, 1999
4,264
0
0
Heres the code:

#include<iostream.h>
#include"apstring.h"
void testConstructors();

int main()
{
testConstructors();
return(0);
}

void testConstructors()
{
apstring word1;
apstring word2("Hello World\0");
apstring word3("Hello World\n");
cout<<"Testing constructors"<<endl<<endl;
cout<<word1;
cout<<word2;
cout<<word3;
}

Heres the errors:

Linking...
strings231.obj : error LNK2001: unresolved external symbol "public: __thiscall apstring::~apstring(void)" (??1apstring@@QAE@XZ)
strings231.obj : error LNK2001: unresolved external symbol "class ostream & __cdecl operator<<(class ostream &,class apstring const &)" (??6@YAAAVostream@@AAV0@ABVapstring@@@Z)
strings231.obj : error LNK2001: unresolved external symbol "public: __thiscall apstring::apstring(char const *)" (??0apstring@@QAE@PBD@Z)
strings231.obj : error LNK2001: unresolved external symbol "public: __thiscall apstring::apstring(void)" (??0apstring@@QAE@XZ)
Debug/strings231.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

strings231.exe - 5 error(s), 0 warning(s)
 

tweakmm

Lifer
May 28, 2001
18,436
4
0
have you ever used the AP classes on this computer before?
Do they work for other programs?
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
Hmmmm sounds like your compiler doesn't like Apstring. Have you used it before?
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136


<< Try including "apstring.cpp" instead of .h >>



No.. apstring is a class. It has to be called like a class. And the class is in the H file.
Try <apstring.h> just for sh|ts and giggles.
 

tweakmm

Lifer
May 28, 2001
18,436
4
0


<<

<< Try including "apstring.cpp" instead of .h >>



No.. apstring is a class. It has to be called like a class. And the class is in the H file.
Try <apstring.h> just for sh|ts and giggles.
>>


that might help, but he might now have the header/class files in the right directory.
Have you used the AP classes on this computer before
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
Yeah, make sure apstring.h is in your compiler's library folder, or you can specify a path for it.
 

jmcoreymv

Diamond Member
Oct 9, 1999
4,264
0
0
I have used two other ap classes so far, apvector and apmatrix. Both seemed to work fine. The compiler is the one thats part of VC++ 6 as part of Enterprise Edition of VS. I also have the Architect Version of VS NET but I cant figure out how to make that thing compile. The option always stays greyed out. If I use the include<> it still gives the same errors (I have a copy of all the files in the include directory).
 

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
did you include apsting.cpp in your project? apstring is the only ap class that requires the .cpp file in the project
 
Jun 18, 2000
11,220
783
126


<<

<< Try including "apstring.cpp" instead of .h >>



No.. apstring is a class. It has to be called like a class. And the class is in the H file.
Try <apstring.h> just for sh|ts and giggles.
>>


I know full well what a class is. I've had this problem before. Including the .cpp instead of the .h works.
 

crypticlogin

Diamond Member
Feb 6, 2001
4,047
0
0
A really quick skim of google doesn't show any implementations of:

apstring word("text");

but tons of:

apstring word = "text";

Are you sure you're calling it right?
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
I have used apstring for two years and never called a .cpp file. Not once.
Perhaps you are not calling it right.
You need to use the replacement operator:

apstring text = "text";

 

jmcoreymv

Diamond Member
Oct 9, 1999
4,264
0
0
It looks like including the cpp file instead of the header file worked. How odd is that, but thanks for the help guys.
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136


<< It looks like including the cpp file instead of the header file worked. How odd is that, but thanks for the help guys. >>



I don't know what the hell kind of compiler will accept that kind of call, but it isn't anything I have ever seen, not even on AP's own exam.
 

tweakmm

Lifer
May 28, 2001
18,436
4
0


<<

<< It looks like including the cpp file instead of the header file worked. How odd is that, but thanks for the help guys. >>



I don't know what the hell kind of compiler will accept that kind of call, but it isn't anything I have ever seen, not even on AP's own exam.
>>


no sh!t.....
leave it to M$ to screw up the impementation of a great language
 
Jun 18, 2000
11,220
783
126


<< It wouldn't work with apstring >>


That's odd, cuz it's worked for me on several occasions, but I guess you guys know better.
rolleye.gif


Hell, a little project I've been working on at home didn't compile correctly (same/similar errors to what jmcoreymv is having) until I included "apstring.cpp."

Edit:

<< I don't know what the hell kind of compiler will accept that kind of call, but it isn't anything I have ever seen, not even on AP's own exam. >>


I've been under the impession that the #include command simply inserts whatever text is "included" be it from a text file or string literal. It doesn't matter if the text is in a .cpp or .h.

In any case, you are very welcome jmcoreymv. :)