0

My directory set up:

libone
  one.c
  one.h
  Makefile.am

libtwo
  two.c #includes one.h
  two.h
  Makefile.am

...
Makefile.am
configure.ac
...

Now when I do autoreconf -fvi and configure and make, I get the error from two.c: could not find one.h. How do I setup the include paths in Makefile.am's? Any help appreciated.

ptomato
  • 56,175
  • 13
  • 112
  • 165
BenjiWiebe
  • 2,116
  • 5
  • 22
  • 41

1 Answers1

0

Either do it the quick'n'dirty way

#include "../libone/one.h"

or (preferred, because then it doesn't matter whether one.h is installed or in the source tree or split out into a different project)

#include <libone/one.h>

and in your Makefile.am

libtwo_a_SOURCES = two.c two.h
libtwo_a_CPPFLAGS = -I$(top_srcdir)
ptomato
  • 56,175
  • 13
  • 112
  • 165
  • I added CPPFLAGS = -I $(top_srcdir)/libone to libtwo/Makefile.am and included "one.h" in two.c. Thanks for the help. – BenjiWiebe Oct 26 '12 at 19:51
  • Not trying to be rude here... But I am a newbie to Autotools... Why is your version better? – BenjiWiebe Oct 26 '12 at 20:09
  • Because it allows you to split `libone` off into its own project and use the version installed in the system include directory. Don't worry, it's a minuscule difference in which one's "better", I just think if you can get more versatility without any more effort, then why not? – ptomato Oct 27 '12 at 09:37
  • This situation reflects a real-life problem. libone goes by the name of libmessage, my own logging library that makes it easier to adjust verbosity and where it logs to. libmessage will only be used with libtwo and some other things dstributed together. Also, libone will not be installed (just used by code in "sister" directories). But thanks for explaining why it would be better. – BenjiWiebe Oct 27 '12 at 19:29