0

I wanna use some functions which are defined in libvmi/driver/xen.c file, in process-list.c file,but I don't know where in Makefile I should link this two ".c" files. I know how to do this in a simple Makefile but I couldn't find something like that in this Makefile to add linking part of libvmi/driver/xen.c and process-list.c. This Makefile belongs to a project with several Makefiles.

Thanks for any help!

    ## Source directory

SUBDIRS = 

INCLUDES = -I$(top_srcdir)
AM_LDFLAGS = -L$(top_srcdir)/libvmi/.libs/
LDADD = -lvmi -lm $(LIBS)
c_sources = process-list.c \ 
            libvmi/driver/xen.c
bin_PROGRAMS = module-list process-list map-symbol map-addr dump-memory
module_list_SOURCES = module-list.c
process_list_SOURCES = $(c_sources)
map_symbol_SOURCES = map-symbol.c
map_addr_SOURCES = map-addr.c
dump_memory_SOURCES = dump-memory.c
James M
  • 18,506
  • 3
  • 48
  • 56
Peggy
  • 639
  • 9
  • 28
  • 1
    What you've posted above isn't a `Makefile`. This is used to generate one. – devnull Jun 29 '13 at 10:32
  • Can you describe in more detail what you want to accomplish? – meaning-matters Jun 29 '13 at 10:35
  • @meaning-matters: I use a function -which is declared in xen.c file- in another file named process-list.c. but compiling it returns error, not defined reference to function "foo".(which is declared as I said in xen.c)I thought I should link their object files somehow. but I don't know how to do this in this Makefile. – Peggy Jun 29 '13 at 11:01

1 Answers1

0

You shouldn't need to link two .c files, you need to compile them and then link the .o files. If your project makefile is generated, perhaps this happens automatically, if not you would mainly need to add the new .c files to the build.

Karthik T
  • 31,456
  • 5
  • 68
  • 87
  • devnull: sorry, you are totally right! now I added "c_sources = process-list.c libvmi/driver/xen.c" and then changed "process_list_SOURCES = process-list.c" to which you see above but it returned the error "make[3]: *** No rule to make target `libvmi/driver/xen.c', needed by `libvmi/driver/xen.o'. Stop." – Peggy Jun 29 '13 at 10:54
  • @ Karthik T:yes I meant the object files,too. xen.o is made in another directory "libvmi/driver/xen.o" and process-list.o,too.both in different directories. I don't know now,how and where to link them. – Peggy Jun 29 '13 at 11:06
  • If it is getting compiled in a different folder, then you just need to figure out the linking.. If they are in different directories, then likely they are in different Makefiles. Possibly they may not be automatically linked.. – Karthik T Jun 29 '13 at 11:10
  • @ Karthik T: Yes,they are in different Makefiles.I'm trying to find a way to link their .o files. – Peggy Jun 29 '13 at 11:25