Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. gcov linker errors

gcov linker errors

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++questionvisual-studiolinux
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    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 status

    NOTE 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

    L V 2 Replies Last reply
    0
    • V Vaclav_

      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 status

      NOTE 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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      V 1 Reply Last reply
      0
      • L Lost User

        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.

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #3

        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.

        L L 2 Replies Last reply
        0
        • V Vaclav_

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • V Vaclav_

            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 status

            NOTE 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

            V Offline
            V Offline
            Vaclav_
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • V Vaclav_

              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.

              L Offline
              L Offline
              leon de boer
              wrote on last edited by
              #6

              -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

              V 1 Reply Last reply
              0
              • L leon de boer

                -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

                V Offline
                V Offline
                Vaclav_
                wrote on last edited by
                #7

                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".

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups