link time error

This is a discussion on link time error within the C++ Programming forums, part of the General Programming Boards category; I get the following link time errors from mvs, any ideas what i have done wrong? LIBCD.lib(crt0.obj) : error LNK2001: ...

  1. #1
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72

    link time error

    I get the following link time errors from mvs, any ideas what i have done wrong?

    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/BasicTemplateListTest.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    BasicTemplateListTest.exe - 2 error(s), 0 warning(s)

  2. #2
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72

    Unhappy

    i do have a main() though

  3. #3
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72
    hmm i've done that and it compiles, its just when i come to build it shoots the errors at me. maybe some code will help?

    Code:
     
    #include "TestTemplateNodes.h"
    
    template <class N>
    int main()
    {
    CTemplateList<N> test;
    
    TestNodes(test);
    	
    return 0;
    }
    is it ok to set main as a template?

  4. #4
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Maybe the problem is that an instance of the function has not been instantiated. A template is just an outline for code that is suppossed to get filled in or completed as needed depending on how it gets called. As it stands now, the code provided is simply the framework, its likely that no actual code yet exists for the function which is why main can't be found. Might be interesting to see if this would work if you actually made a main function call with a particular type supplied for the CTemplateList object so that the function could be instantiated and thus found by the linker. But... it would be best to not have main as a templated function I'm guessing.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  5. #5
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72
    hmm its just when i take away the template line, i get like 52 errors, all blabbing on about:
    error C2662: 'push_front' : cannot convert 'this' pointer from 'class CTemplateList' to 'class CTemplateList<T> &'
    Reason: cannot convert from 'class CTemplateList' to 'class CTemplateList<T>'
    Conversion requires a second user-defined-conversion operator or constructor

    Unless my understanding of templates is wrong, are these acceptable templates?

    Code:
    template <class T>
    class CTemplateNode
    {
    public:
    CTemplateNode() : m_pPrev(0), m_pNext(0), m_iIndex(0) {}
    CTemplateNode<T> value() const {return m_tType;}
    void value(const T& n) {m_tType = n;}
    int index() const {return m_iIndex;}
    
    CTemplateNode<T> *m_pPrev, *m_pNext, m_tType;
    int m_iInt, m_iIndex;
    };
    Code:
    template <class T>
    class CTemplateList
    {
    public:
    CTemplateList() : m_pNHead(0), m_pNTail(0), m_pNCurrent(0), m_iLSize(0) {}
    ~CTemplateList() {if(m_pNHead) clear();}
    
    int size() const {return m_iLSize;}
    bool empty();
    void clear();
    void assign(int n, int e);
    void operator=(const CTemplateList<T>& list);
    CTemplateNode<T>* front() {return m_pNHead;}
    CTemplateNode<T>* back() {return m_pNTail;}
    void push_front(const T& e);
    void pop_front() {remove(m_pNHead);}
    void push_back(const T& e);
    void pop_back() {remove(m_pNTail);}
    CTemplateNode<T>* inserte(int iter, int e) {return(search(iter));}
    CTemplateNode<T>* erase(int iter) {remove(search(iter)); return m_pNCurrent = m_pNCurrent->m_pNext;} 
    void removee(CTemplateNode<T> e);
    
    void index();
    void remove(CTemplateNode<T> *node);
    void insert(const T& e, CTemplateNode<T> *node);
    void reset() {m_pNCurrent=m_pNHead;}
    CTemplateNode<T>* getcurrent() {return m_pNCurrent;}
    CTemplateNode<T>* search(const T& e);
    CTemplateNode<T>* search_index(const T& e);
    CTemplateNode<T>* next();
    CTemplateNode<T>* prev();
    
    protected:
    CTemplateNode<T> *m_pNHead, *m_pNTail, *m_pNCurrent, m_tType;
    int m_iLSize;
    };
    Last edited by gazsux; 01-08-2003 at 01:28 PM.

  6. #6
    Registered User gazsux's Avatar
    Join Date
    Mar 2002
    Posts
    72
    booya! silly old me forgot to give the template a type... ty for all your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21