Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:19:08+00:00 2026-06-02T22:19:08+00:00

I just resumed back to working with C++ after a long time. I am

  • 0

I just resumed back to working with C++ after a long time. I am using Eclipse on Macbook Pro, and I tried just making a small project of Linked Lists.

I have been getting this error when I try compile my project:
ld: symbol(s) not found for architecture x86_64

This happens only if I #include "SingleLinkedList.h" in my main.cpp and do operations related to SingleLinkedist, otherwise removing the above SingleLinkedList in main, the project compiles fines. I have been looking similar questions on SO with same error, but none seem to have helped me resolve this.

Here are the class files if needed:
As far as I remember, earlier everything in the same way used to work fine on Eclipse. I just upgraded to Lion some time back, and installed the new Xcode and a new Eclispe, and now been facing weird issues instead of concentrating on coding.

SingleLinkedList.cpp

#include "SingleLinkedList.h"

template<class T>
SingleLinkedList<T>::~SingleLinkedList()
{
    Node<T> *temp = head;
    while(head!=0)
    {
        temp = head;
        head = temp->next;
        delete temp;
    }
}

template <class T>
void SingleLinkedList<T>::addToHead(int item)
{
    head = new Node<T>(item, head);
    if (tail==0)
        tail = head;
}

template <class T>
void SingleLinkedList<T>::addToTail(int item)
{
    if(tail!=0)
    {
    tail->next = new Node<T>(item);
    tail = tail->next;
    }
    else
        head = tail = new Node<T>(item);
}

template <class T>
int SingleLinkedList<T>::deletefromHead()
{
    int e1 = head->info;
    Node<T> *temp = head;
    if(head ==tail)
    {
    head = tail = 0;
    }
    else
        head = temp->next;
    delete temp;
    return e1;
}

template <class T>
int SingleLinkedList<T>::deletefromTail()
{
    int e1 = tail->info;
    if(head == tail)
    {
        delete head;
        head = tail = 0;
    }
    else{
        Node<T> *temp = head;
        while(temp->next != tail)
            temp = temp->next;
        delete tail;
        tail = temp;
        tail->next = 0;
    }
    return e1;
}

template <class T>
void SingleLinkedList<T>::deleteNode(int item)
{
    if(head!=0) {
        if(head == tail && head->info){ //If this is the only item in the linked list
            delete head;
            head = tail = 0;
        }
        else if (item == head->info){
            Node<T> *temp = head;
            head = temp->next;
            delete temp;
        }
        else{
            Node<T> *temp = head;
            while(temp->next->info != item && temp->next !=0 ){
                temp = temp->next;
            }
            if(temp!=0){
                temp->next = temp->next->next;
                temp = temp->next;
                delete temp;
            }
        }
    }
}

template <class T>
bool SingleLinkedList<T>::isEmpty()
{
    return head == 0;
}

template <class T>
bool SingleLinkedList<T>::isInList(int item)const
{
    Node<T> * temp = head;
    while(temp!=0)
    {
        if(temp->info == item){
            break;
        }
        temp = temp->next;
    }
    return temp->info == item;
}

template<class T>
SingleLinkedList<T>::SingleLinkedList()
{
    head = tail = 0;
}

SingleLinkedList.h

#include "Node.h"

#ifndef SINGLELINKEDLIST_H_
#define SINGLELINKEDLIST_H_

template <class T>
class SingleLinkedList {
public:
    SingleLinkedList();
    ~SingleLinkedList();

    bool isEmpty();
    bool isInList(int)const;

    void addToHead(int);
    void addToTail(int);
    int deletefromHead();
    int deletefromTail();
    void deleteNode(int);
private:
    Node<T> *head;
    Node<T> *tail;
};
#endif /* SINGLELINKEDLIST_H_ */

main.cpp

 #include <iostream>
#include "SingleLinkedList.h"
using namespace std;
int main() {
    SingleLinkedList<int> listfile;
    listfile.addToHead(2);
    listfile.addToHead(4);
    listfile.addToHead(6);
    listfile.addToHead(8);
    listfile.addToHead(10);
return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:19:09+00:00Added an answer on June 2, 2026 at 10:19 pm

    Actually, the reason this isn’t working is because you don’t define header files for template classes, with separate implementation, because templates dont have an implementation other than what the compiler generates. So it’s incorrect c++ to have the .cpp file. Put it all inline or keep it in the header only. see the following at the very bottom

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just switched over from eclipse to vs 2008 for debugging javascript, i feel more
Just wanted to know if anyone is really using Objects and Collections in Oracle
I am working around a problem in Ubuntu 10.04 where after resume, the mouse
Hello I am just a little confused after reading these materials on Tasks and
How do we resume a download after the user quits the app, not just
I'm working on a delphi api for Google docs and having a hard time
Just wondering how I can make my app open automatically at login, but make
Just wondering if the following is considered to be good programming practice or not?
Just to make sure I'm understanding shallow copies of reference types correctly and that
Just trying to get diff to work better for certain kinds of documents. With

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.