Hi, [--with-shared=0, and do not use --with-dyanmic] I compiled petsc and link the static lib with my makefile "ADDLIBSTATIC := $(ADDLIBSTATIC) $(PETSC_LIBDIR)/ libpetsccontrib.a $(PETSC_LIBDIR)/libpetscksp.a $(PETSC_LIBDIR)/libpetscsnes.a $(PETSC_LIBDIR)/libpetscvec.a $(PETSC_LIBDIR)/libpetsc.a $(PETSC_LIBDIR)/libpetscdm.a $(PETSC_LIBDIR)/libpetscmat.a $(PETSC_LIBDIR)/libpetscts.a" The result was the same as before. So I really wonder how to link petsc with static library? This is useful when I could not generate shared library. Tomorrow morning I will try the *setCompilers.py *that you sent me for avoiding the error of -PIC. it is 00:37, I will go to sleep. See you tomorrow. Good night. yours sincerely Weidong
On Tue, Mar 10, 2009 at 10:53 PM, Satish Balay <balay at mcs.anl.gov> wrote: > > > On Tue, 10 Mar 2009, Wei-Dong Lian wrote: > > > Now I also found a problem for my computer about using petsc. > > In my computer, petsc can be compiled successfully without any problem. > So I > > use the *.so library to link into my programme, it worked very well. But > > today I just have a try to link *.a library into my programme and it can > not > > be compiled successfully. > > Why do you want to do this? [When shared libraries exist - the > compiler prefers then - instead of static. So you should just stick > with the compiler default behavior. And if build PETSc with > --with-dynamic - then the .a files are useless anyway.] > > So the shared vs static usage should be chosen at PETSc configure step. > [--with-shared=1/0, and do not use --with-dyanmic] > > > So you should just use: > > ADDLIB := $(ADDLIB) -L$(PETSC_LIBDIR) -Wl,-rpath,$(PETSC_LIBDIR) > -lpetsccontrib -lpetscts -lpetscsnes -lpetscksp -lpetscdm > -lpetscmat -lpetscvec -lpetsc > > > Satish > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20090311/5063a293/attachment.htm>
