I am facing a small problem when trying to build my code with autotools.
My file structure is:
$ tree
.
|-- configure.ac
|-- Makefile.am
`-- src
|-- constants.f90
|-- environment.f90
|-- init.f90
|-- main.f90
`-- util.f90
(deleted possibly unnecessary lines)
and my Makefile.am is:
#SUBDIRS= help
bin_PROGRAMS = scasr
scasr_SOURCES = \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90 src/main.f90
scasr_LDADD =
EXTRA_DIST= autogen.sh
CLEANFILES =*.mod
The problem is src/(*.f90)'s except main.f90 are module. Hence, if I
have to write the makefile by hand, I will have:
constants.o : constants.f90
environment.o : environment.f90
init.o : init.f90 util.o constants.o
main.o : main.f90 init.o constants.o environment.o
util.o : util.f90 constants.o
so, for Makefile.am, I have to make a strict order of files in
scasr_SOURCES. i.e.
with the sources as :
scasr_SOURCES = \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90 src/main.f90
It compiles fine.
But if I have as:
scasr_SOURCES = src/main.f90 \
src/constants.f90 src/environment.f90 src/util.f90 \
src/init.f90
I get error:
make all-am
make[1]: Entering directory `/home/rudra/Programs/ScASR/trunk'
gfortran -g -O2 -c -o src/main.o src/main.f90
src/main.f90:7.4:
use mget_env
1
Fatal Error: Can't open module file 'mget_env.mod' for reading at (1):
No such file or directory
make[1]: *** [src/main.o] Error 1
Is there any way out so that make/configure will check the dependency by
itself? Or I must keep a strict order?
(Answers in the comments. See Question with no answers, but issue solved in the comments (or extended in chat) )
#Stefan wrote:
You could enter the dependencies directly to your Makefile.am. So simply put your handwritten Makefile rules (the third code part in your post) in the Makefile.am. Automatic dependency tracking is, as far as I know, not (yet) possible. This could change with the addition of submodules, which are defined in Fortran 2008 but not yet implemented in any popular compiler.
The OP Wrote:
As per #Stefan's comment, I have added the dependencies in make file, and that solved the problem. I have tested that the order of source code is not important anymore. Since, there is not many stuff in internet available, I am putting the complete procedure here:
create a dependency list (makedepf90 is a good option)
$ makedepf90 src/*.f90 src/constants.o : src/constants.f90 src/environment.o : src/environment.f90 src/init.o : src/init.f90 src/util.o src/constants.o src/main.o : src/main.f90 src/init.o src/constants.o src/environment.o src/util.o : src/util.f90 src/constants.o
Just copy-paste the output of step 1 after the scasr_SOURCES:
scasr_SOURCES = src/main.f90\ src/constants.f90 src/environment.f90 rc/util.f90 src/init.f90 src/constants.o : src/constants.f90 src/environment.o : src/environment.f90 src/init.o : src/init.f90 src/util.o src/constants.o src/main.o : src/main.f90 src/init.o src/constants.o src/environment.o src/util.o : src/util.f90 src/constants.o
NB: I have not tested if it will work if you place it some place else in the makefile. But this is working.
Related
I've built a number of projects with Veins on Omnet++ without issues at this stage, and I decided to implement CAM messages into a simulation. However, upon building I arrive at the following error:
12:41:23 **** Incremental Build of configuration release for project v2x ****
make MODE=release all
cd src && make make[1]: Entering directory '/home/veins/workspace.omnetpp/v2x/src'
Creating executable: ../out/clang-release/src/v2x /usr/bin/ld: cannot open output file ../out/clang-release/src/v2x: Is a directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]:
*** [Makefile:117: ../out/clang-release/src/v2x] Error 1 make[1]: Leaving directory '/home/veins/workspace.omnetpp/v2x/src'
make: *** [Makefile:2: all]
Error 2 "make MODE=release all" terminated with exit code 2.
Build might be incomplete.
12:41:24 Build Failed. 3 errors, 0 warnings. (took 549ms)
My Makefile reads:
#
# OMNeT++/OMNEST Makefile for v2x
#
# This file was generated with the command:
# opp_makemake -f --deep -KINET_PROJ=/home/veins/src/inet -KLTE_PROJ=/home/veins/src/simulte -KVEINS_INET_PROJ=/home/veins/src/veins/subprojects/veins_inet -KVEINS_PROJ=/home/veins/src/veins -DINET_IMPORT -DVEINS_IMPORT -DVEINS_INET_IMPORT -I$$\(INET_PROJ\)/src -I$$\(LTE_PROJ\)/src -I$$\(VEINS_INET_PROJ\)/src -I$$\(VEINS_PROJ\)/src -I. -L$$\(INET_PROJ\)/src -L$$\(LTE_PROJ\)/src -L$$\(VEINS_PROJ\)/src -L$$\(VEINS_INET_PROJ\)/src -lINET$$\(D\) -llte$$\(D\) -lveins$$\(D\) -lveins_inet$$\(D\)
#
# Name of target to be created (-o option)
TARGET_DIR = .
TARGET_NAME = v2x$(D)
TARGET = $(TARGET_NAME)$(EXE_SUFFIX)
TARGET_IMPLIB = $(TARGET_NAME)$(IMPLIB_SUFFIX)
TARGET_IMPDEF = $(TARGET_NAME)$(IMPDEF_SUFFIX)
TARGET_FILES = $(TARGET_DIR)/$(TARGET)
# User interface (uncomment one) (-u option)
USERIF_LIBS = $(ALL_ENV_LIBS) # that is, $(TKENV_LIBS) $(QTENV_LIBS) $(CMDENV_LIBS)
#USERIF_LIBS = $(CMDENV_LIBS)
#USERIF_LIBS = $(TKENV_LIBS)
#USERIF_LIBS = $(QTENV_LIBS)
# C++ include paths (with -I)
INCLUDE_PATH = -I$(INET_PROJ)/src -I$(LTE_PROJ)/src -I$(VEINS_INET_PROJ)/src -I$(VEINS_PROJ)/src -I.
# Additional object and library files to link with
EXTRA_OBJS =
# Additional libraries (-L, -l options)
LIBS = $(LDFLAG_LIBPATH)$(INET_PROJ)/src $(LDFLAG_LIBPATH)$(LTE_PROJ)/src $(LDFLAG_LIBPATH)$(VEINS_PROJ)/src $(LDFLAG_LIBPATH)$(VEINS_INET_PROJ)/src -lINET$(D) -llte$(D) -lveins$(D) -lveins_inet$(D)
# Output directory
PROJECT_OUTPUT_DIR = ../out
PROJECTRELATIVE_PATH = src
O = $(PROJECT_OUTPUT_DIR)/$(CONFIGNAME)/$(PROJECTRELATIVE_PATH)
# Object files for local .cc, .msg and .sm files
OBJS = \
$O/v2x/GeneralMessageSerializer.o \
$O/v2x/VeinsInetApplicationBase.o \
$O/v2x/VeinsInetManager.o \
$O/v2x/VeinsInetManagerBase.o \
$O/v2x/VeinsInetManagerForker.o \
$O/v2x/VeinsInetMobility.o \
$O/v2x/VeinsInetSampleApplication.o \
$O/v2x/VeinsInetSampleMessageSerializer.o \
$O/v2x/GeneralMessage_m.o \
$O/v2x/VeinsInetSampleMessage_m.o
# Message files
MSGFILES = \
v2x/GeneralMessage.msg \
v2x/VeinsInetSampleMessage.msg
# SM files
SMFILES =
# Other makefile variables (-K)
INET_PROJ=/home/veins/src/inet
LTE_PROJ=/home/veins/src/simulte
VEINS_INET_PROJ=/home/veins/src/veins/subprojects/veins_inet
VEINS_PROJ=/home/veins/src/veins
#------------------------------------------------------------------------------
# Pull in OMNeT++ configuration (Makefile.inc)
ifneq ("$(OMNETPP_CONFIGFILE)","")
CONFIGFILE = $(OMNETPP_CONFIGFILE)
else
CONFIGFILE = $(shell opp_configfilepath)
endif
ifeq ("$(wildcard $(CONFIGFILE))","")
$(error Config file '$(CONFIGFILE)' does not exist -- add the OMNeT++ bin directory to the path so that opp_configfilepath can be found, or set the OMNETPP_CONFIGFILE variable to point to Makefile.inc)
endif
include $(CONFIGFILE)
# Simulation kernel and user interface libraries
OMNETPP_LIBS = $(OPPMAIN_LIB) $(USERIF_LIBS) $(KERNEL_LIBS) $(SYS_LIBS)
ifneq ($(PLATFORM),win32.x86_64)
LIBS += -Wl,-rpath,$(abspath $(INET_PROJ)/src) -Wl,-rpath,$(abspath $(LTE_PROJ)/src) -Wl,-rpath,$(abspath $(VEINS_PROJ)/src) -Wl,-rpath,$(abspath $(VEINS_INET_PROJ)/src)
endif
COPTS = $(CFLAGS) $(IMPORT_DEFINES) -DINET_IMPORT -DVEINS_IMPORT -DVEINS_INET_IMPORT $(INCLUDE_PATH) -I$(OMNETPP_INCL_DIR)
MSGCOPTS = $(INCLUDE_PATH)
SMCOPTS =
# we want to recompile everything if COPTS changes,
# so we store COPTS into $COPTS_FILE (if COPTS has changed since last build)
# and make the object files depend on it
COPTS_FILE = $O/.last-copts
ifneq ("$(COPTS)","$(shell cat $(COPTS_FILE) 2>/dev/null || echo '')")
$(shell $(MKPATH) "$O")
$(file >$(COPTS_FILE),$(COPTS))
endif
#------------------------------------------------------------------------------
# User-supplied makefile fragment(s)
-include makefrag
#------------------------------------------------------------------------------
# Main target
all: $(TARGET_FILES)
$(TARGET_DIR)/% :: $O/%
#mkdir -p $(TARGET_DIR)
$(Q)$(LN) $< $#
ifeq ($(TOOLCHAIN_NAME),clang-msabi)
-$(Q)-$(LN) $(<:%.dll=%.lib) $(#:%.dll=%.lib) 2>/dev/null
endif
$O/$(TARGET): $(OBJS) $(wildcard $(EXTRA_OBJS)) Makefile $(CONFIGFILE)
#$(MKPATH) $O
#echo Creating executable: $#
$(Q)$(CXX) $(LDFLAGS) -o $O/$(TARGET) $(OBJS) $(EXTRA_OBJS) $(AS_NEEDED_OFF) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS)
.PHONY: all clean cleanall depend msgheaders smheaders
.SUFFIXES: .cc
$O/%.o: %.cc $(COPTS_FILE) | msgheaders smheaders
#$(MKPATH) $(dir $#)
$(qecho) "$<"
$(Q)$(CXX) -c $(CXXFLAGS) $(COPTS) -o $# $<
%_m.cc %_m.h: %.msg
$(qecho) MSGC: $<
$(Q)$(MSGC) -s _m.cc -MD -MP -MF $O/$(basename $<)_m.h.d $(MSGCOPTS) $?
%_sm.cc %_sm.h: %.sm
$(qecho) SMC: $<
$(Q)$(SMC) -c++ -suffix cc $(SMCOPTS) $?
msgheaders: $(MSGFILES:.msg=_m.h)
smheaders: $(SMFILES:.sm=_sm.h)
clean:
$(qecho) Cleaning $(TARGET)
$(Q)-rm -rf $O
$(Q)-rm -f $(TARGET_FILES)
$(Q)-rm -f $(call opp_rwildcard, . , *_m.cc *_m.h *_sm.cc *_sm.h)
cleanall:
$(Q)$(CLEANALL_COMMAND)
$(Q)-rm -rf $(PROJECT_OUTPUT_DIR)
help:
#echo "$$HELP_SYNOPSYS"
#echo "$$HELP_TARGETS"
#echo "$$HELP_VARIABLES"
#echo "$$HELP_EXAMPLES"
# include all dependencies
-include $(OBJS:%=%.d) $(MSGFILES:%.msg=$O/%_m.h.d)
It's correct in saying that clang-release/src/v2x is a directory, but it has always been so (even before making the recent changes) and it hasn't produced this error.
Other than the MakeFile error, there is no other error in any of the scripts for the project.
You want to create the executable file clang-release/src/v2x but you can't because that file already exists and is a directory.
The name of the file you attempt to create is
v2x$(D)$(EXE_SUFFIX) and nowhere in your Makefile do you have Make variables D or EXE_SUFFIX defined, so they evaluate to empty strings.
Probably you want to make sure you have D and EXE_SUFFIX defined somewhere.
There is a $(CONFIGFILE) you are including, Make finds it but you did not provide the text of it, check if these variables should be defined in there but are not.
As you can see in this GitHub repo, I downloaded a solution from NIST Random Number Generator Test Suite that contains a makefile and C files in the subdirectories.
According to pg 96 of the documentation provided, I have to run make and then run assess 100 (or any other number). I was able to successfully run make but I can't seem to run assess 100, as it just says "command not found". It's supposed to display this I believe:
I tried to go through this makefile tutorial but I wasn't able to understand what's going on. What do I do?
Here's the top snippet of the makefile, if it helps:
CC = /usr/bin/gcc
GCCFLAGS = -c -Wall
ROOTDIR = .
SRCDIR = $(ROOTDIR)/src
OBJDIR = $(ROOTDIR)/obj
VPATH = src:obj:include
OBJ = $(OBJDIR)/assess.o $(OBJDIR)/frequency.o $(OBJDIR)/blockFrequency.o \
$(OBJDIR)/cusum.o $(OBJDIR)/runs.o $(OBJDIR)/longestRunOfOnes.o \
$(OBJDIR)/serial.o $(OBJDIR)/rank.o $(OBJDIR)/discreteFourierTransform.o \
$(OBJDIR)/nonOverlappingTemplateMatchings.o \
$(OBJDIR)/overlappingTemplateMatchings.o $(OBJDIR)/universal.o \
$(OBJDIR)/approximateEntropy.o $(OBJDIR)/randomExcursions.o \
$(OBJDIR)/randomExcursionsVariant.o $(OBJDIR)/linearComplexity.o \
$(OBJDIR)/dfft.o $(OBJDIR)/cephes.o $(OBJDIR)/matrix.o \
$(OBJDIR)/utilities.o $(OBJDIR)/generators.o $(OBJDIR)/genutils.o
assess: $(OBJ)
$(CC) -o $# $(OBJ) -lm
$(OBJDIR)/assess.o: $(SRCDIR)/assess.c defs.h decls.h utilities.h
$(CC) -o $# -c $(SRCDIR)/assess.c
...
I'm trying to build a project with subdirectories using make, I've gotten the recursive make part working but for some reason, it seems to take the prerequisites of the source file dependencies and appends .o to them and then tries to compile them, which doesn't work obviously, why is it doing this?
The rule in question looks like this:
operations_cache.o : memory_management/operations_cache.cpp memory_management/operations_cache.hpp \
function.hpp operations/operation_base.hpp
cd memory_management && $(MAKE) $#
The rule that compiles the operations directory looks like this:
operation_%.o : function.hpp
cd operations && $(MAKE) $#
for some reason, make keeps trying to say that operations/operation_base.hpp.o is a valid target even though I don't have it listed anywhere in the make file. I've read the documentation for and I didn't see anything in it about trying to implicitly define objects based on prerequisite filenames, so I'm super confused as to what is compelling it to do this.
The error I'm getting is this:
g++ -c -o main.o main.cpp
g++ -c -o node.o node.cpp
cd memory_management && make unique_table.o
make[1]: Entering directory './memory_management'
g++ -o ../unique_table.o -c unique_table.cpp
make[1]: Leaving directory './memory_management'
cd operations && make operations/operation_base.hpp.o
make[1]: Entering directory './operations'
g++ -o ../operations/operation_base.hpp.o -c
g++: fatal error: no input files
compilation terminated.
Makefile:10: recipe for target 'operations/operation_base.hpp.o' failed
make[1]: *** [operations/operation_base.hpp.o] Error 1
make[1]: Leaving directory './operations'
Makefile:24: recipe for target 'operations/operation_base.hpp.o' failed
make: *** [operations/operation_base.hpp.o] Error 2
Edit Added complete files
At user request, here are the complete make files of my 3 directories
./Makefile
CC = g++
objects = main.o node.o unique_table.o operations_cache.o function.o operation_base.o operation_and.o
# shared_lib = nodelib.so
all : edit # $(shared_lib)
edit : $(objects)
$(CC) -o edit $(objects)
main.o : main.cpp node.hpp memory_management/unique_table.hpp memory_management/operations_cache.hpp
node.o : node.cpp node.hpp
unique_table.o : memory_management/unique_table.cpp memory_management/unique_table.hpp node.hpp
cd memory_management && $(MAKE) $#
operations_cache.o : memory_management/operations_cache.cpp memory_management/operations_cache.hpp \
function.hpp operations/operation_base.hpp
cd memory_management && $(MAKE) $#
function.o : function.cpp function.hpp node.hpp memory_management/unique_table.hpp
operation_%.o : function.hpp
cd operations && $(MAKE) $#
.PHONY : clean
clean :
rm edit $(objects)
./operations/Makefile
CC = g++
objects = operation_base.o operation_and.o operation_or.o operation_xor.o operation_restrict.o operation_composition.o operation_satisfy.o operation_satisfy_all.o
proj_dir = ../
operation_base.o : operation_base.cpp operation_base.hpp $(proj_dir)function.hpp
operation_and.o : operation_and.cpp operation_and.hpp operation_base.hpp $(proj_dir)function.hpp
operation_or.o : operation_or.cpp operation_or.hpp operation_base.hpp $(proj_dir)function.hpp
operation_xor.o : operation_xor.cpp operation_xor.hpp operation_base.hpp $(proj_dir)function.hpp
operation_composition.o : operation_composition.cpp operation_composition.hpp operation_base.hpp $(proj_dir)function.hpp
operation_restrict.o : operation_restrict.cpp operation_restrict.hpp operation_base.hpp $(proj_dir)function.hpp
operation_satisfy.o : operation_satisfy.cpp operation_satisfy.hpp operation_base.hpp $(proj_dir)function.hpp
operation_satisfy_all.o : operation_satisfy_all.cpp operation_satisfy_all.hpp operation_satisfy.hpp
%.o :
$(CC) -o $(proj_dir)$# -c $<
./memory_management/Makefile
CC = g++
objects = operations_cache.o unique_table.o
proj_dir = ../
operations_cache.o : operations_cache.cpp operations_cache.hpp \
$(proj_dir)function.hpp $(proj_dir)operations/operation_base.hpp
unique_table.o : unique_table.cpp unique_table.hpp $(proj_dir)node.hpp
%.o :
$(CC) -o $(proj_dir)$# -c $<
Edit I found a solution
Removing memory_management/operations_cache.cpp memory_management/operations_cache.hpp function.hpp operations/operation_base.hpp from the operations_cache.o line solves the problem, it doesn't explain why the error was there, but it works, I'd still be interested in understanding why that happened though.
That's because your operations/operation_base.hpp happens to match operation_%.o rule and due to the fact of built-in rule:
.o:
# Builtin rule
# recipe to execute (built-in):
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $#
It works this way:
check if operations/operation_base.hpp can be updated with an explicit rule (no),
check all implicit (pattern) rules whether they can be resolved (candidate: built-in %: %.o),
check if prerequisite operations/operation_base.hpp.o can be resolved (candidate: operation_%.o: functions.hpp),
check if prerequisite functions.hpp can be resolved (yes, file exists),
follow the rule operation_%.o: functions.hpp with stem operations/base.hpp (execute recipe that fails).
I have prepared a simplified Makefile that reproduces the issue. It requires that both functions.hpp exist and built-in rules are enabled.
all: operations/operation_base.hpp
operation_%.o: functions.hpp
echo Making $# from $<
Output:
# Only Makefile (no functions.hpp)
$ ls
Makefile
$ make
make: *** No rule to make target 'operations/operation_base.hpp', needed by 'all'. Stop.
# Create functions.hpp to fulfill pattern rule (this is the case in question)
$ touch functions.hpp
$ make
echo Making operations/operation_base.hpp.o from functions.hpp
Making operations/operation_base.hpp.o from functions.hpp
# The following output comes from built-in rule %: %.o
cc operations/operation_base.hpp.o -o operations/operation_base.hpp
make: cc: Command not found
<builtin>: recipe for target 'operations/operation_base.hpp' failed
# The same, but with disabled built-in rules
$ make -r
make: *** No rule to make target 'operations/operation_base.hpp', needed by 'all'. Stop.
Generally when you don't know why make decided to do something, it's useful to run it with -d to debug decision making and -p to get final resolved Makefile. It confirms the scenario:
$ make -d
…
No implicit rule found for 'all'.
Considering target file 'operations/operation_base.hpp'.
File 'operations/operation_base.hpp' does not exist.
Looking for an implicit rule for 'operations/operation_base.hpp'.
…
Trying implicit prerequisite 'operations/operation_base.hpp.o'.
Looking for a rule with intermediate file 'operations/operation_base.hpp.o'.
Avoiding implicit rule recursion.
Trying pattern rule with stem 'base.hpp'.
Trying rule prerequisite 'functions.hpp'.
Found an implicit rule for 'operations/operation_base.hpp'.
…
No need to remake target 'functions.hpp'.
Considering target file 'operations/operation_base.hpp.o'.
File 'operations/operation_base.hpp.o' does not exist.
Pruning file 'functions.hpp'.
Finished prerequisites of target file 'operations/operation_base.hpp.o'.
Must remake target 'operations/operation_base.hpp.o'.
echo Making operations/operation_base.hpp.o from functions.hpp
…
Successfully remade target file 'operations/operation_base.hpp.o'.
Finished prerequisites of target file 'operations/operation_base.hpp'.
Must remake target 'operations/operation_base.hpp'.
cc operations/operation_base.hpp.o -o operations/operation_base.hpp
…
make: cc: Command not found
…
<builtin>: recipe for target 'operations/operation_base.hpp' failed
Fragments of resolved Makefile (make -p):
operations/operation_base.hpp: operations/operation_base.hpp.o
# Implicit rule search has been done.
# Implicit/static pattern stem: 'operations/operation_base.hpp'
# Modification time never checked.
# File has been updated.
# Failed to be updated.
# automatic
# # := operations/operation_base.hpp
# automatic
# % :=
# automatic
# * := operations/operation_base.hpp
# automatic
# + := operations/operation_base.hpp.o
# automatic
# | :=
# automatic
# < := operations/operation_base.hpp.o
# automatic
# ^ := operations/operation_base.hpp.o
# automatic
# ? := operations/operation_base.hpp.o
# variable set hash-table stats:
# Load=8/32=25%, Rehash=0, Collisions=1/22=5%
# recipe to execute (built-in):
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $#
operations/operation_base.hpp.o: functions.hpp
# Implicit rule search has been done.
# Implicit/static pattern stem: 'operations/base.hpp'
# File is an intermediate prerequisite.
# File does not exist.
# File has been updated.
# Successfully updated.
# automatic
# # := operations/operation_base.hpp.o
# automatic
# % :=
# automatic
# * := operations/base.hpp
# automatic
# + := functions.hpp
# automatic
# | :=
# automatic
# < := functions.hpp
# automatic
# ^ := functions.hpp
# automatic
# ? := functions.hpp
# variable set hash-table stats:
# Load=8/32=25%, Rehash=0, Collisions=1/13=8%
# recipe to execute (from 'Makefile', line 4):
echo Making $# from $<
Can someone explain me why am I getting the compile error
error: no type named 'VarDictionary' in namespace 'pp'
pp::VarDictionary dictionary;
~~~~^
I'm tying to set a dictionary in the function
virtual void HandleMessage(const pp::Var& message) {
}
I copied the example from the bottom of this Google page https://developer.chrome.com/native-client/devguide/coding/message-system
and tried something simple like this
virtual void HandleMessage(const pp::Var& message) {
pp::VarDictionary dictionary;
pp::VarArray an_array;
an_array.Set(0, pp::Var("string0"));
an_array.Set(1, pp::Var("string1"));
dictionary.Set(pp::Var("param_array"), an_array);
PostMessage(dictionary);
}
but when I compile the code i get the error message for the pp::VarDictionary dictionary; however no problem with the pp::VarArray an_array;
I'm using this Makefile from Google
# Copyright (c) 2013 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# GNU Make based build file. For details on GNU Make see:
# http://www.gnu.org/software/make/manual/make.html
#
#
# Get pepper directory for toolchain and includes.
#
# If NACL_SDK_ROOT is not set, then assume it can be found three directories up.
#
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../..)
# Project Build flags
WARNINGS := -Wno-long-long -Wall -Wswitch-enum -pedantic -Werror
CXXFLAGS := -pthread -std=gnu++98 $(WARNINGS)
#
# Compute tool paths
#
GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
OSNAME := $(shell $(GETOS))
RM := $(OSHELPERS) rm
PNACL_TC_PATH := $(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
PNACL_CXX := $(PNACL_TC_PATH)/bin/pnacl-clang++
PNACL_FINALIZE := $(PNACL_TC_PATH)/bin/pnacl-finalize
CXXFLAGS := -I$(NACL_SDK_ROOT)/include
LDFLAGS := -L$(NACL_SDK_ROOT)/lib/pnacl/Release -lppapi_cpp -lppapi -ljsoncpp
#
# Disable DOS PATH warning when using Cygwin based tools Windows
#
CYGWIN ?= nodosfilewarning
export CYGWIN
# Declare the ALL target first, to make the 'all' target the default build
all: job1.pexe
clean:
$(RM) job1.pexe job1.bc
job1.bc: job1.cc
$(PNACL_CXX) -o $# $< -O2 $(CXXFLAGS) $(LDFLAGS)
job1.pexe: job1.bc
$(PNACL_FINALIZE) -o $# $<
#
# Makefile target to run the SDK's simple HTTP server and serve this example.
#
HTTPD_PY := python $(NACL_SDK_ROOT)/tools/httpd.py
.PHONY: serve
serve: all
$(HTTPD_PY) -C $(CURDIR)
You need to add the header file for var_dictionary.h that is where the class you are trying to access is declared.
Source code for that header is available here
I have the following 3 makefiles which have been generated by some other programmer. I have included my code in between which I have marked with a begin and end. The code intends to include the libspatial index library. The other programmer has the hierarchy root directory---->tools--->r
MakeFile1 corresponds to r, MakeFile2 corresponds to tools and MakeFile3 corresponds to root
Now when I include the library I get the error that
make all
make: *** No rule to make target `bin//home/NP/rtree/spatialindex-src-1.8.0/src/storagemanager/DiskStorageManager.cc', needed by `bin/rdf3xload'. Stop.
I am unable to understand as to what mistake did I make. Can someone be kind enough to help me out.
MakeFile 1
src_tools_r:= \
tools/r/r.cpp \
tools/r/Sorter.cpp \
tools/r/StringLookup.cpp \
tools/r/TempFile.cpp \
/home/NP/rtree/spatialindex-src-1.8.0/src/storagemanager/DiskStorageManager.cc
#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR = /usr/local/lib
CPPFLAGS = -I. \
-I$(COURSE_DIR)
LDFLAGS = -L. \
-L$(COURSE_DIR) \
-R $(LIB_DIR):$(COURSE_DIR)
LDLIBS = -lspatialindex
#Code which I wrote in order to include my library --end
$(PREFIX)r$(EXEEXT): $(addprefix $(PREFIX),$(src_tools_r:.cpp=$(OBJEXT)) $(src_infra:.cpp=$(OBJEXT)) $(src_rts:.cpp=$(OBJEXT)) $(src_cts:.cpp=$(OBJEXT)))
$(buildexe)
MakeFile2
include tools/r/MakeFile1
src_tools:= \
$(src_tools_r) \
#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR = /usr/local/lib
CPPFLAGS = -I. \
-I$(COURSE_DIR)
LDFLAGS = -L. \
-L$(COURSE_DIR) \
-R $(LIB_DIR):$(COURSE_DIR)
LDLIBS = -lspatialindex
#Code which I wrote in order to include my library --end
**MakeFile3
# Include platform dependent makefiles
ifeq ($(OS),Windows_NT)
include Makefile.nt
else
include Makefile.unix
endif
PREFIX:=bin/
#############################################################################
# Default target
all: $(PREFIX)rd$(EXEEXT) $(PREFIX)r$(EXEEXT) $(PREFIX)rq$(EXEEXT) $(PREFIX)ru$(EXEEXT) $(PREFIX)re$(EXEEXT) $(PREFIX)ro$(EXEEXT)
#############################################################################
# Collect all sources
ifeq ($(LINEEDITOR),1)
src_lineeditor:=lineeditor/LineInput.cpp lineeditor/LineEditor.cpp lineeditor/Terminal.cpp lineeditor/Display.cpp lineeditor/Buffer.cpp
endif
include tools/Make2
source:=$(src_cts) $(src_infra) $(src_rts) $(src_tools) $(src_lineeditor)
#############################################################################
# Dependencies
generatedependencies=$(call nativefile,$(PREFIX)makeutil/getdep) -o$(basename $#).d $(IFLAGS) $< $(basename $#)$(OBJEXT) $(genheaders) $(GENERATED-$<)
ifneq ($(IGNORE_DEPENDENCIES),1)
-include $(addprefix $(PREFIX),$(source:.cpp=.d)) $(addsuffix .d,$(basename $(wildcard $(generatedsource))))
endif
#############################################################################
# Compiling
#Code which I wrote in order to include my library --begin
# for CS machines
COURSE_DIR = /home/NP/rtree/spatialindex-src-1.8.0/.libs
LIB_DIR = /usr/local/lib
CPPFLAGS = -I. \
-I$(COURSE_DIR)
LDFLAGS = -L. \
-L$(COURSE_DIR) \
-R $(LIB_DIR):$(COURSE_DIR)
LDLIBS = -lspatialindex
compile=$(CXX) -c $(TARGET)$(call nativefile,$#) $(CXXFLAGS) $(CXXFLAGS-$(firstword $(subst /, ,$<))) $(IFLAGS) $(IFLAGS-$(firstword $(subst /, ,$<))) $(call nativefile,$<)
$(PREFIX)%$(OBJEXT): %.cpp $(PREFIX)makeutil/getdep$(EXEEXT)
$(checkdir)
$(generatedependencies)
$(compile)
#############################################################################
# Cleanup
clean:
find bin -name '*.d' -delete -o -name '*.o' -delete -o '(' -perm -u=x '!' -type d ')' -delete
#############################################################################
# Executable
$(PREFIX)query: $(addprefix $(PREFIX),$(source:.cpp=$(OBJEXT)))
#Code which I wrote in order to include my library --end
If this is an independent library, it should have its own Makefile and should build alone as well.
If you want to integrate your source into the main build process, you must conform to their structure.
You have
different c++ source suffix .cc vs .cpp
This is easily resolvable by renaming your source files to .cpp.
absolute path /home/NP/rtree/... vs relative path tools/r/...
This would involve moving the entire tree into the main build tree, because the rules expect the directories to be accessible from there.
But I think the best is to have a library Makefile and integrate that into the main build.
Unfortunately, there is no easy answer like change variable X and move line Y. I recommend, sit down with your colleague and resolve this Makefile issue together.