While compiling C (not c++) code, I am getting error during link time, that certain identifiers have been defined at multiple places, but as shown below, the output is very cryptic.
Is there a way to get better messages from gcc, so that I can see which files are the cause of multiple definitions?
/tmp/cc8kgsLE.o:(.rodata+0x0): multiple definition of `PR_SZ'
/tmp/ccDfv6U4.o:(.rodata+0x0): first defined here
/tmp/cc8kgsLE.o:(.rodata+0x8): multiple definition of `PR_SEC_SZ'
/tmp/ccDfv6U4.o:(.rodata+0x8): first defined here
/tmp/cc8kgsLE.o:(.rodata+0x10): multiple definition of `PR_NSEC_SZ'
/tmp/ccDfv6U4.o:(.rodata+0x10): first defined here
collect2: ld returned 1 exit status
UPDATE: Based on responses, i clarify further that
PR_SZ
, PR_SEC_SZ
, PR_NSEC_SZ
are defined in ONE .h
file, which is protected by #ifndef
, #define
and #endif
macros..
In terms of compiling, i simply type:
gcc -Wall -I. -file1.c file2.c -o file2
UPDATE:
In addition to responses, i found the below link relevant global constants without using #define