Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6704985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:21:05+00:00 2026-05-26T07:21:05+00:00

I am trying to use GNU AutoTools for my C++ project. I have written

  • 0

I am trying to use GNU AutoTools for my C++ project. I have written configure.ac, makefile.am etc. I have some files that are used by the program during execution e.g. template files, XML schema etc. So, I install/copy these files along the executable, for which I use something like:

abcdir = $(bindir)/../data/abc/
abc_DATA = ../data/knowledge/abc.cc

Now it copies the file correctly and My program installation structure looks somethings as follows:

<installation_dir>/bin/<executableFile>
<installation_dir>/data/abc/abc.cc

Now the problem is that in the source code I actually use these files (abc.cc etc.) and for that I need path of where these files resides to open them. One solution is to define (using AC_DEFINE) some variable e.g. _ABC_PATH_ that points to the path of installation but how to do that exactly?. OR is there any better way to do that. For example, in source code, I do something like:

...
ifstream input(<path-to-abc-folder> + "abc.cc"); // how to find <path-to-abc-folder>?
..
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:21:06+00:00Added an answer on May 26, 2026 at 7:21 am

    The AC_DEFINE solution is fine in principle, but requires shell-like variable expansion to take place. That is, _ABC_PATH_ would expand to “${bindir}/../data/abs”, not /data/abc.

    One way is to define the path via a -D flag, which is expanded by make:

    myprogram_CPPFLAGS += -D_ABC_PATH='\"${abcdir}\"'
    

    which works fine in principle, but you have to make include config.status in the dependencies of myprogram.

    If you have a number of such substitution variables, you should roll out a paths.h file that is
    generated by automake with a rule like:

    paths.h : $(srcdir)/paths.h.in config.status
         sed -e 's:@ABC_PATH@:${abcdir}:' $< > $@
    

    As a side-note, you do know about ${prefix} and ${datarootdir} and friends, don’t you? If not, better read them up; ${bindir}/.. is not necessarily equal to ${prefix} if the user did set ${exec_prefix}.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary : I have a project using GNU Autotools. I have a pot file.
I'm trying to port some assembly code written in Visual Studio into GNU inline
I'm trying to use GNU find to find only the directories that contain no
I've been trying to make GNU gdb 6.5-14 to use the source code embedded
Trying to use GnuPG with Delphi (Win32). I need to sign some file with
I'm trying to use NetBeans to compile C code and have the following versions
I am trying to use the GNU Scientific Library (GSL) http://www.gnu.org/software/gsl/ in QtCreator. How
When trying to use a modified version of the Lisp snippet from the GNU
I'm trying to debug a complex Makefile. How do you get GNU make to
I'm trying to use the GNU autoconf/automake toolchain for the first time, so the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.