LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-10-2017, 10:48 AM   #1
vladimir1986
Member
 
Registered: Jul 2011
Posts: 112

Rep: Reputation: Disabled
How may I pass certain flags for gcc with autotools? (ncurses problem)


I am having a bit of a problem with a project I am writing which uses ncurses: When I compile it manually it works perfectly fine(gcc -o binary main.c -lncurses), but I am trying to use autotools and I don't seem to get to pass the -lncurses flag. I didn't find much help either, apart from making it check if I have ncurses installed during the ./configure. When I do a make, it uses the command: "gcc -g -O2 -o Blood main.o", which fails.

This is so far my configure.ac

Code:
AC_PREREQ([2.69])
AC_INIT([Blood], [1.0])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([config.h])
#CPPFLAGS=lncurses
AC_CHECK_HEADERS(ncurses.h)
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
I experimented with both CPPFLAGS and CXXFLAGS as I understood from the man page, but none of those seem to serve to pass the required flag.... What am I missing?

Thank you in advance

Last edited by vladimir1986; 07-10-2017 at 11:51 AM.
 
Old 07-10-2017, 11:49 AM   #2
vladimir1986
Member
 
Registered: Jul 2011
Posts: 112

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by vladimir1986 View Post
I am having a bit of a problem with a project I am writing which uses ncurses: When I compile it manually it works perfectly fine(gcc -o binary main.c -lncurses), but I am trying to use autotools and I don't seem to get to pass the -lncurses flag. I didn't find much help either, apart from making it check if I have ncurses installed during the ./configure. When I do a make, it uses the command: "gcc -g -O2 -o Blood main.o", which fails.

This is so far my configure.ac

Code:
AC_PREREQ([2.69])
AC_INIT([Blood], [1.0])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([config.h])
#CPPFLAGS=lncurses
AC_CHECK_HEADERS(ncurses.h)
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
I experimented with both CPPFLAGS and CXXFLAGS as I understood from the man page, but none of those seem to serve to pass the required flag.... What am I missing?

Thank you in advance
Found it: In makefile.am I added the line

AM_CFLAGS = "-lncurses"
 
Old 07-10-2017, 11:53 PM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Or perhaps
Code:
AM_LDFLAGS = -lncurses
on modern systems (2007+):
Code:
AM_LIBS = -lncurses
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] STRANGE: Newly Compiled GCC 4.4.4 on Solaris sparc gives problem with -m32/-m64 flags d_shanke Solaris / OpenSolaris 3 08-09-2012 05:31 PM
STRANGE: Newly Compiled GCC 4.4.4 on Solaris sparc gives problem with -m32/-m64 flags d_shanke Linux - Newbie 1 07-30-2012 09:52 AM
Problem at 5.12. GCC-4.3.2 - Pass 2 la1nla1n Linux From Scratch 2 01-09-2009 12:40 PM
autotools/gcc linker issue fibbi Linux - Software 2 05-08-2006 10:38 PM
Problem compiling programs using ncurses library (gcc 3.2.2 and RH9 default inst.) jclark7777 Linux - Newbie 1 07-20-2004 01:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration