When GCC compiles, undefined reference to appears

1. Under folder A, there is a folder B
2. Generate static libraries in folder B, assuming that the ld.a, source code is written in C
3. The .CPP file in folder A, a function that references the source code in folder B, and links to the static library at compile time
4. Compile the code in file A with gPP, but there will be an error:

    main.cpp:(.text+0x120e): undefined reference to `OpenConf()"

5. Looking at the symbols of the static library ld.a, it is found that OpenConf exists

    0000000000000c00   276 FUNC    GLOBAL DEFAULT    1 OpenConf

6. Execute the command: objdump-d-r main.o related information:

    120d:    e8 00 00 00 00           callq  1212 <main+0x22e>
    120e: R_X86_64_PLT32    _Z8OpenConfv-0x4

7. Execute command: readelf-r main.o related information:

    00000000120e  00d500000004 R_X86_64_PLT32    0000000000000000 _Z8OpenConfv - 4
    
    
When

compiles, the link to the library does not report an error, which is correct. Now do not know how to debug, how to find errors?


when using C library functions in CPP, did you add extern "C" {}? Otherwise, the link will not be found.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e824ca-4e095.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e824ca-4e095.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?