未定义的符号_main,但我有一个主要功能?

时间:2014-03-17 16:12:09

标签: c gcc

这是我的控制台输出:

Tylers-MacBook-Pro:laser_finder_c tylerjw$ make
gcc -g -Wall   -c -o dots_img.o dots_img.c
gcc -g -Wall   -c -o no_dots_img.o no_dots_img.c
gcc -g -Wall   -c -o point.o point.c
gcc -g -Wall   -c -o images.o images.c
gcc -g -Wall   -c -o laser_finder_c.o laser_finder_c.c
gcc dots_img.o no_dots_img.o point.o images.o laser_finder_c.o  -g -Wall -o laser_finder_c
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [laser_finder_c] Error 1

这似乎没有任何意义,因为主要功能在laser_finder_c.c中定义。下面是我的makefile。我真的很困惑为什么会这样。

TARGET      = laser_finder_c
OBJECTS     = dots_img.o no_dots_img.o point.o images.o laser_finder_c.o 
#######################################################################################
CFLAGS   = -g -Wall
ASFLAGS  = -Wall
LDFLAGS  = -g -Wall

CC = gcc
AS = gcc

########################################################################################
$(TARGET): $(OBJECTS)
    $(CC) $(OBJECTS) $(LDFLAGS) -o $(TARGET)

point.o: point.h
images.o: images.h
laser_finder_c.o: images.h point.h
dots_img.o: images.h
no_dots_img.o: images.h

clean: 
    rm -f $(OBJECTS) $(TARGET)

以下是laser_finder_c.c中main的定义

// laser_finder.c - finds the location of laser points comparing two images
#include "point.h"
#include <stdio.h>
#include <stdlib.h>

// #defines ... removed

int main()
{
  // ... code removed

  return 0;
}

对于上下文,gcc -v的输出为:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

0 个答案:

没有答案