LNK2019 Error under Visual Studio 2010

后端 未结 4 1230
傲寒
傲寒 2021-01-22 19:35

I have created a sample c++ project under Visual Studio 2010 with following files.

A.h

#ifndef A_H
#define A_H

#include 

void foo();

#         


        
4条回答
  •  借酒劲吻你
    2021-01-22 20:00

    First, you need to include "stdafx.h" in your "a.cpp" file before the line for including "a.h".

    Second, it is better you add "a.h" into your project "Header Files" and add "a.cpp" into your "Source Files".

    Then it will be compiled without error! Good luck.

    BTW, the reason to include "stdafx.h" is that by default the project use pre-compiled headers that is why the compiler looks for "stdafx.h".

    If you want, you can disable the "precompiled Header" then you don't need "stdafx.h" and everything will be fine.

提交回复
热议问题