Advertisement

automake and include paths

Started by February 01, 2004 09:28 PM
5 comments, last by clayasaurus 20 years, 7 months ago
hello, i'm trying to make it so in my source directories all I have to do is #include "bob.h" instead of #include "../../bob.h" just with g++ i've done g++ -c bob/bob.cpp -Iinclude/ and that seems to work, but i was wondering if anyone knew how to get configure.in or Makefile.am to recognize this as my include directory? i tried changing the CFLAGS in my configure.in but that doesn't work for me. I've tried the --include=dir but configure gets mad if i don't give it an absolute file path, and even then it doesn't work. my directory is set up like this Makefile.am configure.in Makefile source/bob/bob.cpp include/bob.h any suggestions? thanks [edited by - clayasaurus on February 1, 2004 10:28:45 PM]
hrm well as usual i might answer my own question way to quickly but i just learned about INCLUDES = -I@top_srcdir@/include in Makefile.am and i'm testing it out

[edit] i also just learned that I have to do #include "iostream" as well as #include "bob.h", strange, but it just might work yay

[edited by - clayasaurus on February 1, 2004 10:37:55 PM]
Advertisement
Do it in the automake file. Something like this:
bin_PROGRAMS = bobbob_SOURCES  = source/bob/bob.cpp include/bob.hbob_CPPFLAGS = -Iinclude

You should move the headers to their "HEADERS" dealie rather than in "SOURCE" if they actually need to be installed. The "CPP" in "CPPFLAGS" is for "C pre-processor" rather than "C plus plus", by the way.

hrm i thought i could get away with #include "iostream" but it doesn't seem to work anymore

anyway, my Makefile.am is being used to compile a shared library with a lot of sources and INCLUDES = -I@top_srcdir@/include seems somewhat promising except that it seems to do something to the normal files so they arn't recognized if i include them in one of my include/header.h files, but are if they're included in my source/cpp.cpp files

i get this stuff

g++ -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"claytek\" -DVERSION=\"1.0.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -I. -I. -I./include -g -O2 -MT cWHsize.lo -MD -MP -MF .deps/cWHsize.Tpo -c source/cppcommon/datatypes/cWHsize.cpp  -fPIC -DPIC -o .libs/cWHsize.loIn file included from /usr/include/c++/3.3.2/bits/locale_facets.tcc:41,                 from /usr/include/c++/3.3.2/locale:47,                 from /usr/include/c++/3.3.2/bits/ostream.tcc:37,                 from /usr/include/c++/3.3.2/ostream:535,                 from /usr/include/c++/3.3.2/iostream:45,                 from include/cWHsize.h:18,                 from source/cppcommon/datatypes/cWHsize.cpp:15:/usr/include/c++/3.3.2/cmath:107: error: `acosf' not declared/usr/include/c++/3.3.2/cmath:110: error: `asinf' not declared/usr/include/c++/3.3.2/cmath:113: error: `atanf' not declared/usr/include/c++/3.3.2/cmath:116: error: `atan2f' not declared/usr/include/c++/3.3.2/cmath:119: error: `ceilf' not declared/usr/include/c++/3.3.2/cmath:122: error: `coshf' not declared/usr/include/c++/3.3.2/cmath:125: error: `expf' not declared/usr/include/c++/3.3.2/cmath:128: error: `floorf' not declared/usr/include/c++/3.3.2/cmath:131: error: `fmodf' not declared


and in WHsize.cpp 15 is #include "cWHsize.h", and line 18 in cWHsize.h is , which seems to be causing the problem

i'll try playing around with the CPPFLAGS but i think it does the same thing as INCLUDE=

Edit: changed the code-pseudo-markup tags to source-pseudo-markup tags to prevent the resulting huge page width.

[edited by - Null and Void on February 2, 2004 1:32:29 AM]
well the only way i can think of to fix my problem is to move the headers in the source directories and remove my includes folder, so the headers are in the same place with the source, or maybe create an include folder for every source subdirectory.

[edit] : or maybe i'll use an ide to create the makefile

[edited by - clayasaurus on February 3, 2004 8:38:58 PM]
quote: Original post by Null and Void
The "CPP" in "CPPFLAGS" is for "C pre-processor" rather than "C plus plus", by the way.


To nitpick, Yeah it does!

compare what CPPFLAGS and CFLAGS do for a .c and .cc file.
Advertisement
quote: Original post by C-Junkie
quote: Original post by Null and Void
The "CPP" in "CPPFLAGS" is for "C pre-processor" rather than "C plus plus", by the way.

To nitpick, Yeah it does!

compare what CPPFLAGS and CFLAGS do for a .c and .cc file.

"CXXFLAGS" is for just C++. "CFLAGS" is for just C. "CPPFLAGS" affects both C and C++ since they both use the C preprocessor. Check the Automake documentation, why would they be using "CPPFLAGS" for C programs? Check a configure script''s help output, what does it claim "CPPFLAGS" stands for (in that case it''s an environment variable, but still applicable)?

This topic is closed to new replies.

Advertisement