小编use*_*669的帖子

...未定义引用... collect2:ld返回1退出状态

编译时我遇到了一些错误,我无法弄清楚为什么......我的heapsort.h应该有导出类型吗?

heapsort.c

#include <stdio.h>        // standard libraries already included in "list.h"
#include <stdlib.h>

#include "heap.h"
#include "heapsort.h"

void heapSort(int* keys, int numKeys){
   heapHndl H = NULL;
   H = buildHeap(numKeys, keys, numKeys);
   for (int i = 1; i < numKeys; i++){
      keys[i] = maxValue(H);
      deleteMax(H);
   }
   freeHeap(&H);
}
Run Code Online (Sandbox Code Playgroud)

heapsort.h:

#ifndef _HEAPSORT_H_INCLUDE_
#define _HEAPSORT_H_INCLUDE_

#include <stdio.h>
#include <stdlib.h>

void heapSort(int* keys, int numKeys);

#endif
Run Code Online (Sandbox Code Playgroud)

当我使用我的客户端程序编译时,我在编译时遇到此错误:

HeapClient.o: In function `main':
HeapClient.c:(.text.startup+0x1a3): undefined reference to `heapsort'"
Run Code Online (Sandbox Code Playgroud)

c undefined-reference

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

c ×1

undefined-reference ×1