I've added my own .c file to Emacs /src directory as well as the following lines

emacs.o: ... file.c file.h
file.o: file.c

in deps.mk

I get file.o generated, but it is not linked when generating Emacs executable (at least that's what I see when I check presence of my function). Why?

In general, what actions should I undertake to add my .c file to Emacs executable?

2 Answers 2


Quoting deps.mk:

## This file is included in src/Makefile if AUTO_DEPEND=no.\

So it's kind of a fallback file only used to give dependencies to make sure compilation ordering is right. You want to look in src/Makefile.in instead where you should have no difficulty finding the variable that contains all the .o files we need.


The problem was not in a build system but in Emacs itself.
In order to have a function defined with DEFUN available for a user you must not only define it but also write in your file:

syms_of_filename (void)
  defsubr (&Sfunction_name);

and call this function from emacs.c

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.