I try to add LDLIBS=-lm to my makefile, to link math.h, but I get the same error as before "sin undeclared " function. Here is part of my makefile:
I appreciate your help in advance.
LDLIBS=-lm
ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = \
kdv
kdv_SOURCES = kdv.c vector.c
lib_LIBRARIES = liblinalg.a
liblinalg_a_SOURCES = \
kdv.h \
vector.c
LDADD = liblinalg.a
TESTS = \
kdv
Related
In my src directory, I have source files such as cells.c. When I perform a compilation, the compiler prefixes the object file with the package name, so that it becomes neoleo-cells.o, for example. Why is it doing this, and how can I stop it? I don't think it's standard behaviour.
Here is Makefile.am:
#VPATH = $(srcdir) $(builddir)
GUI_SRCS =
GUI_LINK =
#GUI_DEFINES = -DX_DISPLAY_MISSING
GUI_DEFINES = -DHAVE_X
# Order of linking of libraries for Motif seems to be important
# I have decided to mandate the use of the Xbae library, rather than
# have it optional.
if UseMotif
GUI_SRCS += io-motif.c appres.c fallback.c oleo_icon.xpm
GUI_LINK += -lXm -lXt -lXbae
GUI_DEFINES += -DHAVE_MOTIF
endif
GUI_SRCS += io-x11.c xrdb.c
GUI_LINK += -lX11
YFLAGS = -d
EXTRA_DIST = $(srcdir)/neoleo.i
bin_PROGRAMS = neoleo
BUILT_SOURCES = getdate.c parse.c parse.h posixtm.c posixtm.h
#BUILT_SOURCES += neoleo_wrap.c
CLEANFILES = $(BUILT_SOURCES)
#lib_LTLIBRARIES = libneoleo.la
neoleo_CFLAGS = $(GUI_DEFINES) -Dmain0=main
neoleo_LDADD = -lm -lncurses -lpthread $(GUI_LINK)
#neoleo_LDFLAGS = -e main0
#neoleo_la_LDFLAGS = -module -avoid-version -shared
neoleo_SOURCES = afm.c args.c basic.c busi.c byte-compile.c cells.c cmd.c date.c decompile.c display.c \
epson.c eval.c font.c format.c forminfo.c funcs.c graph.c gsl.c hash.c help.c \
info.c init.c input.c \
io-headless.c io-curses.c io-edit.c io-term.c io-utils.c \
ir.c key.c legend.c line.c list.c lists.c mdi.c oleofile.c pcl.c plot.c \
postscript.c print.c prtext.c ref.c regions.c sc.c sort.c string.c stub.c sylk.c utils.c \
window.c \
defuns.c \
get_date.h getdate.y \
parse.y \
posixtm.y \
neoleo_swig.c \
mysql.c $(GUI_SRCS)
noinst_HEADERS = afm.h appres.h args.h basic.h byte-compile.h cell.h \
cmd.h decompile.h defun.h defuns.h display.h epson.h \
errors.h eval.h font.h format.h forminfo.h funcdef.h \
funcs.h global.h graph.h hash.h help.h info.h init.h \
input.h io-abstract.h io-headless.h io-curses.h io-edit.h \
io-generic.h io-motif.h io-term.h io-utils.h io-x11.h \
ir.h key.h line.h list.h lists.h mdi.h mysql.h node.h \
oleofile.h oleo_plot.h oleosql.h oleo_xb.h parse.h pcl.h \
posixtm.h postscript.h print.h proto.h prtext.h ref.h \
regions.h sc.h sciplot.h sciplotI.h sort.h stub.h stubs.h \
sylk.h sysdef.h userpref.h utils.h window.h \
neoleo_swig.h
# exclude these for now:
# plotter.c xbase.cpp
ref.o : parse.h
#neoleo_wrap.c : $(srcdir)/neoleo.i neoleo_swig.c neoleo_swig.h
# swig -tcl8 -o $# $<
This line causes the rename of the object files:
neoleo_CFLAGS = $(GUI_DEFINES) -Dmain0=main
If you have target-dependent compilation flags, Automake chooses different names for the resulting object files. This approach avoids clashes if there are multiple different targets that use the same sources but different flags.
Now, Automake could in theory notice that this isn't happening and not rename the object files. However, in practice most people don't care what the intermediate files are called, and this approach, I believe, simplified the implementation.
In your case, it sounds like you do care. So, just rename that variable to AM_CFLAGS and everything should work as you expect.
I want to compile the latest version of VASP 5 (5.4.1) on a Cray XC MPP machine. Does anyone have the settings I can use? The VASP distribution does not come with an example for Cray.
The build system has changed from the 5.3.5 version.
Full compilation instructions can be found on the ARCHER (http://www.archer.ac.uk) website at:
http://www.archer.ac.uk/documentation/software/vasp/compiling_5-4-1-phase2.php
But in brief:
Download and patch the source code
Switch to Intel programming environment and load the fftw module:
module swap PrgEnv-cray PrgEnv-intel
module load fftw
Create "makefile.include" with the following settings:
# Precompiler options
CPP_OPTIONS= -DMPI -DHOST=\"CrayXC-Intel\" \
-DIFC \
-DCACHE_SIZE=2000 \
-DPGF90 \
-Davoidalloc \
-DMPI_BLOCK=8000 \
-DscaLAPACK \
-Duse_collective \
-DnoAugXCmeta \
-Duse_bse_te \
-Duse_shmem \
-Dtbdyn
CPP = fpp -f_com=no -free -w0 $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)
FC = ftn
FCL = ftn
FREE = -free -names lowercase
FFLAGS = -assume byterecl
OFLAG = -O3 -ip -fno-alias -unroll-aggressive -opt-prefetch -use-intel-optimized-headers -no-prec-div
OFLAG_IN = $(OFLAG)
DEBUG = -O0
MKL_PATH = $(MKLROOT)/lib/intel64
BLAS =
LAPACK =
BLACS =
SCALAPACK =
OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
INCS =
LLIBS = ${MKL_PATH}/libmkl_blas95_lp64.a ${MKL_PATH}/libmkl_lapack95_lp64.a \
${MKL_PATH}/libmkl_scalapack_lp64.a \
-Wl,--start-group ${MKL_PATH}/libmkl_intel_lp64.a \
${MKL_PATH}/libmkl_sequential.a ${MKL_PATH}/libmkl_core.a \
${MKL_PATH}/libmkl_blacs_intelmpi_lp64.a -Wl,--end-group
OBJECTS_O1 += fft3dfurth.o fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o
# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = cc
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)
OBJECTS_LIB= linpack_double.o getshmem.o
# Normally no need to change this
SRCDIR = ../../src
BINDIR = ../../bin
Compile the code
make all
How can I link an executable in say test subdirectory of an autotools project against a library, say libfoo, that is just built from files in src directory of same project?
Makefile.am looks like:
SUBDIRS = src . test
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
src/Makefile.am:
ACLCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
lib_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES = \
foo.cpp
foo_includedir = $(includedir)/foo
foo_include_HEADERS = \
foo.hpp
test/Makefile.am:
ACLCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
check_PROGRAMS = footest
footest_SOURCES = \
main.cpp
footest_LDADD = ?????
That's easy: footest_LDADD = ../src/libfoo.la
This works for 'out-of-tree' builds, e.g., if you invoke configure from another directory (not ./configure).
My makefile loops endless but can't figure out why? Here is it further informations at sf.net/p/ags
AUTOMAKE_OPTIONS = foreign
top_srcdir = $(shell pwd)/src/ags
SUBDIRS = src/ags \
doc
-include ./src/ags/Makefile.am \
$(top_srcdir)/util/Makefile.am \
$(top_srcdir)/lib/Makefile.am \
$(top_srcdir)/object/Makefile.am \
$(top_srcdir)/widget/Makefile.am \
$(top_srcdir)/audio/Makefile.am \
$(top_srcdir)/audio/task/Makefile.am \
$(top_srcdir)/audio/file/Makefile.am \
$(top_srcdir)/audio/recall/Makefile.am \
$(top_srcdir)/audio/task/recall/Makefile.am \
$(top_srcdir)/file/Makefile.am \
$(top_srcdir)/X/Makefile.am \
$(top_srcdir)/X/editor/Makefile.am \
$(top_srcdir)/X/machine/Makefile.am \
$(top_srcdir)/file/Makefile.am \
$(top_srcdir)/server/Makefile.am \
./doc/Makefile.am
CC = gcc
# what flags you want to pass to the C compiler & linker
CFLAGS = -g --pedantic -Wall -O -I./src -I/usr/include
LDFLAGS = -L/lib -L/usr/lib -L/usr/X11/lib -lm -pthread -lrt -lgmp
# this lists the binaries to produce, the (non-PHONY, binary) targets in
# the previous manual Makefile
noinst_LIBRARIES = libags.a libags-thread.a libags-audio.a
bin_PROGRAMS = gsequencer
# library
libags_a_CFLAGS=
libags_a_LDFLAGS =
# application
gsequencer_CFLAGS=
gsequencer_LDFLAGS=
gsequencer_LDADD=libags.a libags-thread.a libags-audio.a
#
libags_audio_h_sources = $(ags_recall_audio_h_sources) $(ags_audio_task_h_sources) $(ags_xorg_task_h_sources) $(ags_audio_file_h_sources) $(ags_audio_recall_task_h_sources)
libags_audio_c_sources = $(ags_recall_audio_c_sources) $(ags_audio_task_c_sources) $(ags_xorg_task_c_sources) $(ags_audio_file_c_sources) $(ags_audio_recall_task_c_sources)
gsequencer_h_sources = $(ags_xorg_h_sources) $(ags_machine_h_sources) $(ags_editor_h_sources)
gsequencer_c_sources = $(ags_xorg_c_sources) $(ags_machine_c_sources) $(ags_editor_c_sources)
libags_a_SOURCES = $(ags_lib_c_sources) $(ags_object_c_sources) $(ags_util_c_sources)
libags_thread_a_SOURCES = $(ags_thread_c_sources)
libags_audio_a_SOURCES = $(ags_audio_c_sources)
libags_gui_a_SOURCES = $(ags_widget_c_sources)
gsequencer_SOURCES = $(gsequencer_c_sources) $(ags_server_c_sources) $(ags_file_c_sources)
Wiping all build scripts
rm *
Touching all files
find . -type f | xargs touch
Running the following to rebuild build scripts did it finally
aclocal
autoheader
libtoolize --force --copy
automake --add-missing --copy --foreign
autoconf
./configure
make
PROBLEM: empty Makefile.am caused infinite loop
SOLUTION: add an empty variable to it
I am a beginner in using autotool, I want to add some shell script in the Makefile.am, when I use the method below, the Makefile created by autotool is not I am expected. How can I write to create the correct one.
Thanks for your reply!
PS:
this is my configure.in and Makefile.am(parts)
configure.in:
if test "$sample" = yes;then
DEFS="$DEFS -DSAMPLE=1"
AC_SUBST(SAMPLE, [yes])
fi
Makefile.am:
if test "$SAMPLE" = yes;then
noinst_PROGRAMS = test
test_SOURCES = test.c
else
bin_PROGRAMS = release
release_SOURCES = main.c
fi
Makefile autotool created:
........
........
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS ctags \
distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am \
install-includeHEADERS install-info install-info-am \
install-libLTLIBRARIES install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-includeHEADERS \
uninstall-libLTLIBRARIES
if test "yes" = yes;then
fi
Automake conditionals don't work like that. See the manual.
Here's how it should look:
configure.ac:
AM_CONDITIONAL([SAMPLE], [test "$SAMPLE" = yes])
Makefile.am:
if SAMPLE
noinst_PROGRAMS = test
test_SOURCES = test.c
else
bin_PROGRAMS = release
release_SOURCES = main.c
endif