Error with linked list program

Hi there everyone.

I'm very new to C++, only a few days, but I have some experience with other languages. Currently I am building a program for a class that creates a circular linked list and repeatedly "kills" every other member of the list by removing them. This continues until the only member of the linked list points to itself, revealing the winner of the deathathon.

Previously I have used Java and Actionscript, so I had to teach myself pointers for C++. I may have gotten something incredibly simple wrong with my program, but upon compiling, it returns this error:

[Linker error] undefined reference to `__dyn_tls_init_callback'
[Linker error] undefined reference to `__cpu_features_init'
ld returned 1 exit status

I will paste my code below. I googled these errors for a while, but could not seem to find the origin of the problem. Can someone please tell me where I went wrong in my program? Thanks!

Code:
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
#include <iostream>
using namespace std;

class Node {
      private:
              string name;
              Node* next;
      public:
             Node* getNext();
             void setNext(Node* node);
             string getName();
             Node::Node(string enteredName);
                               
};

Node* Node::getNext(){
    return next;
}

void Node::setNext(Node* node){
    next = node;
}

string Node::getName(){
    return name;
}
Node::Node(string enteredName){
    name = enteredName;
}

int main(){
    int number;
    cin >> number;
    string root_name;
    cin >> root_name;
    Node* head = new Node(root_name);
    Node* current = head;
    
    for(int i = 0; i < number-1; i++){
            string name;
            cin >> name;
            Node* temp = new Node(name);
            current->setNext(temp);
            current = temp;
            if(i == number - 2){
                 temp->setNext(head);
            }
    }
    
    current = head;
    while(current->getNext() != current){
        cout << current->getName() << " kills " << current->getNext()->getName();
        current->setNext(current->getNext()->getNext());
        current = current->getNext();
    }
    cout << current->getName() << " lives!";
}
You don't include <string>, you don't return 0, you don't have anything to stop the program from closing when it ends (for example, cin.ignore().get(); ).
Besides that I really don't know what could be wrong. It compiled and worked nicely for me. There could be something wrong with your compiler settings.
Thanks for the tips, I totally forget that main is supposed to return an int...

I'm still getting the error after all the fixes, I'm not sure what the problem is. We're supposed to submit the problem on a unix system, so I'll try compiling and running it on there, but it would be nice to fix the problem locally as well.
Topic archived. No new replies allowed.