Dear friends:
I compile my procedure with mpicc, it can give correct execute file.

mpicc -o testprint testprint.c libptools_ppf.a

But when i compile it with mpic++, it gives me some error about undefined reference. Could you please help me out.

 mpic++ -o testprint testprint.c libptools_ppf.a
testprint.c:25:31: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
testprint.c:25:31: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
testprint.c:25:31: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
testprint.c:25:31: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
testprint.c:25:31: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
testprint.c:25:31: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
/tmp/ccmDrUCj.o: In function `main':
testprint.c:(.text+0x54): undefined reference to `PPF_Print(int, char const*, ...)'
testprint.c:(.text+0x87): undefined reference to `PPF_Print(int, char const*, ...)'
testprint.c:(.text+0xaf): undefined reference to `PPF_Print(int, char const*, ...)'
testprint.c:(.text+0xcd): undefined reference to `PPF_Print(int, char const*, ...)'
testprint.c:(.text+0x103): undefined reference to `PPF_Print(int, char const*, ...)'
/tmp/ccmDrUCj.o:testprint.c:(.text+0x142): more undefined references to `PPF_Print(int, char const*, ...)' follow
collect2: error: ld returned 1 exit status

Conversions between types are more strict in C++ than C (the compiler errors in testprint.c), and you probably didn't "guard" your external C function declarations with extern "C" (the linker errors). So, please show your code.

This article has been dead for over six months. Start a new discussion instead.