none
LNK2019 Error, Works fine in cmd, but not visual studio

    Question

  • Hello.

    I'm getting this error. I've looked online and it says this happens when something is declared but not defined, however I don't see any issues like that. The most annoying part is that it compiles fine in cmd. I'm not sure why Visual Studio 2013 is giving me issues

    Errors

    Error	1	
    
    error LNK2019: unresolved external symbol "public: __thiscall Shader::Shader(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Shader@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main	
    
    Error	2	
    
    error LNK2019: unresolved external symbol "public: virtual __thiscall Shader::~Shader(void)" (??1Shader@@UAE@XZ) referenced in function _main	
    
    Error	3	
    
    error LNK1120: 2 unresolved externals	

    main.cpp

    #include <iostream>
    #include "shader.h"
    
    
    int main(int argc, char** argv)
    {	
    	Shader shader("./res/basicShader");
    
    	return 0;
    }

    shader.h

    #ifndef SHADER_H
    #define SHADER_H
    
    #include <string>
    
    class Shader
    {
    	public:
    		Shader(const std::string& fileName);
    
    		virtual ~Shader();
    	protected:
    	private:
    };
    
    #endif //SHADER_H 

    shader.cpp

    #include "shader.h"
    #include <iostream>
    #include <fstream>
    #include <string>
    
    Shader::Shader(const std::string& fileName)
    {
    	
    }
    
    Shader::~Shader()
    { 
    
    }
    


    Wednesday, January 07, 2015 10:37 PM

Answers

  • Hi Arend Peter,

    Since this forum is to discuss the VS IDE usage, based on your description, it would be the VC++ development issue, to help you resolve this issue as soon as possible, I suggest you post this issue to the VC++ language development forum, I think you would get dedicated support there.

    The VC++ forum link:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vcgeneral

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 12, 2015 3:11 AM