Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29234 Discussions

C interoperability when using icpc as a c compiler

bbourdin
Beginner
414 Views
Hi,
Is it possible to use icpc as the C compiler when interfacing fortran and C using iso_c_binding?
I would like to link my code to petsc without using their fortran binding (hence gaining access to some of the functions that are not exposed to fortran), but for some reasons, I need to compile petsc using icpc as my c compiler.
I am attaching a very simple example which works fine when using icc as the c compiler, but fais to link when using icpc as the c compiler:
Everything works fine with icc
MacPro:Interop3 blaise$ make clean && make
ifort -g -c TestF2003_C.f90
icc -g -c cfunc.c
ifort -g -o TestF2003_C TestF2003_C.o cfunc.o
but if I use icpc as the c compiler, linking fails
MacPro:Interop3 blaise$ make clean && make CC=icpc
ifort -g -c TestF2003_C.f90
icpc -g -c cfunc.c
ifort -g -o TestF2003_C TestF2003_C.o cfunc.o
Undefined symbols:
"___gxx_personality_v0", referenced from:
CIE in cfunc.o
ld: symbol(s) not found
make: *** [TestF2003_C] Error 1
I am assuming that I need to add some library to the linking command, but which one?
Regards,
Blaise
0 Kudos
1 Reply
bbourdin
Beginner
414 Views
I am replying to myself, since this may be useful to somebody:gxx_personality is defined in libstdc++, so when using icpc as the C compiler, it needs to be added to the link command
0 Kudos
Reply