2

Could you help me figure out why I'm getting these 2019 Errors? I'm pretty sure all the files are saved in the correct places, and I think I'm using the correct conventions for header files? This is a lab for my systems programming class.

Here are the errors:

1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall DLL::intDLL::intDLL(void)" (??0intDLL@DLL@@QAE@XZ) referenced in function _main

1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall DLL::intDLL::~intDLL(void)" (??1intDLL@DLL@@QAE@XZ) referenced in function _main

1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall DLL::intDLL::addFront(int)" (?addFront@intDLL@DLL@@QAEXH@Z) referenced in function _main

1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall DLL::intDLL::getFront(void)" (?getFront@intDLL@DLL@@QAEHXZ) referenced in function _main

1>c:\users\josh\documents\visual studio 2012\Projects\Lab10\Debug\Lab10.exe : fatal error LNK1120: 4 unresolved externals

intDLL.h file:

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

class intDLL {

public:
    intDLL();
    intDLL(const intDLL &original);
    ~intDLL();
    void addFront(int inValue);
    void addBack(int inValue);
    void setBack();
    int getFront();
    int getBack();

    struct node {
        int value;
        node *next;
        node *prev;
    };

private:
    node *front;
    node *back;

};

intDLL.cpp

#include <iostream>
#include "intDLL.h"
using std::cout;
using std::endl;


intDLL::intDLL() {
    front = 0;
    back = 0;
}

void intDLL::setBack() {
    node *tempNode = new node;
    if(front == 0) {
        return;
    }

    tempNode = front;
    while(tempNode->back != 0) {
        tempNode = tempNode->prev;  
    }

    back = tempNode;
}

void intDLL::addFront(int inValue) {
    if(front == 0) {
        node *newFront = new node;
        newFront->value = inValue;
        newFront->next = 0;
        newFront->prev = 0;
    }
    else {
        node *newFront = new node;
        newFront->value = inValue;
        newFront->prev = front;
        front->next = newFront;
        newFront->next = 0;
        front = newFront;
    }

    setBack();
}

void intDLL::addBack(int inValue) {
    setBack();
    node *newBack = new node;
    newBack -> value = inValue;
    back->prev = newBack;
    newBack->next = back;
    back = newBack;
}

int intDLL::getFront() {
    return front->value;
}

int intDLL::getBack() {
    return back->value;
}

main:

#include <iostream>
#include "intDLL.h"
using std::cout;
using std::endl;

int main(int argc, char* argv[]) {
    intDLL test = intDLL();
    test.addFront(3);
    test.addFront(4);
    test.addFront(5);
    std::cout << test.getFront() << endl;

    return 0;
}
billz
  • 44,644
  • 9
  • 83
  • 100
josh
  • 21
  • 2
  • Please show the complete error messages. The only hint, I get from `LNK2019`, is it must be linker related. – Olaf Dietsche Feb 13 '13 at 00:27
  • Added the error messages. Why the downvote on my very first post? :( – josh Feb 13 '13 at 00:31
  • Because just outputting raw code and saying "i have an error message" isn't good. Removed downvote. But still you should add details like how you compile it – CharlesB Feb 13 '13 at 00:35

1 Answers1

0

Not sure what's the real error message, but seems like you haven't implemented a few functions, for sample

intDLL(const intDLL &original);
~intDLL();

Check your function definitions to make sure every functions declared are defined. Also make sure all cpp files are compiled and linked.

Another error is intDLL::node has no back member

void intDLL::setBack() {
    intDLL::node *tempNode = new node;
     ^^^^ node is defined in intDLL, you need provide scope
    if(front == 0) {
       return;
    }

  tempNode = front;
  while(tempNode->back != 0) {
                  ^^^ intDLL::node has no back member
    tempNode = tempNode->prev;  
   }

  back = tempNode;
}

See this SO link.

Community
  • 1
  • 1
billz
  • 44,644
  • 9
  • 83
  • 100
  • I commented out those unused functions that were declared in the header file (Hadn't gotten to writing them yet because of these errors), and got them same last 3 error messages. I assumed that when I do "start without debugging" in Visual Studio 2012 it compiled all the files in the project and did appropriate linking. Not the case? – josh Feb 13 '13 at 00:41