This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Stubbing functions



I am testing code using Code Composer. The code contains functions that access hardware and I want to stub out these function in a test driver. I link the test driver with libraries of containg the prime software.

However, I get a message similar to

  error #10056: symbol "_Test_cleanup" redefined: first defined in "test.obj"; redefined in
     "C:\Embraer\CSeries\RBT\ToolsLib\TI\Test_Lib_TI.lib<m_compare.obj>"
  error #10010: errors encountered during linking; "test.out" not built

From the manuals it seems it should be possible to link my test driver object code with the prime library. I thought that if I used the --priority option if would be able to link in the function from my test driver and have the one in the prime software ignored.

Am I understanding the manual incorrectly?

  • I think this is what is happening to you ... You wrote a C file named m_compare.c that contains the function Test_cleanup and at least other function with a name I don't know.  But I know you call that function, so I'll name it does_get_called.  You build m_compare.c without the option --gen_func_subsections, which means the symbols Test_cleanup and does_get_called are both defined in the .text section of m_compare.obj.  Then you put m_compare.obj in a library named Test_Lib_TI.lib.  Your test driver code does both of these things: it calls does_get_called, and it defines its own version of Test_cleanup.  The reference to does_get_called is seen first somehow, so the .text section from the module m_compare.obj is brought in from Test_Lib_TI.lib.  Now you have a definition of does_get_called and Test_cleanup in your system.  Then, the definition of Test_cleanup in your test driver code is seen, and that error message is emitted.

    The answer is to build the library module with --gen_func_subsections.

    Thanks and regards,

    -George

  • George,

    You were on the mark with your description of what I was doing. I recompiled and archived my Test_Lib_TI.lib with the --gen_func_subsections. I added this option to the compilation of the test driver as well. In the map file I was able to see the called functions from m_compare.obj that get used. I was also able to see that the Test_cleanup function was from the driver instead of the library.

    However, it did not make the error go away. I am still getting the redifinition error. (I even added the following link option, --diag_warning=10056, to try to treat it as a warning!)

  • I told you each function in the library needs to be in its own section.  Sorry, but that is incorrect.  Each function needs to be in its own source file.  Specific to your case, each function you plan to replace with non-library code needs to be in its own file.

    Thanks and regards,

    -George