Unresolved External? Help!

This is a discussion on Unresolved External? Help! within the C++ Programming forums, part of the General Programming Boards category; I'm getting the following error when compiling my program: (Visual Studio Error): 1>tictac.obj : error LNK2019: unresolved external symbol "protected: ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    167

    Unresolved External? Help!

    I'm getting the following error when compiling my program:

    (Visual Studio Error):

    1>tictac.obj : error LNK2019: unresolved external symbol "protected: void __thiscall BasList::remove_node(class ListNode *,int,int)" (?remove_node@BasList@@IAEXPAVListNode@@HH@Z) referenced in function "public: void __thiscall BasList::remove_head(int,int)" (?remove_head@BasList@@QAEXHH@Z)

    (And here it is in GCC, in case that helps too):

    /tmp/ccYrl06E.o: In function `BasList::remove_head(int, int)':
    tictac.cpp.text._ZN7BasList11remove_headEii[BasList::remove_head(int, int)]+0x25): undefined reference to `BasList::remove_node(ListNode*, int, int)'

    Bahhh, why doesn't it give a line number. I don't know what it's referring to since I don't see those functions linked in my main anywhere.

    How do I find out where the error is?? Can't double click it =\

    ----------


    If you want to check out the source code, all I'm trying to do is compile this tic tac toe game: http://www.cs.ucsb.edu/~cs165a/Softw...imaxGuide.html

    (All code is downloadable via the "AI Library" zip file http://www.cs.ucsb.edu/~cs165a/software.html )

    In the zip file, the only files I'm using are tictac.h, tictac.cpp, minimax.h, xlist.h, and blist.h. Try to compile and you'll get a bunch of linker errors

    Anyone have any ideas?
    Last edited by Paul22000; 10-28-2008 at 11:08 AM.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,794
    Quote Originally Posted by Paul22000 View Post
    In the zip file, the only files I'm using are tictac.h, tictac.cpp, minimax.h, xlist.h, and blist.h. Try to compile and you'll get a bunch of linker errors

    Anyone have any ideas??
    Yes, you need to add another source file(s) to your project. At the very least, blist.cpp would appear to be needed as well.
    "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

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by hk_mp5kpdw View Post
    Yes, you need to add another source file(s) to your project. At the very least, blist.cpp would appear to be needed as well.
    Why? All the code for the b lists are in blist.h?

    Should I just make a blank file blist.cpp? I don't think that would get rid of the linker errors though. If you tried it, were you able to get tictactoe to compile?

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    It looks like blist does have a source file:
    Code:
    $ find -name 'blist*'
    ./AILibNix/include/blist.h
    ./AILibNix/util/blist.cc
    $
    I'd compile with it if I were you.

    The methods that don't have a body (in curly braces) in blist.h need to be found elsewhere, and hopefully blist.cc gives you them.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by dwks View Post
    It looks like blist does have a source file:
    Code:
    $ find -name 'blist*'
    ./AILibNix/include/blist.h
    ./AILibNix/util/blist.cc
    $
    I'd compile with it if I were you.

    The methods that don't have a body (in curly braces) in blist.h need to be found elsewhere, and hopefully blist.cc gives you them.
    Wow.

    Wow.

    Haha.

    Why didn't I do a windows search for the files!

    Thank you!!!!!

    While we're here, what do you think about this warning:

    tictac.cpp(235) : warning C4996: 'gets': This function or variable may be unsafe. Consider using gets_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    While we're here, what do you think about this warning:
    gets() is the most poorly designed function in the entire C runtime library. Avoid it like the plague.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by CornedBee View Post
    gets() is the most poorly designed function in the entire C runtime library. Avoid it like the plague.
    Is there something better to replace it with than get_s?

  8. #8
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    Quote Originally Posted by Paul22000 View Post
    Bahhh, why doesn't it give a line number. I don't know what it's referring to since I don't see those functions linked in my main anywhere.
    It isn't giving a line number because it's a LINKER error, not a COMPILER error. Having said that, building in debug mode will often allow the linker to report an exact line number, but not all linkers will do that. You might try it at least.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul22000 View Post
    Is there something better to replace it with than get_s?
    fgets(buffer, size, file) will do the essentially the same thing as gets, but safely if you give it stdin as the last argument, and the size of the buffer as the middle argument. The main difference is that the newline ('\n') corresponding to the enter-key is in the buffer, so you may need to remove that. If there is no newline at the end of the input you received, the input was longer than your buffer, and you would want to call fgets() or getchar() repeatedly until you get a newline.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by brewbuck View Post
    It isn't giving a line number because it's a LINKER error, not a COMPILER error. Having said that, building in debug mode will often allow the linker to report an exact line number, but not all linkers will do that. You might try it at least.
    Does anyone know how to do this in Visual Studio? I'm sure this knowledge will come in handy for the future!

    (I'm using VS Express 2008 9.0)

  11. #11
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    When you create a new project, it compiles in debug mode by default. So apparently the linker just isn't smart enough.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #12
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by CornedBee View Post
    When you create a new project, it compiles in debug mode by default. So apparently the linker just isn't smart enough.
    Damn. Yeah, even tried on Linux with gcc. That's too bad.

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by matsp View Post
    fgets(buffer, size, file) will do the essentially the same thing as gets, but safely if you give it stdin as the last argument, and the size of the buffer as the middle argument. The main difference is that the newline ('\n') corresponding to the enter-key is in the buffer, so you may need to remove that. If there is no newline at the end of the input you received, the input was longer than your buffer, and you would want to call fgets() or getchar() repeatedly until you get a newline.

    --
    Mats
    My buffer is: char answer[80]

    So like this?

    fgets(answer, 80, stdin);

    Seems to compile and work. Just want to make sure. Thanks for the tip!

  14. #14
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Sure, that works. You could make it a little more maintainable with
    Code:
    fgets(answer, sizeof answer, stdin);
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  15. #15
    Registered User
    Join Date
    Apr 2008
    Posts
    167
    Quote Originally Posted by dwks View Post
    Sure, that works. You could make it a little more maintainable with
    Code:
    fgets(answer, sizeof answer, stdin);
    Ahh! Good thinking!

Page 1 of 2 12 LastLast
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. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  4. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 02:01 PM
  5. Unresolved external symbols in OGL
    By Shadow12345 in forum Game Programming
    Replies: 4
    Last Post: 08-04-2002, 09:46 PM

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