OK, I have realised that in that particular example libhwloc is linked twice, but removing either one also gives errors.<br><br>On Saturday, March 9, 2013 2:30:33 PM UTC+1, mirix wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Hello,<br><br>I would like to know if there are any general rules on the correct order for linking libraries when compiling CP2K.<br><br>For instance, I have this:<br><br>LIBS     = -L/home/mirix/hwloc/lib/<wbr>libhwloc.a -lxml2 -lpci\<br>/home/mirix/Software/cp2k/<wbr>cp2k-2.3/tools/build_libsmm/<wbr>lib/libsmm_znn.a\<br>/home/mirix/Software/cp2k/<wbr>scalapack-2.0.2/libscalapack.<wbr>a\<br>$(ATLASPATH)/liblapack.a\<br>$(ATLASPATH)/libcblas.a\<br>$(ATLASPATH)/libf77blas.a\<br>$(ATLASPATH)/libptcblas.a\<br>$(ATLASPATH)/libptf77blas.a\<br>$(ATLASPATH)/libatlas.a\<br>$(LIBINTPATH)/libderiv.a\<br>$(LIBINTPATH)/libr12.a\<br>$(LIBINTPATH)/libint.a\<br>/usr/local/lib/libfftw3f.a\<br>/usr/local/cuda/lib64/<wbr>libcudart.so.5.0\<br>/usr/local/cuda/lib64/<wbr>libcufft.so.5.0\<br>/usr/local/cuda/lib64/<wbr>libcublas.so.5.0\<br>/home/mirix/hwloc/lib/<wbr>libhwloc.a -lxml2 -lpci\<br>-lstdc++ -lpthread -lrt<br><br><br>This gives: cuda_cublas.f90:(.text+0x91): undefined reference to `cpu_d_gemm_'<br><br>Depending on the order of the libraries I receive different "undefined reference" errors. I am trying different options, but I still have not found a working combination.<br><br>Any ideas?<br><br>Best regards,<br><br>Miro<br></blockquote>