编译具有多个头文件的C程序时出错

时间:2017-05-15 12:08:44

标签: c compiler-errors linker clang

我有kmeans_seq.cbikmeans_seq.c个文件。文件bikmeans_seq.c包含两个标题:kmeans_seq.hbikmeans_seq.h。当我使用bikmeans_seq.c编译gcc bikmeans_seq.c -o bikmeans时,我收到此错误:

Undefined symbols for architecture x86_64:
  "_euclidean_dist", referenced from:
      _points_assignment in bikmeans_seq-5c462b.o
      _partition_clusters in bikmeans_seq-5c462b.o
      _standard_deviation in bikmeans_seq-5c462b.o
  "_find_max", referenced from:
      _standard_deviation in bikmeans_seq-5c462b.o
  "_kmeans", referenced from:
      _main in bikmeans_seq-5c462b.o
      _partition_clusters in bikmeans_seq-5c462b.o
     (maybe you meant: _bisecting_kmeans)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我不确定这个错误是什么。有人可以暗示我为什么会收到此错误吗?谢谢。

1 个答案:

答案 0 :(得分:0)

Without sources is a bit difficult but try this:

gcc -Wall bikmeans_seq.c kmeans_seq.c -o bikmeans

Even if this will work I would suggest to use a makefile.

Hope this helps!