Thread: error LNK2019: unresolved external symbol

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    error LNK2019: unresolved external symbol

    Pretty new to C++ and even newer to Visual 2010 but basically I'm getting this linker error
    Code:
     error LNK2019: unresolved external symbol "public: int __thiscall wav::OpenReadEx(char *,int)" (?OpenReadEx@Cwav@@QAEHPADH@Z) referenced in function _wmain
    and my test code is basic its like

    Code:
    #include "stdafx.h"
    #include "wav.h"
    wav g_wav;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	int i;
    	i=3;
    	i = g_wav.OpenReadEx("Pink_Noise_Loop",1);
    	return 0;
    }
    So im thinking its just the makefile that can't link to the wav.h where the OpenReadEx function is being called from. Okay also in visual ive opened 2 projects one project is test2. and the second is sourceCode. and in the properities of C/C++ i put in the include the directory where the sourceCode is . And sourceCode holds wav.h and wav.cpp so iono why is still having this linker problem

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    The linking is done to a lib file, not an include file. Make sure you include the sourceCode lib file and directory in the project settings' linker options.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    So i checked the sourceCode directory and There isnt a .lib file in there? how do u create it then or does visual suppose to have it created

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    If that's your own code, you have to build that project and create a lib file. If that's a project from somewhere else, then it would probably come with a lib file.

    If that's your code, is there a reason you are separating it into its own project? The simple solution would be to put into the same project as your test and then it will be compiled and linked together. If you want to keep it as a separate project, then you just need to make sure the sourceCode project is set up to output a lib file when you build it. It will be placed in the Debug (or Release) directory by default.

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    its someone elses seperate code that im trying to use or just use a few functions so i check the debug file and theres isnt a .lib file and i already rebuild it again so how do u set the project to output a .lib file

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    What does that project output when it is built? (And what version of VC++ are you using?)

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Daved View Post
    (And what version of VC++ are you using?)
    2010, as stated in the first post.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #8
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    Sorry i found the .lib file it was under my original project test2/debug dont really understand y it was there instead of sourceCode/debug but it compiled thanks

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, 03: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, 02:28 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM