Dear All,

I am using the large project makefile from the deal.ii website, but am
having some problems. I have constructed a minimal example below. The
problem is that the linking doesn't work - although the headers are fine
(or else it wouldn't compile) the linker gives the message:

Makefile:125: lib/Makefile.dep: No such file or directory
=====cdG=======2d================== Remaking lib/Makefile.dep
=====cdG=======2d====debug========= ADEquation.cc
=====cdG=======2d====debug========= cdGMethod.cc
=====cdG=======2d================== Linking cdG-2d
lib/2d/cdGMethod.g.o: In function `cdGMethod':
/home/grads/tphj28/Dropbox/Documents/Research/JRC_papers_and_reports/CDG/CDG_code/min_test_2/source/cdGMethod.cc:17:
undefined reference to `ADEquation<2>::ADEquation()'
collect2: ld returned 1 exit status
make: *** [lib/cdG-2d] Error 1

This suggests to me that the Makefile doesn't point to all of the
correct object files (I have confirmed that the object files do exist).
Unfortunately I don't know much about Makefiles, so can't spot the
error. I wouldn't normally post this to the deal.ii mailing list, but as
it seems to be a problem with the makefile from the deal.ii website, I
thought I would.

Thanks,

John


cdGMethod.h--------------------------------------------------

#ifndef CDGMETHOD_H
#define CDGMETHOD_H

#include <dealii_includes.h>

#include <ADEquation.h>

using namespace dealii;

template <int dim>
class cdGMethod
{
  public:
   cdGMethod (unsigned int space);
   ~cdGMethod () {};
  
    void run (void);
  
  private:
    const ADEquation<dim> ad_equation;
};

#endif

cdGMethod.cc-----------------------------------------------
#include <dealii_includes.h>
#include <ADEquation.h>
#include <cdGMethod.h>

using namespace dealii;

#ifndef DEAL_II_DIMENSION
  // This should be picked up from Makefile
  #define DEAL_II_DIMENSION 2
#endif

template <int dim>
cdGMethod<dim>::cdGMethod (unsigned int space)
  :
  ad_equation ()
{
  std::cout << "space " << space << std::endl;
}

template <int dim>
void cdGMethod<dim>::run ()
{

}

int main ()
{
  try
  {
    deallog.depth_console (0);

    cdGMethod<DEAL_II_DIMENSION> cdg_method(2);
    cdg_method.run ();
  }
  catch (std::exception &exc)
  {
    std::cerr << std::endl << std::endl
             << "----------------------------------------------------"
             << std::endl;
    std::cerr << "Exception on processing: " << std::endl
             << exc.what() << std::endl
             << "Aborting!" << std::endl
             << "----------------------------------------------------"
             << std::endl;

    return 1;
  }
  catch (...)
  {
    std::cerr << std::endl << std::endl
             << "----------------------------------------------------"
             << std::endl;
    std::cerr << "Unknown exception!" << std::endl
             << "Aborting!" << std::endl
             << "----------------------------------------------------"
             << std::endl;
    return 1;
  }
  return 0;
}

ADEquation.h---------------------------------------------------------------------

#ifndef ADEQUATION_H
#define ADEQUATION_H

#include <dealii_includes.h>

using namespace dealii;

template <int dim>
class ADEquation
{   
  public:
    ADEquation ();
    ~ADEquation() {};
   
};

#endif

ADEquation.cc-------------------------------------------------------------------

#include <dealii_includes.h>
#include <ADEquation.h>

using namespace dealii;

template <int dim>
ADEquation<dim>::ADEquation (void)
{}

Makefile------------------------------------------------------------------------------

# $Id: Makefile.large 22840 2010-11-22 22:28:16Z bangerth $

# The large projects Makefile looks much like the one for small
# projects. Basically, only the following seven parameters need to be
# set by you:

application-name  = cdG
DEAL_II_DIMENSION = 2

# The next variable tells us the name of the executable. It is prefixed by
# `lib/' to designate its destination directory. Note that the program
# name depends on the dimension, so you can keep copies for the
# different dimensions around:
target   = lib/$(application-name)-$(DEAL_II_DIMENSION)d

# The `debug-mode' variable works as in the small projects Makefile:
debug-mode = on

# And so does the following variable. You will have to set it to
# something reasonable that, for example, includes the location where you
# put output files that you want the `make clean' rule to delete
clean-up-files = *.vtk

# Finally, here is a variable which tells the `run' rule which
# parameters to pass to the executable. Usually, this will be the name
# of an input file.
run-parameters  = parameter-file.prm

# Now, this is the last variable you need to set, namely the path to
# the deal.II toplevel directory:
D = /usr/local/common/user_packages/tphj28/dealii_developer/deal.II

#
#
# Usually, you will not need to change anything beyond this point.
#
#
# This tells `make' where to find the global settings and rules:
include $D/common/Make.global_options


# First get a list of files belonging to the project. Include files
# are expected in `include/', while implementation files are expected
# in `source/'. Object files are placed into `lib/[123]d', using the
# same base name as the `.cc' file.
cc-files    := $(shell echo source/*.cc)
o-files     := $(cc-files:source/%.cc=lib/$(DEAL_II_DIMENSION)d/%.$(OBJEXT))
go-files    :=
$(cc-files:source/%.cc=lib/$(DEAL_II_DIMENSION)d/%.g.$(OBJEXT))
h-files     := $(wildcard include/*.h)
lib-h-files := $(shell echo $D/include/deal.II/*/*.h)

# As before, define two variables that denote the debug and optimized
# versions of the deal.II libraries:
libs.g   := $(lib-deal2.g)
libs.o   := $(lib-deal2.o)



# Now use the information from above to define the set of libraries to
# link with and the flags to be passed to the compiler:
ifeq ($(debug-mode),on)
  libraries = $(go-files) $(libs.g)
  flags     = $(CXXFLAGS.g) -Iinclude
else
  libraries = $(o-files) $(libs.o)
  flags     = $(CXXFLAGS.o) -Iinclude
endif


# Then augment the compiler flags by a specification of the dimension
# for which the program shall be compiled:
flags += -DDEAL_II_DIMENSION=$(DEAL_II_DIMENSION)


# The following two rules define how to compile C++ files into object
# files:
lib/$(DEAL_II_DIMENSION)d/%.g.$(OBJEXT) :
    @echo
=====$(application-name)=======$(DEAL_II_DIMENSION)d====debug=====$(MT)== $(<F)
    @$(CXX) $(flags) -c $< -o $@
lib/$(DEAL_II_DIMENSION)d/%.$(OBJEXT) :
    @echo
=====$(application-name)=======$(DEAL_II_DIMENSION)d====optimized=$(MT)== $(<F)
    @$(CXX) $(flags) -c $< -o $@



# Next define how to link the executable
$(target)$(EXEEXT) : $(libraries) Makefile
    @echo
=====$(application-name)=======$(DEAL_II_DIMENSION)d==============$(MT)== 
Linking
$(@F)
    @$(CXX) -o $@ $(libraries) $(LIBS) $(LDFLAGS)



# Rule how to run the program
run: $(target)$(EXEEXT)
    ./$(target)$(EXEEXT) $(run-parameters)


# Rule how to clean up. This is split into several different rules to
# allow for parallel execution of commands:
clean: clean-lib clean-data
    -rm -f *~ */*~ */*/*~ lib/Makefile.dep

clean-lib:
    -rm -f lib/?d/*.$(OBJEXT) lib/?d/*.g.$(OBJEXT) $(target)$(EXEEXT)
lib/TAGS

clean-data:
    -rm -f $(clean-up-files)


# Again tell `make' which rules are not meant to produce files:
.PHONY: clean clean-data clean-lib run



# Finally produce the list of dependencies. Note that this time, the
# object files end up in directories of their own, so we have to
# modify the output a bit. The file with the dependencies is put into
# `lib/'.
lib/Makefile.dep: $(cc-files) $(h-files) $(lib-h-files) Makefile
    @echo
=====$(application-name)=======$(DEAL_II_DIMENSION)d==================
Remaking $@
    @$D/common/scripts/make_dependencies $(INCLUDE) -Blib $(cc-files) \
     | $(PERL) -p -e 's!^lib/(.*):!lib/$(DEAL_II_DIMENSION)d/$$1:!g;' \
        > $@

include lib/Makefile.dep





_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii

Reply via email to