Hi,
I finally understand the whole thing.
I was having a wrong impression that I could make a C program call a C+
+ library if g++ is used in the command, even without extern "C" in
the library header.
So I thought extern "C" is used for situations where gcc is used in
the compile command.
But I was wrong.
If there's no extern "C" in the library head file, trying to compile a
C main program (use g++) would give you undefined reference errors.
To get rid of those errors, include extern "C" in the head file.
Like tragomaskhalos said, use #ifdef __cplusplus in the head file, so
the same head file could be used for building the library and for
building the main program.
And the last step is to use g++ to compile the main program. gcc won't
work.