title: Trilinos - c++: error trying to exec 'cc1plus': execvp: No such file or directory
body: <p>I want to write a simple program which uses Trilinos. After many problems with configuration script I've managed to write it, so it launches without any problem. The problem is, when I try to compile my own code ( both Makefile and my test program I've rewritten according to the original examples ), it throws the error:</p>
  
  <pre><code>c++: error trying to exec '/usr/lib/gcc/x86_64-linux-gnu/4.9/cc1plus': execv: Argument list too long
  </code></pre>
  
  <p>So I tried to launch my Makefile with <code>env -i make</code> to make enough space for "the arguments". It worked, but now it throws another error:</p>
  
  <pre><code>c++: error trying to exec 'cc1plus': execvp: No such file or directory
  Makefile:62: recipe for target 'test.o' failed
  make: *** [test.o] Error 1
  </code></pre>
  
  <hr>
  
  <h2>My attempts:</h2>
  
  <p>I've tried to find any solution to this problem, but I've found nothing which worked so far. </p>
  
  <h3>I've checked if my GCC and G++ are the same version and they are:</h3>
  
  <pre><code>gcc (Ubuntu 4.9.1-16ubuntu6) 4.9.1
  Copyright (C) 2014 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  
  g++ (Ubuntu 4.9.1-16ubuntu6) 4.9.1
  Copyright (C) 2014 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  </code></pre>
  
  <h3>Then I've tried to reinstall G++:</h3>
  
  <pre><code>sudo aptitude reinstall g++-4.9
  </code></pre>
  
  <p>Still, no success.</p>
  
  <h3>Finally I've checked, if my <code>g++</code> command points to the correct destination:</h3>
  
  <pre><code>martin@martin-Aspire-E1-531:~$ which g++
  /usr/bin/g++
  </code></pre>
  
  <p><code>/usr/bin/g++</code> is a link to the file <code>g++-4.9</code>, which is a correct file to launch the compiler. </p>
  
  <p>So, I don't have any idea what should I do know to compile it correctly. Do you?</p>
  
  <hr>
  
  <h2>My files</h2>
  
  <h3>.do-configure(file for configuring Trilinos)</h3>
  
  <pre><code>#!/bin/bash
  
  # Set this to the root of your Trilinos source directory.
  TRILINOS_SOURCE_PATH=~/Stazene/trilinos-11.12.1-Source
  
  #
  # You can invoke this shell script with additional command-line
  # arguments.  They will be passed directly to CMake.
  #
  EXTRA_ARGS=$@
  
  #
  # Each invocation of CMake caches the values of build options in a
  # CMakeCache.txt file.  If you run CMake again without deleting the
  # CMakeCache.txt file, CMake won't notice any build options that have
  # changed, because it found their original values in the cache file.
  # Deleting the CMakeCache.txt file before invoking CMake will insure
  # that CMake learns about any build options you may have changed.
  # Experience will teach you when you may omit this step.
  #
  rm -f CMakeCache.txt
  
  #
  # Enable all primary stable Trilinos packages.
  #
  cmake \
    -D CMAKE_INSTALL_PREFIX:FILEPATH="~/.trilinos" \
    -D CMAKE_BUILD_TYPE:STRING=DEBUG \
    -D CMAKE_C_COMPILER=/usr/bin/mpicc \
    -D CMAKE_CXX_COMPILER=/usr/bin/mpicxx \
    -D CMAKE_Fortran_COMPILER=/usr/bin/mpif90 \
    -D TPL_ENABLE_MPI:BOOL=ON \
    -D MPI_BASE_DIR:FILEPATH="/usr/include/mpi" \
    -D MPI_EXEC:FILEPATH="/usr/include/mpiexec" \
    -D Boost_INCLUDE_DIRS="/usr/include/boost" \
    -D Trilinos_ENABLE_Fortran:BOOL=OFF \
    -D Trilinos_ENABLE_SECONDARY_TESTED_CODE=ON \
    -D Trilinos_ENABLE_TESTS:BOOL=ON \
    -D Trilinos_ENABLE_Epetra=ON \
    -D Trilinos_ENABLE_ALL_PACKAGES:BOOL=ON \
  $EXTRA_ARGS \
  $TRILINOS_SOURCE_PATH
  </code></pre>
  
  <h3>Makefile</h3>
  
  <pre><code># CMAKE File for "MyApp" application building against an installed Trilinos
  
  #This file is an adaptation of the CMakeLists.txt file that was converted from 
  #the buildAgainstTrilinos example. This Makefile was designed to be used in a
  #flat directory structure. If you would like to run this example you will need
  #put this file and src_file.cpp, src_file.hpp, main_file.cpp from
  #buildAgainstTrilinos into a new directory. You will then need to set the
  #environment variable MYAPP_TRILINOS_DIR to point to your base installation of
  #Trilinos. Note that this example assumes that the installation of Trilinos that
  #you point to has Epetra enabled.
  
  # Get Trilinos as one entity
  include ~/.trilinos/Makefile.export.Trilinos
  
  # Make sure to use same compilers and flags as Trilinos
  CXX_WITH_ECHO=$(Trilinos_CXX_COMPILER)
  CXX_WITHOUT_ECHO=@$(Trilinos_CXX_COMPILER)
  
  CXX=$(CXX_WITHOUT_ECHO)
  CC=$(Trilinos_C_COMPILER)
  FORT=$(Trilinos_Fortran_COMPILER)
  
  CXX_FLAGS=$(Trilinos_CXX_COMPILER_FLAGS) $(USER_CXX_FLAGS)
  C_FLAGS=$(Trilinos_C_COMPILER_FLAGS) $(USERC_FLAGS)
  FORT_FLAGS=$(Trilinos_Fortran_COMPILER_FLAGS) $(USER_FORT_FLAGS)
  
  INCLUDE_DIRS=$(Trilinos_INCLUDE_DIRS) $(Trilinos_TPL_INCLUDE_DIRS)
  LIBRARY_DIRS=$(Trilinos_LIBRARY_DIRS) $(Trilinos_TPL_LIBRARY_DIRS)
  LIBRARIES=$(Trilinos_LIBRARIES) $(Trilinos_TPL_LIBRARIES)
  
  LINK_FLAGS=$(Trilinos_EXTRA_LD_FLAGS)
  
  #just assuming that epetra is turned on.
  DEFINES=-DMYAPP_EPETRA
  
  
  default: build_all
  
  # Echo trilinos build info just for fun
  info:
      @echo "\nFound Trilinos!  Here are the details: "
      @echo "   Trilinos_VERSION = $(Trilinos_VERSION)"
      @echo "   Trilinos_PACKAGE_LIST = $(Trilinos_PACKAGE_LIST)"
      @echo "   Trilinos_LIBRARIES = $(Trilinos_LIBRARIES)"
      @echo "   Trilinos_INCLUDE_DIRS = $(Trilinos_INCLUDE_DIRS)"
      @echo "   Trilinos_LIBRARY_DIRS = $(Trilinos_LIBRARY_DIRS)"
      @echo "   Trilinos_TPL_LIST = $(Trilinos_TPL_LIST)"
      @echo "   Trilinos_TPL_INCLUDE_DIRS = $(Trilinos_TPL_INCLUDE_DIRS)"
      @echo "   Trilinos_TPL_LIBRARIES = $(Trilinos_TPL_LIBRARIES)"
      @echo "   Trilinos_TPL_LIBRARY_DIRS = $(Trilinos_TPL_LIBRARY_DIRS)"
      @echo "   Trilinos_BUILD_SHARED_LIBS = $(Trilinos_BUILD_SHARED_LIBS)"
      @echo "End of Trilinos details\n"
  
  build_all: test.out
      @echo "CXX_FLAGS: $(CXX_FLAGS)"
  
  # build the 
  test.out: test.o
      $(CXX) $(CXX_FLAGS) test.cpp -o test.out $(LINK_FLAGS) $(INCLUDE_DIRS) $(DEFINES) $(LIBRARY_DIRS) $(LIBRARIES)
  
  test.o:
      $(CXX) -c $(CXX_FLAGS) $(INCLUDE_DIRS) $(DEFINES) test.cpp
  
  .PHONY: clean
  clean:
      rm -f *.o *.a *.exe *.out
  </code></pre>
  
  <h3>.CPP file</h3>
  
  <pre><code>//
  // This example includes conditional MPI initialization, getting an
  // Epetra communicator wrapper, and printing out Epetra version
  // information.
  //
  
  // This defines useful macros like HAVE_MPI, which is defined if and
  // only if Epetra was built with MPI enabled.
  #include &lt;Epetra_config.h&gt;
  
  #ifdef HAVE_MPI
      // Your code is an existing MPI code, so it presumably includes mpi.h directly.
      #  include &lt;mpi.h&gt;
      // Epetra's wrapper for MPI_Comm.  This header file only exists if
      // Epetra was built with MPI enabled.
      #  include &lt;Epetra_MpiComm.h&gt;
  #else
      #  include &lt;Epetra_SerialComm.h&gt;
  #endif // HAVE_MPI
  
  #include &lt;Epetra_Version.h&gt;
  
  
  //
  // ... Your other include files go here ...
  //
  
  // Do something with the given communicator.  In this case, we just
  // print Epetra's version to the given output stream, on Process 0.
  void exampleRoutine (const Epetra_Comm&amp; comm, std::ostream&amp; out) {
      if (comm.MyPID () == 0) {
      // On (MPI) Process 0, print out the Epetra software version.
        out &lt;&lt; Epetra_Version () &lt;&lt; std::endl &lt;&lt; std::endl;
      }
  }
  
  int main (int argc, char *argv[]) {
      // These "using" declarations make the code more concise, in that
      // you don't have to write the namespace along with the class or
      // object name.  This is especially helpful with commonly used
      // things like std::endl.
      using std::cout;
      using std::endl;
  
      #ifdef HAVE_MPI
          // Start up MPI, if using MPI.  Trilinos doesn't have to be built
          // with MPI; it's called a "serial" build if you build without MPI.
          //
          // It's bad form to ignore the error codes returned by MPI
          // functions, but we do so here for brevity.
          (void) MPI_Init (&amp;argc, &amp;argv);
          cout &lt;&lt; "MPI ok" &lt;&lt; endl;
  
          // Wrap MPI_COMM_WORLD in an Epetra communicator wrapper.
          // Epetra_MpiComm is a subclass of Epetra_Comm, so you may use it
          // wherever an Epetra_Comm is required.
          Epetra_MpiComm comm (MPI_COMM_WORLD);
      #else
          // Make a "serial" (non-MPI) communicator.  It doesn't actually
          // "communicate," because it only has one process, whose rank is
          // always 0.  Epetra_SerialComm is a subclass of Epetra_Comm, so you
          // may use it wherever an Epetra_Comm is required.
          Epetra_SerialComm comm;
          cout &lt;&lt; "Serial" &lt;&lt; endl;
      #endif
  
      // Epetra_Comm has methods that wrap basic MPI functionality.
      // MyPID() is equivalent to MPI_Comm_rank, and NumProc() to
      // MPI_Comm_size.
      //
      // With a "serial" communicator, the rank is always 0, and the
      // number of processes is always 1.
      const int myRank = comm.MyPID ();
      const int numProcs = comm.NumProc ();
  
      cout &lt;&lt; "My PID is:" &lt;&lt; myRank &lt;&lt; endl;
  
      if (myRank == 0) {
          cout &lt;&lt; "Total number of processes: " &lt;&lt; numProcs &lt;&lt; endl;
      }
  
      // Do something with the new Epetra communicator.
      exampleRoutine (comm, cout);
  
      // This tells the Trilinos test framework that the test passed.
      if (comm.MyPID () == 0) {
          cout &lt;&lt; "End Result: TEST PASSED" &lt;&lt; endl;
      }
  
      #ifdef HAVE_MPI
          // Since you called MPI_Init, you are responsible for calling
          // MPI_Finalize after you are done using MPI.
          (void) MPI_Finalize ();
      #endif // HAVE_MPI
  
      return 0;
  }
  </code></pre>