AP Comp Sci C++ Classes in OS X

Posted:
in Genius Bar edited January 2014
I downloaded all of the AP classes (apmatrix.h, apvector.h, apmatrix.cpp etc) and put them in the /usr/include/ folder.

When I try to compile a program with Project Builder I get the following error:

in file included from main.cpp:3

template with C linkage



my program is:

using namespace std;

#include <iostream>

#include <apvector.h>



int main (int argc, const char * argv[]) {



apvector<int> test(10);

cout<< "Hello, World!\

";

return 0;

}

I know that nothing in the program is wrong.

Has anyone had success using the AP Classes in OS X?



[ 10-12-2002: Message edited by: jante99 ]



[ 10-12-2002: Message edited by: jante99 ]</p>

Comments

  • Reply 1 of 5
    Why are you using C++? Anyway,the problem may be that you haven't linked the headers to the project in Project Builder,even though it is declared in the main function.Go to Project&gt;Add Frameworks and then on from there.I'm not sure if this will work or not because I only have used Objective C with Project Builder,but is worth a try.
  • Reply 2 of 5
    mcqmcq Posts: 1,543member
    The only other thing I'd try is either changing it to



    #include "apvector.h"



    Or do that and also copy the ap classes into whatever directory you have your work in.



    Btw Rick, Jante's using C++ because AP Computer Science is taught in C++, not Obj-C.
  • Reply 3 of 5
    thuh freakthuh freak Posts: 2,664member
    ok, i've never seen, or atleast can't remember, a `template with C linkage` error. if it aint breaking any laws, i suggest u put a link to those files, and i can try to figure out the prob. prelim, it seems like a prob with the apvector.h tho, since the prob was main.cpp line 3 (which points at the #include for apvector)
  • Reply 4 of 5
    linking to the files works!
  • Reply 5 of 5
    Good.In general you have to specifically link files to ProjectBuilder through the menus to include them in the project,even if you have placed them physically in the directories of the project in question ProjectBuilder often won't know they are there-don't spend too much time trying to decode error messages-a lot of them don't make sense or aren't really related to the problem at hand.
Sign In or Register to comment.