How to avoid multiple definition linking error?
问题 Beside moving the hello() function into another source (.cpp) file or renaming the function. Is there any other methods to avoid the linking error? staticLibA.h #ifndef _STATIC_LIBA_HEADER #define _STATIC_LIBA_HEADER int hello(void); int hello_staticLibA_only(void); #endif staticLibA.cpp #include "staticLibA.h" int hello(void) { printf("\nI'm in staticLibA\n"); return 0; } int hello_staticLibA_only(void) { printf("\nstaticLibA: hello_staticLibA_only\n"); return 0; } output: g++ -c -Wall -fPIC