Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Linking with PETSc(How can I link my program with PETSc library?)
Linking with PETSc [message #703783] Wed, 27 July 2011 22:50 Go to next message
Matt Bockman is currently offline Matt BockmanFriend
Messages: 1
Registered: July 2011
Junior Member
Hi,

I am running Ubuntu 11.04 and Eclipse 3.5.2. I have compiled the PETSc library in my home directory.

I have an existing C++ project in Eclipse with automatically generated makefiles. The problem is that I cannot seem to link to the PETSc library. A lot of this stuff is way over my head so I'm trying to learn as much as possible but it is a lot to absorb.

Here is the error that I get from Eclipse:

**** Build of configuration Debug for project quad_FEM_svn ****

make all 
Building file: ../SparseMatrixPetsc.c
Invoking: GCC C Compiler
/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/bin/mpicc -I/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/include -I/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/include -I/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/include -O0 -g3 -pg -p -Wall -MMD -MP -MF"SparseMatrixPetsc.d" -MT"SparseMatrixPetsc.d" -o"SparseMatrixPetsc.o" "../SparseMatrixPetsc.c"
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../gcrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/tmp/ccZLkAIH.o: In function `solveMatrix':
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:24: undefined reference to `PetscInitialize'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:24: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:25: undefined reference to `PetscOptionsSetValue'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:25: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:32: undefined reference to `MatCreateSeqAIJ'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:32: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:33: undefined reference to `VecCreateSeq'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:33: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:34: undefined reference to `VecDuplicate'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:34: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:37: undefined reference to `MatSetValues'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:37: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:39: undefined reference to `VecSetValues'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:39: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:40: undefined reference to `VecSetValues'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:40: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:44: undefined reference to `VecSetValues'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:44: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:48: undefined reference to `MatSetValues'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:48: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:49: undefined reference to `MatSetValues'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:49: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:52: undefined reference to `MatSetValues'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:52: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:53: undefined reference to `MatSetValues'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:53: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:54: undefined reference to `MatAssemblyBegin'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:54: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:55: undefined reference to `MatAssemblyEnd'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:55: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:56: undefined reference to `VecAssemblyBegin'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:56: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:57: undefined reference to `VecAssemblyEnd'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:57: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:59: undefined reference to `MatView'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:63: undefined reference to `VecView'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:65: undefined reference to `VecView'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:73: undefined reference to `KSPCreate'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:73: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:74: undefined reference to `KSPSetOperators'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:74: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:76: undefined reference to `KSPSetType'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:76: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:77: undefined reference to `KSPSetInitialGuessNonzero'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:77: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:83: undefined reference to `KSPGetPC'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:83: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:84: undefined reference to `PCSetType'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:84: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:87: undefined reference to `KSPSetFromOptions'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:87: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:88: undefined reference to `KSPSetUp'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:88: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:95: undefined reference to `PCFactorGetMatrix'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:95: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:96: undefined reference to `VecDuplicate'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:96: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:97: undefined reference to `MatGetDiagonal'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:97: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:98: undefined reference to `VecView'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:105: undefined reference to `KSPSolve'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:105: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:106: undefined reference to `KSPGetConvergedReason'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:106: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:113: undefined reference to `KSPGetIterationNumber'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:113: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:118: undefined reference to `VecDestroy'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:118: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:119: undefined reference to `VecDestroy'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:119: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:120: undefined reference to `VecDestroy'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:120: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:121: undefined reference to `MatDestroy'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:121: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:122: undefined reference to `KSPDestroy'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:122: undefined reference to `PetscError'
/home/mdbockman/Documents/Research/codes/quadrilateral_FEM/quad_FEM_svn_local/quad_FEM_svn/Debug/../SparseMatrixPetsc.c:123: undefined reference to `PetscFinalize'
collect2: ld returned 1 exit status
make: *** [SparseMatrixPetsc.o] Error 1


Here is the file I am trying to compile:
/*
 * SparseMatrixPetsc.c
 *
 *  Created on: Jul 26, 2011
 *      Author: mdbockman
 */

#include "SparseMatrixPetsc.h"
#include "petscksp.h"
#include "petscsys.h"

int solveMatrix(int argc,char **argv)
{
  KSP                solver;
  PC                 prec;
  Mat                A,M;
  Vec                X,B,D;
  MPI_Comm           comm;
  PetscScalar        v;
  KSPConvergedReason reason;
  PetscInt           i,j,its;
  PetscErrorCode     ierr;

  ierr = PetscInitialize(&argc,&argv,0,0);CHKERRQ(ierr);
  ierr = PetscOptionsSetValue("-options_left",PETSC_NULL);CHKERRQ(ierr);
  comm = MPI_COMM_SELF;

  /*
   * Construct the Kershaw matrix
   * and a suitable rhs / initial guess
   */
  ierr = MatCreateSeqAIJ(comm,4,4,4,0,&A);CHKERRQ(ierr);
  ierr = VecCreateSeq(comm,4,&B);CHKERRQ(ierr);
  ierr = VecDuplicate(B,&X);CHKERRQ(ierr);
  for (i=0; i<4; i++) {
    v=3;
    ierr = MatSetValues(A,1,&i,1,&i,&v,INSERT_VALUES);CHKERRQ(ierr);
    v=1;
    ierr = VecSetValues(B,1,&i,&v,INSERT_VALUES);CHKERRQ(ierr);
    ierr = VecSetValues(X,1,&i,&v,INSERT_VALUES);CHKERRQ(ierr);
  }

  i=0; v=0;
  ierr = VecSetValues(X,1,&i,&v,INSERT_VALUES);CHKERRQ(ierr);

  for (i=0; i<3; i++) {
    v=-2; j=i+1;
    ierr = MatSetValues(A,1,&i,1,&j,&v,INSERT_VALUES);CHKERRQ(ierr);
    ierr = MatSetValues(A,1,&j,1,&i,&v,INSERT_VALUES);CHKERRQ(ierr);
  }
  i=0; j=3; v=2;
  ierr = MatSetValues(A,1,&i,1,&j,&v,INSERT_VALUES);CHKERRQ(ierr);
  ierr = MatSetValues(A,1,&j,1,&i,&v,INSERT_VALUES);CHKERRQ(ierr);
  ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
  ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
  ierr = VecAssemblyBegin(B);CHKERRQ(ierr);
  ierr = VecAssemblyEnd(B);CHKERRQ(ierr);
  printf("\nA:\n");
MatView(A,0);
//printf("M:\n");
//MatView(M,0);
printf("X:\n");
VecView(X,0);
printf("B:\n");
VecView(B,0);
//printf("D:\n");
//VecView(D,0);

  /*
   * A Conjugate Gradient method
   * with ILU(0) preconditioning
   */
  ierr = KSPCreate(comm,&solver);CHKERRQ(ierr);
  ierr = KSPSetOperators(solver,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);

  ierr = KSPSetType(solver,KSPCG);CHKERRQ(ierr);
  ierr = KSPSetInitialGuessNonzero(solver,PETSC_TRUE);CHKERRQ(ierr);

  /*
   * ILU preconditioner;
   * this will break down unless you add the Shift line,
   * or use the -pc_factor_shift_positive_definite option */
  ierr = KSPGetPC(solver,&prec);CHKERRQ(ierr);
  ierr = PCSetType(prec,PCILU);CHKERRQ(ierr);
  /* ierr = PCFactorSetShiftType(prec,MAT_SHIFT_POSITIVE_DEFINITE);CHKERRQ(ierr); */

  ierr = KSPSetFromOptions(solver);CHKERRQ(ierr);
  ierr = KSPSetUp(solver);CHKERRQ(ierr);

  /*
   * Now that the factorisation is done, show the pivots;
   * note that the last one is negative. This in itself is not an error,
   * but it will make the iterative method diverge.
   */
  ierr = PCFactorGetMatrix(prec,&M);CHKERRQ(ierr);
  ierr = VecDuplicate(B,&D);CHKERRQ(ierr);
  ierr = MatGetDiagonal(M,D);CHKERRQ(ierr);
  printf("\nPivots:\n\n"); VecView(D,0);

  /*
   * Solve the system;
   * without the shift this will diverge with
   * an indefinite preconditioner
   */
  ierr = KSPSolve(solver,B,X);CHKERRQ(ierr);
  ierr = KSPGetConvergedReason(solver,&reason);CHKERRQ(ierr);
  if (reason==KSP_DIVERGED_INDEFINITE_PC) {
    printf("\nDivergence because of indefinite preconditioner;\n");
    printf("Run the executable again but with '-pc_factor_shift_type POSITIVE_DEFINITE' option.\n");
  } else if (reason<0) {
    printf("\nOther kind of divergence: this should not happen.\n");
  } else {
    ierr = KSPGetIterationNumber(solver,&its);CHKERRQ(ierr);
    printf("\nConvergence in %d iterations.\n",(int)its);
  }
  printf("\n");

  ierr = VecDestroy(X);CHKERRQ(ierr);
  ierr = VecDestroy(B);CHKERRQ(ierr);
  ierr = VecDestroy(D);CHKERRQ(ierr);
  ierr = MatDestroy(A);CHKERRQ(ierr);
  ierr = KSPDestroy(solver);CHKERRQ(ierr);
  PetscFinalize();
  return 0;
}


Which is a C file. I haven't yet included this file in any of my other files, but I eventually will. I understand that I need to use some special magic to use C functions in a C++ context.

Also, that code is copied from an example file (except in the example file, the function is called main). The makefile for that example is here:

CFLAGS	        = 
FFLAGS          =
CPPFLAGS        =
FPPFLAGS        =
LOCDIR          = src/ksp/pc/examples/tutorials/
EXAMPLESC       = ex1.c ex2.c ex3.c
EXAMPLESF       =
MANSEC          = PC

include ${PETSC_DIR}/conf/variables
include ${PETSC_DIR}/conf/rules

ex1: ex1.o  chkopts
	-${CLINKER}  -o ex1 ex1.o ${PETSC_KSP_LIB} 
	echo ${PETSC_KSP_LIB}
	${RM} ex1.o

ex2: ex2.o  chkopts
	-${CLINKER}  -o ex2 ex2.o ${PETSC_KSP_LIB} 
	${RM} ex2.o

ex3: ex3.o  chkopts
	-${CLINKER}  -o ex3 ex3.o ${PETSC_KSP_LIB} 
	${RM} ex3.o
#------------------------------------------------------------------------------------
runex3:
	-@${MPIEXEC} -n 1 ./ex3 -ksp_monitor_short > ex3_inode.out 2>&1;
	-@${MPIEXEC} -n 1 ./ex3 -ksp_monitor_short -mat_no_inode > ex3.tmp 2>&1; \
	if (${DIFF} ex3_inode.out ex3.tmp) then true; \
	   else echo "Possible problem with ex3, diffs above"; fi; \
	   ${RM} -f ex3_inode.out; ${RM} -f ex3.tmp

runex3_pd:
	-@${MPIEXEC} -n 1 ./ex3 -ksp_monitor_short -pc_factor_shift_type POSITIVE_DEFINITE > ex3_inode.out 2>&1;
	-@${MPIEXEC} -n 1 ./ex3 -ksp_monitor_short -pc_factor_shift_type POSITIVE_DEFINITE -mat_no_inode > ex3.tmp 2>&1; \
	if (${DIFF} ex3_inode.out ex3.tmp) then true; \
	   else echo "Possible problem with ex3, diffs above"; fi; \
	   ${RM} -f ex3_inode.out; ${RM} -f ex3.tmp

TESTEXAMPLES_C	   = ex3.PETSc runex3 runex3_pd ex3.rm 
TESTEXAMPLES_C_X11 = ex2.PETSc ex2.rm

include ${PETSC_DIR}/conf/test


I understand that I can create my own makefile. Indeed I have compiled the example by itself using a separate project and creating my own makefile. However, it would be really painful to have to make my own makefile for this project and I'm hoping there is a better way to include a library.

Thanks in advance for your help,
Matt

(BTW, I originally tried to use pastebin but the forum does not allow any links during the first 5 posts, I know it's a lot of code!)
Re: Linking with PETSc [message #707398 is a reply to message #703783] Mon, 01 August 2011 15:42 Go to previous messageGo to next message
lokuz Mising name is currently offline lokuz Mising nameFriend
Messages: 3
Registered: August 2011
Junior Member
Did you find a solution to this problem?
Re: Linking with PETSc [message #707855 is a reply to message #703783] Tue, 02 August 2011 06:30 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
http://wiki.eclipse.org/CDT/User/FAQ#Adding_C.2FC.2B.2B_External_Libraries

Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Linking with PETSc [message #709733 is a reply to message #707855] Thu, 04 August 2011 08:37 Go to previous message
lokuz Mising name is currently offline lokuz Mising nameFriend
Messages: 3
Registered: August 2011
Junior Member
Thanks for your answer. The problem is not adding a normal lib to the project settings. The troublemaker is the

include ${PETSC_DIR}/conf/variables
include ${PETSC_DIR}/conf/rules

part of the makefile below. Of course you can set the whole stuff in there by hand, but this is really tedious. AFAIK there is no possiblily to add autmatically insert line to the CDT generated makefile.
Previous Topic:Active statement in debugger background color
Next Topic:change name of project directory
Goto Forum:
  


Current Time: Sat Apr 20 03:35:02 GMT 2024

Powered by FUDForum. Page generated in 0.03277 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top