gcov linker errors
-
I have now build both project and its library using ARM architecture. The library compiles and links - no error. The library contains one test C++ class with only constructor / destructor implemented. This is important to note - see the NOTEs at the end of the post. The main program compiles but fails to link with errors indicating problem with "gcov". The attached partial crosscompiler make output of library build indicates addition of "gcov" related options. They have been put there as standard IDE options for building library. I did NOT added these options.
make -j4 all
Building file: ../MODULE/M_ARM_TEST/CARMTEST.cpp
Invoking: Cross G++ Compiler
arm-linux-gnueabihf-g++ -O0 -g3 -p -pg -ftest-coverage -fprofile-arcs -Wall -c -fmessage-length=0 -v -MMD -MP -MF"MODULE/M_ARM_TEST/CARMTEST.d" -MT"MODULE/M_ARM_TEST/CARMTEST.o" -o "MODULE/M_ARM_TEST/CARMTEST.o" "../MODULE/M_ARM_TEST/CARMTEST.cpp"
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-g++The attached partial output of main program posts the "gcov" errors.
lRPI_BT_LIB_ARM -lbluetooth
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/libRPI_BT_LIB_ARM.a(CARMTEST.o): In function `_GLOBAL__sub_I_65535_0__ZNSt10C_ARM_TESTC2Ev':
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/../MODULE/M_ARM_TEST/CARMTEST.cpp:42: undefined reference to `__gcov_init'
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/libRPI_BT_LIB_ARM.a(CARMTEST.o):(.data+0x28): undefined reference to `__gcov_merge_add'
collect2: error: ld returned 1 exit statusNOTE The library source code line #42 is where error is actually indicated in output , at the closing bracket of "std" namespace comment NOTE 42 } /* namespace std */ 1. What is the purpose of having -ftest-coverage -fprofile-arcs option SPECIFICALLY for library? I do not have them in any other IDE build programs. I did not try to delete them, perhaps after I have some more knowledge about their purpose. 2. I did try to add -lgcov to program linker but it did not work. I understand that gcov is some kind of utility tracking application and not sure why I need it. Any help woudl be appreciated. Cheers
-
I have now build both project and its library using ARM architecture. The library compiles and links - no error. The library contains one test C++ class with only constructor / destructor implemented. This is important to note - see the NOTEs at the end of the post. The main program compiles but fails to link with errors indicating problem with "gcov". The attached partial crosscompiler make output of library build indicates addition of "gcov" related options. They have been put there as standard IDE options for building library. I did NOT added these options.
make -j4 all
Building file: ../MODULE/M_ARM_TEST/CARMTEST.cpp
Invoking: Cross G++ Compiler
arm-linux-gnueabihf-g++ -O0 -g3 -p -pg -ftest-coverage -fprofile-arcs -Wall -c -fmessage-length=0 -v -MMD -MP -MF"MODULE/M_ARM_TEST/CARMTEST.d" -MT"MODULE/M_ARM_TEST/CARMTEST.o" -o "MODULE/M_ARM_TEST/CARMTEST.o" "../MODULE/M_ARM_TEST/CARMTEST.cpp"
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-g++The attached partial output of main program posts the "gcov" errors.
lRPI_BT_LIB_ARM -lbluetooth
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/libRPI_BT_LIB_ARM.a(CARMTEST.o): In function `_GLOBAL__sub_I_65535_0__ZNSt10C_ARM_TESTC2Ev':
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/../MODULE/M_ARM_TEST/CARMTEST.cpp:42: undefined reference to `__gcov_init'
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/libRPI_BT_LIB_ARM.a(CARMTEST.o):(.data+0x28): undefined reference to `__gcov_merge_add'
collect2: error: ld returned 1 exit statusNOTE The library source code line #42 is where error is actually indicated in output , at the closing bracket of "std" namespace comment NOTE 42 } /* namespace std */ 1. What is the purpose of having -ftest-coverage -fprofile-arcs option SPECIFICALLY for library? I do not have them in any other IDE build programs. I did not try to delete them, perhaps after I have some more knowledge about their purpose. 2. I did try to add -lgcov to program linker but it did not work. I understand that gcov is some kind of utility tracking application and not sure why I need it. Any help woudl be appreciated. Cheers
It is not clear where that reference is coming from, but most likely in one of the header files if you did not make a specific call to it. Or did you call to some other library which in turn requires gcov? Take a look at __gcov_init - Google Search[^] for some similar issues.
-
It is not clear where that reference is coming from, but most likely in one of the header files if you did not make a specific call to it. Or did you call to some other library which in turn requires gcov? Take a look at __gcov_init - Google Search[^] for some similar issues.
Thanks for reply, I did ask Mrs Google - and this is a common , used by others, way to fix the error. # compile with coverage CFLAGS += -g -fprofile-arcs -ftest-coverage LDFLAGS += -lgcov I did added -lgcov , but it did not work. This error showed up after I added the new library which has no code , no headers, except one test class. There are no other library referenced in this new add.
-
Thanks for reply, I did ask Mrs Google - and this is a common , used by others, way to fix the error. # compile with coverage CFLAGS += -g -fprofile-arcs -ftest-coverage LDFLAGS += -lgcov I did added -lgcov , but it did not work. This error showed up after I added the new library which has no code , no headers, except one test class. There are no other library referenced in this new add.
Vaclav_ wrote:
This error showed up after I added the new library
Well that should give you a clue. The only way to find out what is happening is to look into the addition that caused the message. For some reason that new library must be calling the error.
-
I have now build both project and its library using ARM architecture. The library compiles and links - no error. The library contains one test C++ class with only constructor / destructor implemented. This is important to note - see the NOTEs at the end of the post. The main program compiles but fails to link with errors indicating problem with "gcov". The attached partial crosscompiler make output of library build indicates addition of "gcov" related options. They have been put there as standard IDE options for building library. I did NOT added these options.
make -j4 all
Building file: ../MODULE/M_ARM_TEST/CARMTEST.cpp
Invoking: Cross G++ Compiler
arm-linux-gnueabihf-g++ -O0 -g3 -p -pg -ftest-coverage -fprofile-arcs -Wall -c -fmessage-length=0 -v -MMD -MP -MF"MODULE/M_ARM_TEST/CARMTEST.d" -MT"MODULE/M_ARM_TEST/CARMTEST.o" -o "MODULE/M_ARM_TEST/CARMTEST.o" "../MODULE/M_ARM_TEST/CARMTEST.cpp"
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-g++The attached partial output of main program posts the "gcov" errors.
lRPI_BT_LIB_ARM -lbluetooth
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/libRPI_BT_LIB_ARM.a(CARMTEST.o): In function `_GLOBAL__sub_I_65535_0__ZNSt10C_ARM_TESTC2Ev':
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/../MODULE/M_ARM_TEST/CARMTEST.cpp:42: undefined reference to `__gcov_init'
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB_ARM/Debug/libRPI_BT_LIB_ARM.a(CARMTEST.o):(.data+0x28): undefined reference to `__gcov_merge_add'
collect2: error: ld returned 1 exit statusNOTE The library source code line #42 is where error is actually indicated in output , at the closing bracket of "std" namespace comment NOTE 42 } /* namespace std */ 1. What is the purpose of having -ftest-coverage -fprofile-arcs option SPECIFICALLY for library? I do not have them in any other IDE build programs. I did not try to delete them, perhaps after I have some more knowledge about their purpose. 2. I did try to add -lgcov to program linker but it did not work. I understand that gcov is some kind of utility tracking application and not sure why I need it. Any help woudl be appreciated. Cheers
SOLVED Added --coverage to main program linker options. From description it should make no difference if it is complier or linker option. Still not sure if I ever use if it supposedly created (where?) the "gconv" utility "executable" which I did not program.
-
Thanks for reply, I did ask Mrs Google - and this is a common , used by others, way to fix the error. # compile with coverage CFLAGS += -g -fprofile-arcs -ftest-coverage LDFLAGS += -lgcov I did added -lgcov , but it did not work. This error showed up after I added the new library which has no code , no headers, except one test class. There are no other library referenced in this new add.
-lgcov is not a linker directive it's a library link and it won't work in LDFLAGS The library links needs to go on the extreme right of the final linker call So I am clear that is the last call that joins all the individual compiles up. So there is exactly one line it needs to go on which is the final line executed to link
In vino veritas
-
-lgcov is not a linker directive it's a library link and it won't work in LDFLAGS The library links needs to go on the extreme right of the final linker call So I am clear that is the last call that joins all the individual compiles up. So there is exactly one line it needs to go on which is the final line executed to link
In vino veritas
Leon, I got sidetracked by another issue, and this one was "FIXED" - see my next post. From my research - it is optioned / initialized in the library I have build and I really do not understand what it supposedly doing with just the options being set. It is definitely incomplete. I did try to delete the options, but it is "built-in".