my code compiles fine but i get this error upon build. i understand that something is out of whack with the symbol defs, but ive gone over and over them and from what i see, they are all defined correctly and have the correct references so im thinking maybe its a problem with the way ive put the header and implementation together, but idk. help please, please dont shut it down just because the question has been asked, i didnt get any help from other answers to other questions.
/bin/sh -c '/usr/bin/make -j4 -e -f Makefile'
----------Building project:[ AreaComp - Debug ]----------
/usr/bin/g++ -o ./Debug/AreaComp @"AreaComp.txt" -L.
Undefined symbols for architecture x86_64:
"compute::Area::compSq()", referenced from:
_main in Areamain.cpp.o
"compute::Area::compHex()", referenced from:
_main in Areamain.cpp.o
"compute::Area::compOct()", referenced from:
_main in Areamain.cpp.o
"compute::Area::compTri()", referenced from:
_main in Areamain.cpp.o
"compute::Area::compHept()", referenced from:
_main in Areamain.cpp.o
"compute::Area::compPent()", referenced from:
_main in Areamain.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Debug/AreaComp] Error 1
make: *** [All] Error 2
====1 errors, 0 warnings====
here's the header file:
#ifndef MAIN_SAVITCH_COMPUTE_H
#define MAIN_SAVITCH_COMPUTE_H
namespace compute
{
class Area
{
public:
void compTri();
void compSq();
void compPent();
void compHex();
void compHept();
void compOct();
private:
double area;
};
}
#endif
Here's Implementation (tried as .cxx and .cpp....no change):
#include <iostream>
#include <cmath>
#include <cassert>
#include "Area.h"
namespace compute
{
double i;
void Area::compTri()
{
for(i = 1.00; i < 6.00; i++)
{
area = (1.00/2.00)i*((pow((-(1/2)i), 2.00)+pow(i,2.00)));
cout<< "area for triangle of side length"<< i << "=" << area << endl;
}
}
void Area::compSq()
{
for(i = 1.00; i < 6.00; i++)
{
area = 2.00*i;
cout << "area for square of side length" << i << "=" << area << endl;
}
}
void Area::compPent()
{
for(i = 1.00; i < 6.00; i++)
{
area = (1.00/4.00)*sqrt(5.00*(5.00 + 2.00*sqrt(5.00)))*pow(i,2.00);
cout << "area for pentagon of side length" << i << "=" << area << endl;
}
}
void Area::compHex()
{
for(i = 1.00; i < 6.00; i++)
{
area = ((3.00*sqrt(3.00))/2.00)*pow(i,2.00);
cout << "area for hexagon of side length" << i << "=" << area << endl;
}
}
void Area::compHept()
{
for(i = 1.00; i < 6.00; i++)
{
area = (7.00/4.00)*pow(i,2.00)*(1.00/tan(180.00/7.00));
cout << "area for heptagon of side length" << i << "=" << area << endl;
}
}
void Area::compOct()
{
for(i = 1.00; i < 6.00; i++)
{
area = 2.00*(1.00+sqrt(2.00))*pow(i,2.00);
cout << "area for octagon of side length" << i << "=" << area << endl;
}
}
}
here's the main file:
#include <iostream>
#include <cassert>
#include <cmath>
#include "Area.h"
using namespace std;
using namespace compute;
int main(int argc, char **argv)
{
int a;
cout <<"this program will compute the area of a polygon with between 3 & 8"<< endl;
cout << "how many sides does your polygon have?" << endl;
cin >> a;
assert(a >= 3 && a <= 8);
Area find;
if(a == 3)
{
find.compTri();
}
else if(a == 4)
{
find.compSq();
}
else if(a == 5)
{
find.compPent();
}
else if(a == 6)
{
find.compHex();
}
else if(a == 7)
{
find.compHept();
}
else
{
find.compOct();
}
return 0;
};
make file:
##
## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased
##
## Debug
ProjectName :=AreaComp
ConfigurationName :=Debug
WorkspacePath := "/Users/tuckerfowler/Documents/CS3304"
ProjectPath := "/Users/tuckerfowler/Documents/CS3304 /AreaComp"
IntermediateDirectory :=./Debug
OutDir := $(IntermediateDirectory)
CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Tucker Fowler
Date :=18/01/2016
CodeLitePath :="/Users/tuckerfowler/Library/Application Support/codelite"
LinkerName :=/usr/bin/g++
SharedObjectLinkerName :=/usr/bin/g++ -dynamiclib -fPIC
ObjectSuffix :=.o
DependSuffix :=.o.d
PreprocessSuffix :=.i
DebugSwitch :=-g
IncludeSwitch :=-I
LibrarySwitch :=-l
OutputSwitch :=-o
LibraryPathSwitch :=-L
PreprocessorSwitch :=-D
SourceSwitch :=-c
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
Preprocessors :=
ObjectSwitch :=-o
ArchiveOutputSwitch :=
PreprocessOnlySwitch :=-E
ObjectsFileList :="AreaComp.txt"
PCHCompileFlags :=
MakeDirCommand :=mkdir -p
LinkOptions :=
IncludePath := $(IncludeSwitch). $(IncludeSwitch).
IncludePCH :=
RcIncludePath :=
Libs :=
ArLibs :=
LibPath := $(LibraryPathSwitch).
##
## Common variables
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
##
AR := /usr/bin/ar rcu
CXX := /usr/bin/g++
CC := /usr/bin/gcc
CXXFLAGS := -g -O0 -Wall $(Preprocessors)
CFLAGS := -g -O0 -Wall $(Preprocessors)
ASFLAGS :=
AS := /usr/bin/as
##
## User defined environment variables
##
CodeLiteDir:=/Users/tuckerfowler/Downloads/codelite.app/Contents/SharedSupport/
Objects0=$(IntermediateDirectory)/main.cpp$(ObjectSuffix)
Objects=$(Objects0)
##
## Main Build Targets
##
.PHONY: all clean PreBuild PrePreBuild PostBuild MakeIntermediateDirs
all: $(OutputFile)
$(OutputFile): $(IntermediateDirectory)/.d
$(Objects)
@$(MakeDirCommand) $(@D)@echo "" > $(IntermediateDirectory)/.d
@echo $(Objects0) > $(ObjectsFileList)
$(LinkerName)
$(OutputSwitch)
$(OutputFile)
@$(ObjectsFileList)
$(LibPath)
$(Libs)
$(LinkOptions)
MakeIntermediateDirs:
@test -d ./Debug || $(MakeDirCommand) ./Debug
$(IntermediateDirectory)/.d:
@test -d ./Debug || $(MakeDirCommand) ./Debug
PreBuild:
##
## Objects
##
$(IntermediateDirectory)/main.cpp
$(ObjectSuffix):main.cpp
$(IntermediateDirectory)/main.cpp
$(DependSuffix)
$(CXX)
$(IncludePCH)
$(SourceSwitch) "/Users/tuckerfowler/Documents/CS3304/AreaComp/main.cpp"
$(CXXFLAGS)
$(ObjectSwitch)
$(IntermediateDirectory)/main.cpp
$(ObjectSuffix)
$(IncludePath)
$(IntermediateDirectory)/main.cpp
$(DependSuffix): main.cpp
@$(CXX)
$(CXXFLAGS)
$(IncludePCH)
$(IncludePath)-MG-MP-MT
$(IntermediateDirectory)/main.cpp
$(ObjectSuffix) -MF
$(IntermediateDirectory)/main.cpp
$(DependSuffix) -MM "main.cpp"
$(IntermediateDirectory)/main.cpp
$(PreprocessSuffix): main.cpp
@$(CXX)
$(CXXFLAGS)
$(IncludePCH)
$(IncludePath)
$(PreprocessOnlySwitch)
$(OutputSwitch)
$(IntermediateDirectory)/main.cpp
$(PreprocessSuffix) "main.cpp"
-include $(IntermediateDirectory)/*$(DependSuffix)
##
## Clean
##
clean:
$(RM) -r ./Debug/