compiling error

I am writing a program trying to convert distance measurements to meters. using c++.

error: Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
using two files.

first file:

/*
 * Lab         : distance.cpp
 *       : NAME HERE
 * Description : Implementation File for Distace Class
 */
// Include our .h file
#include "distance.h"

// Member Function Definitions
Distance::Distance() {
  meters_ = 0;
}
Distance::Distance(double meters) {
  set_meters(meters);
  if (meters_ < 0) {
  meters_ = 0;
}
}

Distance::Distance(double length, char unit) {
  SetDistance(length, unit);

  if (unit == 'E') {
    length = length;

  } else if (unit == 'K') {
    length = length * 1000;

  } else if (unit == 'C') {
    length = length / 100;

  } else if (unit == 'M') {
    length = length * 1609.344;


  } else if (unit == 'F') {
    length = length / 3.281;

  } else if (unit == 'I') {
    length = length / 39.37;

  } else if (unit == 'A') {
    length = length * 1.829;
  }
}
/*
 * Mutator
 * For now, just stub this function.
 */
void Distance::set_meters(double meters) {
  meters_ = meters;
}

/*
 * Accessor
 * For now, stub the function and have it return 0.
 */
double Distance::meters() {
  return meters_;
}

/*
 * Converts the supplied distance to meters and internally stores it.
 * For now, just stub this function
 */
void Distance::SetDistance(double length = 0, char unit = 'm') {

}

/*
 * Returns the internal distance converted based on the unit specified.
 * For now, stub the function and have it return 0.
 */
double Distance::GetDistance(char unit) {
  return 0;
}

/*
 * Outputs a representation of the distance.
 * For now, just stub the function
 */
void Distance::Output(char unit) {
  cout << "representation of the distance is: " << unit << endl;
}


second file:

*
 * Name        : distance.h
 * Author      : Luke Sathrum / YOUR NAME HERE
 * Description : DESCRIPTION GOES HERE
 * Sources     : SOURCES HERE
 */

// Opening Header Guards
#ifndef DISTANCE_H
#define DISTANCE_H

#include <iostream>
using std::cout;
using std::endl;

/*
 * Class Distance
 * A class that converts distances. It will always internally store in meters.
 */
class Distance {
 public:
  /*
   * Constructor #1
   * Sets meters_ to 0
   */
  Distance();

  /*
   * Constructor #2
   * Sets meters_ to the supplied value
   * HINT: You may just want to call the set_meters() mutator function.
   * @param double meters - The value to set the internal meters_ to. If the
   *                        distance is negative, set to 0.
   */
  Distance(double meters);

  /*
   * Constructor #3.
   * Converts the supplied distance to meters and internally stores it.
   * The distance's unit will be provided in the second parameter.
   * If the second parameter is not valid (i.e. not 'K', 'C', etc) assume the
   * distance is in meters.
   * HINT: You may want to just call the SetDistance() Function
   * @param double length - The value to set the internal meters_ to once
   *                        converted. If the distance is negative, set to 0.
   * @param char unit - The type of unit length is. Will be one of the following
   *                    case-insensitive:
   *                    'E' - Meters
   *                    'K' - Kilometers
   *                    'C' - Centimeters
   *                    'M' - Miles
   *                    'F' - Feet
   *                    'I' - Inches
   *                    'A' - Fathoms
   */
  Distance(double length, char unit);

  /*
   * Mutator
   * The distance will come in as meters and this function will set the
   * internal length to this value
   * @param double meters - The value to set the internal meters_ to. If the
   *                        distance is negative, set to 0.
   */
  void set_meters(double meters);

  /*
   * Accessor
   * Gets the internal distance in Meters.
   * @return double - The distance in Meters.
   */
  double meters();

  /*
   * Converts the supplied distance to meters and internally stores it.
   * The distance's unit will be provided in the second parameter.
   * If the second parameter is not valid (i.e. not 'K', 'C', etc) assume the
   * distance is in meters.
   * @param double length - The value to set the internal meters_ to once
   *                        converted. If the distance is negative, set to 0.
   * @param char unit - The type of unit length is. Will be one of the following
   *                    case-insensitive:
   *                    'E' - Meters
   *                    'K' - Kilometers
   *                    'C' - Centimeters
   *                    'M' - Miles
   *                    'F' - Feet
   *                    'I' - Inches
   *                    'A' - Fathoms
   */
  void SetDistance(double length, char unit);

  /*
   * Returns the internal distance converted based on the unit specified.
   * For example if the unit is 'K' it will convert meters -> kilometers and
   * return that value.
   * The distance's unit will be provided in the first parameter.
   * If the second parameter is not valid (i.e. not 'K', 'C', etc) assume they
   * want the distance in meters.
   * HINT: You may want to call the GetDistance() Function for the conversion
   * @param char unit - The type of unit length is. Will be one of the following
   *                    case-insensitive:
   *                    'E' - Meters
   *                    'K' - Kilometers
   *                    'C' - Centimeters
   *                    'M' - Miles
   *                    'F' - Feet
   *                    'I' - Inches
   *                    'A' - Fathoms
   * @return double - The converted distance.
   */
  double GetDistance(char unit);

  /*
   * Outputs a representation of the distance.
   * NOTE: There is NO newline character at the end of output.
   * The output will be formatted as:
   * "DISTANCE UNIT"
   * where DISTANCE is the distance to 2 decimal places and UNIT is one of the
   * following: "Meters", "Kilometers", "Centimeters", "Miles", "Feet",
   *            "Inches", or "Fathoms".
   * The conversion to perform is denoted by the parameter.
   * If the unit given through the argument is invalid, output: "Invalid Unit"
   * @param char unit - The conversion to perform. Will be one of the following
   *                    case-insensitive:
   *                    'E' - Meters
   *                    'K' - Kilometers
   *                    'C' - Centimeters
   *                    'M' - Miles
   *                    'F' - Feet
   *                    'I' - Inches
   *                    'A' - Fathoms
   */
  void Output(char unit = 'E');

 private:
  double meters_;
};


// Closing Header Guards
#endif /* DISTANCE_H */

any help would be appreciated. thank you
I think it's just saying that your program does not have a main() function.
Topic archived. No new replies allowed.