Note that there are some explanatory texts on larger screens.

plurals
  1. POld: Symbol(s) not found… but they are there…
    text
    copied!<p>My project is really acting up lately - I ironed out a whole bunch of errors, and then it throws a cryptic <code>ld: symbol(s) not found</code> error. However, it's clear that the symbols do exist:</p> <pre><code>Undefined symbols: "Solid::~Solid()", referenced from: void std::_Destroy&lt;Solid&gt;(Solid*)in ui.o "Log::operator+=(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)", referenced from: runUI() in ui.o "Log::getLog(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)", referenced from: runUI() in ui.o "Log::Log()", referenced from: __static_initialization_and_destruction_0(int, int)in ui.o "Building::Building(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)", referenced from: runUI() in ui.o "Log::~Log()", referenced from: ___tcf_1 in ui.o </code></pre> <p>Here are the files it references:</p> <h3>log.cpp</h3> <pre><code>/* * log.cpp * * Created on: Apr 30, 2011 * Author: wjc */ #include &lt;string&gt; #include &lt;vector&gt; #include &lt;sstream&gt; // for converting count to string #include "consts.h" using namespace std; struct logResult { vector &lt;string&gt; result; int status; }; struct parsedLog { string result; int status; }; class Log { private: bool initialized; vector &lt;string&gt; * actionLog; static int count; string countString(){ stringstream ss; ss&lt;&lt;count; return ss.str(); } public: int initialize(){ if (initialized) return ALREADY_INIT; actionLog-&gt;push_back("*** Log initialized ***"); actionLog-&gt;push_back("This is log#" + countString() +". If this is greater than one, there is a problem."); initialized = true; return SUCCESS; } int initialize(string text){ int initResult = initialize(); if (initResult == ALREADY_INIT) return ALREADY_INIT; actionLog-&gt;push_back("Initialization message: "+text); return SUCCESS; } Log (){ initialize(); count++; } Log (string text){ initialize(text); count++; } ~Log (){ count--; } bool isInitialized(){ return initialized; } int add(string text){ if (!initialized) return NOT_INIT; actionLog-&gt;push_back(text); return SUCCESS; } int operator+= (string text){ return add(text); } int clearLog(bool init = true){ if (!initialized) return NOT_INIT; delete actionLog; int initResult = SUCCESS; if (init) initResult = initialize(); if (initResult == ALREADY_INIT) return ALREADY_INIT; // Otherwise // (no other possibilities because initialize() // only returns either a SUCCESS or // ALREADY_INIT value) return SUCCESS; } logResult getLog(){ if (!initialized){ logResult final; final.status = NOT_INIT; return final; } else { logResult final; final.result = *actionLog; final.status = SUCCESS; return final; } } parsedLog getLog(string delim){ if (!initialized){ parsedLog final; final.status = NOT_INIT; return final; } else { parsedLog final; string logString; for (unsigned int i; i&lt;actionLog-&gt;size()-1; i++){ logString += (*actionLog)[i]; logString += delim; } logString += actionLog-&gt;back(); final.result = logString; final.status = SUCCESS; return final; } } }; </code></pre> <h3>log.h</h3> <pre><code>/* * log.h * * Created on: Apr 30, 2011 * Author: wjc */ #ifndef LOG_H_ #define LOG_H_ #include &lt;string&gt; using namespace std; struct logResult { vector &lt;string&gt; result; int status; }; struct parsedLog { string result; int status; }; class Log { public: int initialize(); int initialize(string text); Log (); Log (string text); ~Log(); bool isInitialized; int add(string text); int operator+= (string text); int clearLog (bool init = true); vector &lt;string&gt; getLog(); parsedLog getLog(string delim); private: bool initialized; vector &lt;string&gt; actionLog; static int count; string countString(); }; #endif /* LOG_H_ */ </code></pre> <h3>ui.cppp</h3> <pre><code>/* * Created on: Apr 26, 2011 * ui.cpp * Author: wjc */ #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;sstream&gt; #include "filedaemon.h" #include "vsystem.h" #include "customio.h" #include "building.h" #include "log.h" using namespace std; bool shouldexit = false; bool back = false; int selection; void addShape(); void modifyVars(); struct getVarResult { var result; int status; }; Log actionLog; var novar = {"ERROR", -1, Reserved}; getVarResult getVar(int type); void viewBuilding(); int runUI(){ while (!shouldexit){ cout&lt;&lt;"Please select an item from the list below and press Enter:"&lt;&lt;endl; const int mmenuLength = 2; string mmenuOptions[2] = {"Create a new document","Quit"}; for (int i=0; i&lt;2; i++){ cout&lt;&lt;i+1&lt;&lt;": "&lt;&lt;mmenuOptions[i]&lt;&lt;endl; } cout&lt;&lt;endl; selection = getMenuItem(1,mmenuLength); if (selection == mmenuLength) return 0; // Quit if it's the last one cout&lt;&lt;"Enter a name for your building:"&lt;&lt;endl; string buildingTitle; getline(cin, buildingTitle); Building b(buildingTitle); actionLog += "New building " + buildingTitle + " created."; const int bmenuLength = 5; string bmenuOptions[5] = {"Add shape","Modify variables","View building","View log","Quit"}; for (int i=0; i&lt;bmenuLength; i++){ cout&lt;&lt;i+1&lt;&lt;": "&lt;&lt;bmenuOptions[i]&lt;&lt;endl; } cout&lt;&lt;endl; selection = getMenuItem(1,bmenuLength); switch (selection){ case 1: // Add a shape break; case 2: modifyVars(); break; case 3: // View building break; case 4: { parsedLog parsed = actionLog.getLog("\n"); if (parsed.status == SUCCESS) { cout&lt;&lt;"The following contains the contents of your action log."&lt;&lt;endl; cout&lt;&lt;parsed.result&lt;&lt;endl&lt;&lt;endl; } else { cout&lt;&lt;"Somehow your log is not initialized."&lt;&lt;endl&lt;&lt;endl; } } break; case 5: shouldexit = true; break; default: cout&lt;&lt;"You entered a number greater than "&lt;&lt;bmenuLength&lt;&lt;" or less than 1. How you did this is a mystery."&lt;&lt;endl&lt;&lt;"[ Press Enter to exit ]"&lt;&lt;endl; string temp; getline(cin, temp); return 0; } // The following commented-out block is a // test of the variable storing system. // It will not be used in any final products. /*cout &lt;&lt; " Variable Systems Test "&lt;&lt;endl; cout &lt;&lt; "~~~~~~~~~~~~~~~~~~~~~~~~~~~"&lt;&lt;endl; cout &lt;&lt; endl; cout&lt;&lt;"Enter a variable name:"&lt;&lt;endl; string varname; cin&gt;&gt;varname; cout&lt;&lt;"Enter a value (A FLOAT!):"&lt;&lt;endl; float value; cin&gt;&gt;value; cout&lt;&lt;"Checking to see if "&lt;&lt;varname&lt;&lt;" exists."&lt;&lt;endl; bool alreadythere = checkVar(varname); alreadythere ? cout&lt;&lt;"It exists!"&lt;&lt;endl : cout&lt;&lt;"It doesn't exist."&lt;&lt;endl; if (alreadythere){ cout&lt;&lt;"Changing variable. Function returned "&lt;&lt;changeVar(varname, value)&lt;&lt;endl; } else { cout&lt;&lt;"Setting variable. Function returned "&lt;&lt;addVar(varname, value)&lt;&lt;endl; } cout&lt;&lt;"Enter a variable to check:"&lt;&lt;endl; string varcheck; cin&gt;&gt;varcheck; fetchResult result = fetchVar(varcheck); if(! result.good){ cout&lt;&lt;"Variable \""&lt;&lt;varcheck&lt;&lt;"\" doesn't exist!"&lt;&lt;endl; } else { cout&lt;&lt;"Variable \""&lt;&lt;varcheck&lt;&lt;"\" is equal to "&lt;&lt;result.result&lt;&lt;endl; } cout&lt;&lt;getVarList("\n","\t")&lt;&lt;endl; string exitstr; getch;*/ } return 0; } void modifyVars(){ while (! back){ cout&lt;&lt;"These are your defined variables."&lt;&lt;endl; cout&lt;&lt;"Reserved variables have an asterisk preceding them."&lt;&lt;endl; vector &lt;var&gt; vars = getVarList(); for (unsigned int i = 0; i&lt;vars.size(); i++){ cout&lt;&lt;endl; vars[i].reserved ? cout&lt;&lt;" * " : cout&lt;&lt;" "; cout &lt;&lt; vars[i].name&lt;&lt;" = "; cout&lt;&lt;fixed&lt;&lt;vars[i].value; }cout&lt;&lt;endl; cout&lt;&lt;"What would you like to do?"&lt;&lt;endl; string varMenuOptions[4] = {"Add a variable","Change a variable","Remove a variable","Go back"}; for (int i = 0; i&lt;4; i++){ cout&lt;&lt;i+1&lt;&lt;". "&lt;&lt;varMenuOptions[i]&lt;&lt;endl; } cout&lt;&lt;endl; selection = getMenuItem(1,3); switch(selection){ case 1: // Add variable { getVarResult gvr = getVar(ADD); if (gvr.status == SUCCESS) addVar(gvr.result.name, gvr.result.value, UserDefined); break; } case 2: // Change variable { getVarResult gvr = getVar(CHANGE); if (gvr.status == SUCCESS) changeVar(gvr.result.name, gvr.result.value); break; } // switch (selection) } // while (!back) } } getVarResult getVar(int type){ getVarResult finalResult; getVarResult invalidType; getVarResult cancelled; invalidType.result = novar; invalidType.status = INVALID_TYPE; cancelled.result = novar; cancelled.status = USER_CANCELLED; if (type != ADD &amp;&amp; type != CHANGE) return invalidType; bool usercancelled = false; bool nameOK = true; bool varIsReserved = false; string varName; do { switch(type){ case ADD: if (!nameOK) cout&lt;&lt;"That variable already exists."&lt;&lt;endl; break; case CHANGE: if (!nameOK) cout&lt;&lt;"That variable has not yet been created."&lt;&lt;endl; if (varIsReserved) cout&lt;&lt;"That variable is used by the system and cannot be changed."&lt;&lt;endl; break; } cout&lt;&lt;"Enter the variable's name, or \"BACK\": "; varName = getString(1,16); if (varName == "BACK"){ usercancelled = true; break; } fetchResult testExist = fetchVar(varName); switch(type){ case ADD: nameOK = !testExist.good; break; case CHANGE: nameOK = testExist.good; varIsReserved = testExist.reserved; break; default: cout &lt;&lt; "Function error - int type seems to have changed since user called getVar(int type)."&lt;&lt;endl; cout &lt;&lt; "[ Press Enter to exit]"&lt;&lt;endl; string temp; getline(cin, temp); return invalidType; } } while (! nameOK || varIsReserved); finalResult.result.name = varName; if (usercancelled) return cancelled; bool valueOK = true; float numValue; do { if (! valueOK) cout&lt;&lt;"That doesn't seem to be a valid positive number."; cout&lt;&lt;"Enter the new value, or \"COPY\" to copy a variable, or \"BACK\":"&lt;&lt;endl; string value = getString(); /* * If "BACK" then break do-while(! valueOK) */ if (value == "BACK"){ usercancelled = true; break; } if(value == "COPY"){ string copyVar; fetchResult varContents; bool copyOK = true; do { if (!copyOK) cout&lt;&lt;"That variable does not exist. Note that names are case-sensitive."&lt;&lt;endl; cout&lt;&lt;"Enter the variable to copy, \"VIEW\" to view all, or \"BACK\":"&lt;&lt;endl; /* * If "BACK" then break do-while(! valueOK) */ if (value == "BACK"){ usercancelled = true; break; } copyVar = getString(1,8); if (copyVar == "VIEW") { cout&lt;&lt;"Your current variables are as follows:"&lt;&lt;endl; vector &lt;var&gt; vars = getVarList(); for (unsigned int i = 0; i&lt;vars.size(); i++){ cout&lt;&lt;endl; vars[i].reserved ? cout&lt;&lt;" * " : cout&lt;&lt;" "; cout &lt;&lt; vars[i].name&lt;&lt;" = "; cout&lt;&lt;fixed&lt;&lt;vars[i].value; }cout&lt;&lt;endl; } else { varContents = fetchVar(copyVar); copyOK = varContents.good; numValue = varContents.result; } } while (copyVar == "VIEW" || ! copyOK); } else { // This code converts from string to number safely. stringstream testStream(value); if (! (testStream &gt;&gt; numValue)) valueOK = false; } if (! usercancelled) break; } while (! valueOK); finalResult.result.value = numValue; if (usercancelled) return cancelled; finalResult.status = SUCCESS; return finalResult; } </code></pre> <h3>ui.h</h3> <pre><code>/* * ui.h * * Created on: Apr 26, 2011 * Author: wjc */ #ifndef UI_H_ #define UI_H_ #include "vsystem.h" int runUI(); void addShape(); void modifyVars(); struct getVarResult { var result; int status; }; getVarResult getVar(int type); void viewBuilding(); #endif /* UI_H_ */ </code></pre> <h3>building.h</h3> <pre><code>/* * building.h * * Created on: Apr 30, 2011 * Author: wjc */ #ifndef BUILDING_H_ #define BUILDING_H_ #include &lt;string&gt; #include &lt;vector&gt; #include "consts.h" #include "solid_type.h" using namespace std; struct dimension { bool exists; float value; }; class Solid { public: string name; string comment; solid_type type; bool positive; dimension dim1; // Radius, width, or side length dimension dim2; // Height, number of sides, or fraction of sphere_over_n dimension dim3; // Width - only for prism_rect, pyrm_rect and tprym_rect Solid (); Solid (bool pos); Solid (string setName, string setComment, solid_type setType, bool setPos, dimension setDim1, dimension setDim2, dimension setDim3); ~Solid(); int countShapes(); int howMany(); private: static int count; }; class Building { private: string name; vector &lt;Solid&gt; components; public: Building(string text); void setName(string text); string getName(); vector &lt;Solid&gt; addComponent(Solid component); }; #endif /* BUILDING_H_ */ </code></pre> <h3>building.cpp</h3> <pre><code>/* * building.cpp * * Created on: May 1, 2011 * Author: wjc */ #include &lt;string&gt; #include &lt;vector&gt; #include "consts.h" #include "solid_type.h" using namespace std; struct dimension { bool exists; float value; }; class Solid{ public: string name; // So the user can look at the log string comment; // Expanded version of name, again for the log solid_type type; // Determines the type of Solid bool positive; // Positive = addition; negative = subtraction dimension dim1; // Radius, width, or side length dimension dim2; // Height, number of sides, or fraction of sphere_over_n dimension dim3; // Width - only for prism_rect, pyrm_rect and tprym_rect Solid(){ count++; } Solid(bool setPos){ count++; positive = setPos; } Solid (string setName, string setComment, solid_type setType, bool setPos, dimension setDim1, dimension setDim2, dimension setDim3){ count++; name = setName; comment = setComment; type = setType; positive = setPos; dim1 = setDim1; dim2 = setDim2; dim3 = setDim3; } ~Solid(){ count--; } int howMany(){ return count; } int countSolids(){ return howMany(); } private: static int count; // Number of Solids in existence }; class Building { private: string name; vector &lt;Solid&gt; components; public: Building (string text){ setName(text); } void setName(string text) { name = text; } string getName(){ return name; } vector &lt;Solid&gt; addComponent(Solid component){ components.push_back(component); return components; } }; </code></pre> <p>My complete code is available at <a href="http://bit.ly/kXMKVy" rel="nofollow">FileDropper</a>, although I know most people won't want to unpack a zip, so I put the relevant ones above. Any help would be greatly appreciated!</p> <p>Running Eclipse Helios with G++ 4.2.1 on Mac OS X Snow Leopard 10.6.7.</p> <hr> <p>The complete linking command is:</p> <pre><code>g++ -o "BuildingGenerator" ./src/bgmath.o ./src/building.o ./src/customio.o \ ./src/filedaemon.o ./src/log.o ./src/main.o ./src/ui.o ./src/vsystem.o </code></pre> <p>So it looks like it is linking all the necessary files. Also, the (header) files are all <code>#include</code>'d where needed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload