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

后端 未结 6 1600
粉色の甜心
粉色の甜心 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 18:59

    An initial reaction to this would be to ask and ensure that the two object files are being linked together. This is done at the compile stage by compiling both files at the same time:

    gcc -o programName a.c b.c
    

    Or if you want to compile separately, it would be:

    gcc -c a.c
    gcc -c b.c
    gcc -o programName a.o b.o
    

提交回复
热议问题