[Trilinos-Users] [EXTERNAL] Trilinos, epetra and komplex problem

Perschbacher, Brent M bmpersc at sandia.gov
Wed Jun 19 10:09:06 MDT 2013


Ivan,
  Since you are directly including Epetra files you are effectively
writing C++, even if the code you write yourself is very much C like. This
requires you to change how you include a number of headers to use the C++
names for them. Generally anything that you were including from the C
standard library like stdio or string need to have the ".h" removed and a
"c" prepended to the name. IE "#include <stdio.h>" would be changed to
"#include <cstdio>" This is to ensure that the C functions are in the
correct namespace. Looking at the snippet you provided it looks like you
need to change stdio.h, stdlib.h and math.h. If you would like to maintain
a completely C code there is a package with a C interface to parts of
Trilinos called Ctrilinos. However, I'm not sure how complete it is off
the top of my head, but I believe it covers a significant portion of the
Epetra software stack.

As for the void* conversions, C++ is stricter about that, but without
seeing the lines of code it is complaining about I couldn't offer up
anything useful on how to address it.

One other thing to note. If you are building with mpi it would be much
easier to use the compiler wrappers provided by your mpi implementation,
in this case openmpi. The wrappers often add options to the compiler line
that are necessary to find libraries or headers. Generally the Wrappers
are mpicc for C and mpicxx for C++. I noticed that one of these errors is
because of the include of mpi.h and this might help with that.

Brent

On 6/19/13 1:41 AM, "Ivan Gladich" <igladich at sissa.it> wrote:

>Dear Brent
>thank you very much for your help.
>
>I switched to the g++ compiler and moves the -lepetra and -lkomplex
>flags before all the others...I have others problems...
>I just add the line
>#include "Epetra_SerialDenseMatrix.h"
>to the simple.c file in
>
>../trilinos-11.2.3-Source_MPI/packages/komplex/example/komplex_hb/simple.c
>
>So the first lines of my code looks like
>#include "azk_komplex.h"
>#include "az_aztec.h"
>#include "Epetra_SerialDenseMatrix.h"
>#include <stdio.h>
>#include <stdlib.h>
>#include <math.h>
>#ifdef AZTEC_MPI
>#include <mpi.h>
>#endif
>...
>
> >g++ simple_2.c 
>-I/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/inclu
>de 
>-L/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/lib
>-lkomplex -lepetra -liomp5 -lpthread -lmkl_intel_lp64 -lmkl_intel_thread
>-lmkl_core
>---------------
>In file included from
>/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/include
>/az_f77func.h:48:0,
>from 
>/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/include
>/az_aztec.h:75,
>from 
>/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/include
>/azk_komplex.h:159,
>from simple_2.c:44:
>/usr/include/string.h:548:5: error: Œ__locale_t¹ has not been declared
>/usr/include/string.h:549:33: error: nonnull argument references
>non-pointer operand (argument 1, operand 3)
>/usr/include/string.h:552:18: error: Œ__locale_t¹ has not been declared
>/usr/include/string.h:553:33: error: nonnull argument references
>non-pointer operand (argument 1, operand 4)
>In file included from
>/u/shared/programs/x86_64/gcc/4.5.2/include/c++/4.5.2/bits/localefwd.h:42:
>0,
>from /u/shared/programs/x86_64/gcc/4.5.2/include/c++/4.5.2/ios:42,
>from /u/shared/programs/x86_64/gcc/4.5.2/include/c++/4.5.2/ostream:40,
>from /u/shared/programs/x86_64/gcc/4.5.2/include/c++/4.5.2/iostream:40,
>from 
>/u/shared/programs/x86_64/openmpi/1.6.4/gcc/4.4.7/include/openmpi/ompi/mpi
>/cxx/mpicxx.h:53,
>from /u/shared/programs/x86_64/openmpi/1.6.4/gcc/4.4.7/include/mpi.h:2087,
>from 
>/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/include
>/az_aztec.h:101,
>from 
>/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/include
>/azk_komplex.h:159,
>from simple_2.c:44:
>/u/shared/programs/x86_64/gcc/4.5.2/lib/gcc/x86_64-unknown-linux-gnu/4.5.2
>/../../../../include/c++/4.5.2/x86_64-unknown-linux-gnu/bits/c++locale.h:5
>2:23: 
>error: Œuselocale¹ was not declared in this scope
>/u/shared/programs/x86_64/gcc/4.5.2/lib/gcc/x86_64-unknown-linux-gnu/4.5.2
>/../../../../include/c++/4.5.2/x86_64-unknown-linux-gnu/bits/c++locale.h:5
>2:45: 
>error: invalid type in declaration before Œ;¹ token
>/u/shared/programs/x86_64/gcc/4.5.2/lib/gcc/x86_64-unknown-linux-gnu/4.5.2
>/../../../../include/c++/4.5.2/x86_64-unknown-linux-gnu/bits/c++locale.h:
>In function Œint std::__convert_from_v(__locale_struct* const&, char*,
>int, const char*, ...)¹:
>/u/shared/programs/x86_64/gcc/4.5.2/lib/gcc/x86_64-unknown-linux-gnu/4.5.2
>/../../../../include/c++/4.5.2/x86_64-unknown-linux-gnu/bits/c++locale.h:7
>2:53: 
>error: Œ__gnu_cxx::__uselocale¹ cannot be used as a function
>/u/shared/programs/x86_64/gcc/4.5.2/lib/gcc/x86_64-unknown-linux-gnu/4.5.2
>/../../../../include/c++/4.5.2/x86_64-unknown-linux-gnu/bits/c++locale.h:9
>7:33: 
>error: Œ__gnu_cxx::__uselocale¹ cannot be used as a function
>simple_2.c: In function Œint main(int, char**)¹:
>simple_2.c:113:47: error: invalid conversion from Œvoid*¹ to Œdouble*¹
>simple_2.c:114:47: error: invalid conversion from Œvoid*¹ to Œdouble*¹
>simple_2.c:117:46: error: invalid conversion from Œvoid*¹ to Œint*¹
>simple_2.c:119:38: error: invalid conversion from Œvoid*¹ to Œint*¹
>simple_2.c:121:41: error: invalid conversion from Œvoid*¹ to Œdouble*¹
>simple_2.c:122:41: error: invalid conversion from Œvoid*¹ to Œdouble*¹
>simple_2.c:123:41: error: invalid conversion from Œvoid*¹ to Œdouble*¹
>simple_2.c:124:41: error: invalid conversion from Œvoid*¹ to Œdouble*¹
>simple_2.c:125:42: error: invalid conversion from Œvoid*¹ to Œdouble*¹
>simple_2.c:126:42: error: invalid conversion from Œvoid*¹ to Œdouble*¹
>-----------------------
>
>These are modules loaded on my workstation
>Currently Loaded Modulefiles:
>1) mkl/11.0 2) openmpi/1.6.4/gcc/4.4.7 3) gcc/4.5.2
>
>the last lines seem a problem of c vs. c++ syntax...but the error in
>"error: Œ__locale_t¹ has not been declared" I do not have clue
>Thanks again for your suggestions
>
>Ivan
>
>On 06/18/2013 04:46 PM, Perschbacher, Brent M wrote:
>> Ivan,
>>    The compiler isn't complaining about a missing
>>Epetra_ConfigDefs.hpp, it
>> is complaining about a missing header that is being included by
>> Epetra_ConfigDefs.hpp. There are a couple things wrong with your compile
>> line for simple.c that you'll need to fix if you want to compile
>>examples
>> and your own code against Trilinos. The first, and the cause of your
>> current issue, is that you are using the C compiler when you need to be
>> using the C++ compiler. The missing header "algorithm" is part of the
>>C++
>> standard library which is not included by the C compiler. To fix this
>>just
>> replace the "gcc" in your compile line with g++. Once you've done that
>> you'll run into another issue which you haven't yet, but we can fix
>> easily. You are adding the Trilinos libraries after your blas and lapack
>> libraries(mkl) which will cause you linking errors with Epetra. You need
>> to move your "-lkomplex" and "-lepetra" to before your other -l's to
>> ensure proper linking. Once you make those changes you should be able to
>> compile and link your simple example.
>>
>> I hope this helps.
>>
>> Brent
>>
>> On 6/18/13 5:40 AM, "Ivan Gladich"<igladich at sissa.it>  wrote:
>>
>>> Dear Trilinos users
>>>        I am a new user of Trilinos library and I have a problem to call
>>> epetra for matrix storage
>>> I need to solve a simple linear system A*x=b where A is a complex
>>>matrix
>>> and b a complex vector.
>>> I installed Trilinos package using the following script
>>> --------------------------------
>>> #!/bin/bash
>>> export
>>> 
>>>TRILINOS_DIR="/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_
>>>IV
>>> AN/opt/"
>>> export USE_MPI="ON"
>>> export ccmake=/u/sbp/igladich/opt/cmake-2.8.11-Linux-i386/bin
>>> /u/sbp/igladich/opt/cmake-2.8.11-Linux-i386/bin/cmake \
>>> -D TrilinosFramework_ENABLE_MPI:BOOL=$USE_MPI \
>>> -D CMAKE_INSTALL_PREFIX:PATH=$TRILINOS_DIR \
>>> -D
>>> 
>>>TPL_BLAS_LIBRARIES:STRING="-I/u/shared/programs/x86_64/mkl/11.0.1/mkl/in
>>>cl
>>> ude
>>> -L/u/shared/programs/x86_64/mkl/11.0.1/mkl/lib/intel64 -lmkl_intel_lp64
>>> -lmkl_intel_thread -lmkl_core -liomp5 -lpthread" \
>>> -D TPL_LAPACK_LIBRARIES:STRING="-lmkl_lapack95_lp64" \
>>> -D TPL_ENABLE_MPI:BOOL=ON \
>>> -D BUILD_SHARED_LIBS:BOOL=ON \
>>> -D CMAKE_BUILD_TYPE:STRING=RELEASE \
>>> -D Trilinos_ENABLE_Fortran:BOOL=ON \
>>> -D Trilinos_WARNINGS_AS_ERRORS_FLAGS:STRING="" \
>>> -D CMAKE_VERBOSE_MAKEFILE:BOOL=OFF \
>>> -D Trilinos_ENABLE_TESTS:BOOL=ON \
>>> -D Trilinos_ENABLE_ALL_PACKAGES:BOOL=ON \
>>> -D Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES:BOOL=ON \
>>> -D Trilinos_ENABLE_TrilinosCouplings:BOOL=ON \
>>> $EXTRA_ARGS \
>>> ../
>>> make -j2 install
>>> ---------------------------
>>> The installation went well
>>> Moreover, I was able to compile and execute the the example case in
>>>
>>> 
>>>/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI/packages/kompl
>>>ex
>>> /example/komplex_hb/simple.c
>>>
>>> Using
>>>
>>> gcc simple.c
>>> 
>>>-I/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/inc
>>>lu
>>> de
>>> 
>>>-L/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/lib
>>> -liomp5
>>> -lpthread -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core  -lkomplex
>>>
>>> Now I would like to store my matrix using the utility
>>> #include "Epetra_SerialDense_Matrix.h"
>>>
>>> I started adding the following two lines
>>>
>>> #include "Epetra_ConfigDefs.h"
>>> #include  "Epetra_SerialDenseMatrix.h"
>>>
>>> to my simple.c example with the flag -lepetra in the compilation
>>>line...
>>>
>>> gcc simple_2.c
>>> 
>>>-I/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/inc
>>>lu
>>> de
>>> 
>>>-L/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/lib
>>> -liomp5
>>> -lpthread -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core  -lkomplex
>>> -lepetra
>>>
>>> In file included from simple_2.c:46:0:
>>> 
>>>/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/inclu
>>>de
>>> /Epetra_ConfigDefs.h:51:21:
>>> fatal error: algorithm: No such file or directory
>>> compilation terminated.
>>>
>>> But if I check/
>>> ls
>>> 
>>>/u/sbp/sbpstore2/igladich/libs/trilinos-11.2.3-Source_MPI_IVAN/opt/inclu
>>>de
>>> /
>>>
>>> Epetra_ConfigDefs.h
>>>
>>> is really there..
>>>
>>> Sorry for the (probable) trivial question but I am a new users ...maybe
>>> I have lost something important
>>>
>>> Thanks in advance for any possible help
>>> Best Regards
>>> Ivan Gladich
>>>
>>> -- 
>>> ------
>>> Ivan Gladich, Ph.D.
>>> Research Assistant
>>> International School for Advanced Studies (SISSA)
>>> Via Bonomea 265, I-34136, Trieste,
>>> Italy
>>>
>>> Room: 331
>>> Tel: +390403787335
>>> e-mail: igladich at sissa.it
>>> web page: http://people.sissa.it/~igladich/
>>>
>>> _______________________________________________
>>> Trilinos-Users mailing list
>>> Trilinos-Users at software.sandia.gov
>>> http://software.sandia.gov/mailman/listinfo/trilinos-users
>>
>
>
>-- 
>------
>Ivan Gladich, Ph.D.
>Research Assistant
>International School for Advanced Studies (SISSA)
>Via Bonomea 265, I-34136, Trieste,
>Italy
>
>Room: 331
>Tel: +390403787335
>e-mail: igladich at sissa.it
>web page: http://people.sissa.it/~igladich/
>
>_______________________________________________
>Trilinos-Users mailing list
>Trilinos-Users at software.sandia.gov
>http://software.sandia.gov/mailman/listinfo/trilinos-users




More information about the Trilinos-Users mailing list