LNK2019 Error under Visual Studio 2010

后端 未结 4 1374
傲寒
傲寒 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:11

    I think what happened is that A.h was in the Source group of the project rather than the Header group, so it was compiled as if it were a .cpp. Since both A.cpp and A.h will generate an object file A.obj, the last one to compile is the only one that got linked. I believe the last one compiled was A.h, which didn't have an implementation of foo(), thus the linker couldn't find it.

提交回复
热议问题