#1
  1. <!--REMOTE_ADDR-->
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Cali4nia
    Posts
    162
    Rep Power
    12

    error on building a program in MS Visual Studio 6.0


    Hi,
    I am trying to build a sorted link list program, I have a specification file, an implementaion file and a driver file.

    The prog. compiles without any error or warning but when i try to run / build it, i get the following errors, I am not sure if u need the code too, if yes then i can post it too.

    Thnx for Help!!

    -----------------errors-------------------------


    --------------------Configuration: sortedlist - Win32 Debug--------------------
    Linking...
    driver.obj : error LNK2001: unresolved external symbol "public: __thiscall SortedType<int>::~SortedType<int>(void)" (??1?$SortedType@H@@QAE@XZ)
    driver.obj : error LNK2001: unresolved external symbol "public: void __thiscall SortedType<int>::MakeEmpty(void)" (?MakeEmpty@?$SortedType@H@@QAEXXZ)
    driver.obj : error LNK2001: unresolved external symbol "public: void __thiscall SortedType<int>::RetrieveItem(int &,bool &)" (?RetrieveItem@?$SortedType@H@@QAEXAAHAA_N@Z)
    driver.obj : error LNK2001: unresolved external symbol "public: void __thiscall SortedType<int>::DeleteItem(int)" (?DeleteItem@?$SortedType@H@@QAEXH@Z)
    driver.obj : error LNK2001: unresolved external symbol "public: int __thiscall SortedType<int>::LengthIs(void)const " (?LengthIs@?$SortedType@H@@QBEHXZ)
    driver.obj : error LNK2001: unresolved external symbol "public: void __thiscall SortedType<int>::InsertItem(int)" (?InsertItem@?$SortedType@H@@QAEXH@Z)
    driver.obj : error LNK2001: unresolved external symbol "public: __thiscall SortedType<int>::SortedType<int>(void)" (??0?$SortedType@H@@QAE@XZ)
    Debug/sortedlist.exe : fatal error LNK1120: 7 unresolved externals
    Error executing link.exe.

    sortedlist.exe - 8 error(s), 0 warning(s)
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    10
    Rep Power
    0
    Hmm...
    you might want to check if all the required files are included correctly.
    Did you remember to include the header file in your .cpp file?
    e.g.
    i have myclass.cpp and myclass.h for my implementation and class declaration respectively.
    Forgeting to add #include "myclass.h" at the top of myclass.cpp would cause errors.

    Another would be if you didn't add the cpp file to your project.
    e.g.
    under main.cpp i say #include "myclass.h"
    but i didn't remember to add the file myclass.cpp to the project. That would give errors too.
  4. #3
  5. <!--REMOTE_ADDR-->
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Cali4nia
    Posts
    162
    Rep Power
    12
    yes i have included it, if that was the case then it would have pointed it out while compiling, here is a link to the similar problem, but i couldnt figure out the answer...as i did what is told here.

    http://www.experts-exchange.com/Prog..._10764361.html

    Thnx for reply
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    10
    Rep Power
    0
    The link is a different problem.
    "Linking...
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/VwBlktoVst.exe : fatal error LNK1120: 2 unresolved externals"

    is a problem to do with Visual C++ compiler option which can be solved by doing the following:
    project->settings
    Then select "C/C++"
    For "Category" choose "Code Generation"
    Then for "use run time library" select "debug multi threaded".

    Your problem seems different. I think you are trying to use template?
    Is your template declaration and implementation all in a single .h file?
    If so did you use any
    #ifndef MYCLASS_H
    #define MYCLASS_H

    #endif

    don't add the above statements for template class.

    Err...thats all i can think of.
  8. #5
  9. <!--REMOTE_ADDR-->
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Cali4nia
    Posts
    162
    Rep Power
    12
    yes am using templates and my decleration and implementaions are in 2 seperate files. i dont understand y am i getting these errors
    neways thanx a lot for ur help
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    10
    Rep Power
    0
    For template type classes you should keep your declaration and implementation in a single file.
    e.g.
    //myclass.h

    template<T>
    myclass
    {
    //some data and functions
    public:
    void myfunction();
    };

    //implementation:
    void myclass::myfunction()
    {

    }

    Heres a tutorial for you to have a look at:
    http://babbage.cs.qc.edu/STL_Docs/templates.htm
  12. #7
  13. <!--REMOTE_ADDR-->
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Cali4nia
    Posts
    162
    Rep Power
    12
    thnx i got ur point it has eliminated the previous errors but now its giving me new errors like
    --------------------Configuration: driver - Win32 Debug--------------------
    Compiling...
    driver.cpp
    c:\documents and settings\compaq\desktop\temp\sortedlist.h(127) : error C2065: 'ItemTyepe' : undeclared identifier
    c:\program files\microsoft visual studio\vc98\include\xstring(79) : while compiling class-template member function 'void __thiscall SortedType<int>::InsertItem(int)'
    c:\documents and settings\compaq\desktop\temp\sortedlist.h(131) : error C2440: '=' : cannot convert from 'struct NodeType<int> *' to 'struct NodeType *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    c:\program files\microsoft visual studio\vc98\include\xstring(79) : while compiling class-template member function 'void __thiscall SortedType<int>::InsertItem(int)'
    c:\documents and settings\compaq\desktop\temp\sortedlist.h(137) : fatal error C1903: unable to recover from previous error(s); stopping compilation
    c:\program files\microsoft visual studio\vc98\include\xstring(79) : while compiling class-template member function 'void __thiscall SortedType<int>::InsertItem(int)'
    Error executing cl.exe.

    driver.exe - 3 error(s), 0 warning(s)
  14. #8
  15. <!--REMOTE_ADDR-->
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Cali4nia
    Posts
    162
    Rep Power
    12
    lol nevermind forget it, itwas just a typo, thnx a lot 4 the help!!
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    10
    Rep Power
    0
    EDIT: OK nvm. You found the problem :)
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2001
    Posts
    1,481
    Rep Power
    15
    error C2065: 'ItemTyepe' : undeclared identifier

    That's a variable spelling error.
    -------------------
    error C2440: '=' : cannot convert from 'struct NodeType<int> *' to 'struct NodeType *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    That's a type problem. You are setting two things equal to each other that are different types. It looks like one is a pointer to a template and the other is a pointer to an object? Click on the error and it will take you to the line where the error is and check the types on both sides of the equals sign and make sure they are the same.
    Last edited by 7stud; August 21st, 2003 at 04:34 AM.

IMN logo majestic logo threadwatch logo seochat tools logo