What does the “undefined reference to varName” in C mean?

后端 未结 6 1585
粉色の甜心
粉色の甜心 2020-12-01 18:32

I have 2 files: a.c and b.c

In a.c I am sending a signal to a function located in b.c

signal(SIGU         


        
6条回答
  •  情歌与酒
    2020-12-01 19:03

    You're getting a linker error, so your extern is working (the compiler compiled a.c without a problem), but when it went to link the object files together at the end it couldn't resolve your extern -- void doSomething(int); wasn't actually found anywhere. Did you mess up the extern? Make sure there's actually a doSomething defined in b.c that takes an int and returns void, and make sure you remembered to include b.c in your file list (i.e. you're doing something like gcc a.c b.c, not just gcc a.c)

提交回复
热议问题