• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Development Tools » TI C/C++ Compiler » TI C/C++ Compiler - Forum » Linking error with C674X-MATHLIB 3.0.1.1
Share
TI C/C++ Compiler
  • Forum
Options
  • Subscribe via RSS

Forums

Linking error with C674X-MATHLIB 3.0.1.1

This question is answered
Reinier Coetzer
Posted by Reinier Coetzer
on Aug 06 2012 07:05 AM
Expert1045 points

Hi,

I'm trying to use the C674X-MATHLIB (v3.0.1.1) in my C++ application in CCS 5.2. I am aware of the annoying pragma issue, and by simply using the extern "C" as recommended in other posts, it made no difference. Instead I developed an interface C-file with wrapper functions that simply calls the C-functions of MATHLIB, and then I declared the wrapper functions as extern "C" in the interface header file.

The compilation of this approach works fine, but I'm getting linking errors in that a number of symbols are not found. I'm linking against the mathlib.a674 library in the mathlib_c674x_3_0_1_1\lib directory of C674X-MATHLIB. The following symbols are not found by the linker:

- All the vector versions of single point precision (possibly also the double precision, but I have not tested this), e.g. atan2sp_v,  atansp_v, cossp_v, etc.

- logtable, kTable, jTable and V, which are located in mathlib_c674x_3_0_1_1\packages\ti\mathlib\src\common\tables.c

The vector versions are simply a for-loop which calls the inline version of the associated function and the other symbols are constants. By copying this code into my own source files, I managed to successfully compile and link. I find this strange because the linker found the normal math functions, e.g. atan2sp and atan2sp_i. Does this mean that the above mentioned functions and variables were not compiled into the supplied library or am I missing something very obvious here?

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • George Mock
    Posted by George Mock
    on Aug 06 2012 08:22 AM
    Guru51495 points

    Please show the exact text of one of the linker error messages.

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click Verify Answer on the best reply to your question.
    The Compiler Wiki answers most common questions.
    Track an issue with SDOWP. Enter your bug id in the "Find Record ID" box.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Reinier Coetzer
    Posted by Reinier Coetzer
    on Aug 06 2012 08:42 AM
    Expert1045 points

    Hi George,

    As requested:

    The output from compiling my library that is using MATHLIB:

    **** Build of configuration Debug for project slm_eigen_lib ****

    C:\ti\ccsv5\utils\bin\gmake -k all
    'Building file: ../src/eigen.cpp'
    'Invoking: C6000 Compiler'
    "C:/ti/ccsv5/tools/compiler/c6000_7.3.4/bin/cl6x" -mv6740 -g --include_path="C:/ti/ccsv5/tools/compiler/c6000_7.3.4/include" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/packages" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/inc" --display_error_number --diag_warning=225 --abi=coffabi --opt_for_speed=3 --preproc_with_compile --preproc_dependency="src/eigen.pp" --obj_directory="src"  "../src/eigen.cpp"
    'Finished building: ../src/eigen.cpp'
    ' '
    'Building file: ../src/mathlib_if.c'
    'Invoking: C6000 Compiler'
    "C:/ti/ccsv5/tools/compiler/c6000_7.3.4/bin/cl6x" -mv6740 -g --include_path="C:/ti/ccsv5/tools/compiler/c6000_7.3.4/include" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/packages" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/inc" --display_error_number --diag_warning=225 --abi=coffabi --opt_for_speed=3 --preproc_with_compile --preproc_dependency="src/mathlib_if.pp" --obj_directory="src"  "../src/mathlib_if.c"
    'Finished building: ../src/mathlib_if.c'
    ' '
    'Building file: ../src/utils.cpp'
    'Invoking: C6000 Compiler'
    "C:/ti/ccsv5/tools/compiler/c6000_7.3.4/bin/cl6x" -mv6740 -g --include_path="C:/ti/ccsv5/tools/compiler/c6000_7.3.4/include" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/packages" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/inc" --display_error_number --diag_warning=225 --abi=coffabi --opt_for_speed=3 --preproc_with_compile --preproc_dependency="src/utils.pp" --obj_directory="src"  "../src/utils.cpp"
    'Finished building: ../src/utils.cpp'
    ' '
    'Building target: ../lib/slm_eigen_lib.lib'
    'Invoking: C6000 Archiver'
    "C:/ti/ccsv5/tools/compiler/c6000_7.3.4/bin/ar6x" r "../lib/slm_eigen_lib.lib" "./src/utils.obj" "./src/mathlib_if.obj" "./src/eigen.obj"
      ==>  new archive '../lib/slm_eigen_lib.lib'
      ==>  building archive '../lib/slm_eigen_lib.lib'
    'Finished building target: ../lib/slm_eigen_lib.lib'
    ' '

    **** Build Finished ****

    The output from building my main project, that links against my library as build above:

    **** Build of configuration Debug for project slm_eigen_test_app ****

    C:\ti\ccsv5\utils\bin\gmake -k all
    'Building file: ../main.tcf'
    'Invoking: TConf'
    "C:/ti/xdctools_3_23_03_53/tconf" -b -Dconfig.importPath="C:/ti/bios_5_41_13_42/packages;" "../main.tcf"
    'Finished building: ../main.tcf'
    ' '
    'Building file: maincfg.s??'
    'Invoking: C6000 Compiler'
    "C:/ti/ccsv5/tools/compiler/c6000_7.3.4/bin/cl6x" -mv6740 -g --include_path="C:/ti/ccsv5/tools/compiler/c6000_7.3.4/include" --include_path="D:/projects/slm_lib_c6748/slm_eigen_lib/inc" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/packages" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/inc" --include_path="D:/projects/slm_lib_c6748/slm_eigen_test_app/Debug" --include_path="C:/ti/bios_5_41_13_42/packages/ti/bios/include" --include_path="C:/ti/bios_5_41_13_42/packages/ti/rtdx/include/c6000" --display_error_number --diag_warning=225 --abi=coffabi --preproc_with_compile --preproc_dependency="maincfg.pp"  "maincfg.s??"
    'Finished building: maincfg.s??'
    ' '
    'Building file: maincfg_c.c'
    'Invoking: C6000 Compiler'
    "C:/ti/ccsv5/tools/compiler/c6000_7.3.4/bin/cl6x" -mv6740 -g --include_path="C:/ti/ccsv5/tools/compiler/c6000_7.3.4/include" --include_path="D:/projects/slm_lib_c6748/slm_eigen_lib/inc" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/packages" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/inc" --include_path="D:/projects/slm_lib_c6748/slm_eigen_test_app/Debug" --include_path="C:/ti/bios_5_41_13_42/packages/ti/bios/include" --include_path="C:/ti/bios_5_41_13_42/packages/ti/rtdx/include/c6000" --display_error_number --diag_warning=225 --abi=coffabi --preproc_with_compile --preproc_dependency="maincfg_c.pp"  "maincfg_c.c"
    'Finished building: maincfg_c.c'
    ' '
    'Building file: ../src/main.cpp'
    'Invoking: C6000 Compiler'
    "C:/ti/ccsv5/tools/compiler/c6000_7.3.4/bin/cl6x" -mv6740 -g --include_path="C:/ti/ccsv5/tools/compiler/c6000_7.3.4/include" --include_path="D:/projects/slm_lib_c6748/slm_eigen_lib/inc" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/packages" --include_path="C:/Texas Instruments/mathlib_c674x_3_0_1_1/inc" --include_path="D:/projects/slm_lib_c6748/slm_eigen_test_app/Debug" --include_path="C:/ti/bios_5_41_13_42/packages/ti/bios/include" --include_path="C:/ti/bios_5_41_13_42/packages/ti/rtdx/include/c6000" --display_error_number --diag_warning=225 --abi=coffabi --preproc_with_compile --preproc_dependency="src/main.pp" --obj_directory="src"  "../src/main.cpp"
    "../src/main.cpp", line 52: warning #179-D: variable "j" was declared but never referenced
    'Finished building: ../src/main.cpp'
    ' '
    'Building target: slm_eigen_test_app.out'
    'Invoking: C6000 Linker'
    "C:/ti/ccsv5/tools/compiler/c6000_7.3.4/bin/cl6x" -mv6740 -g --display_error_number --diag_warning=225 --abi=coffabi -z -m"slm_eigen_test_app.map" --warn_sections --display_error_number -i"C:/ti/ccsv5/tools/compiler/c6000_7.3.4/lib" -i"D:/projects/slm_lib_c6748/slm_eigen_lib/lib" -i"D:/projects/slm_lib_c6748/slm_eigen_lib/inc" -i"C:/Texas Instruments/mathlib_c674x_3_0_1_1/packages" -i"C:/Texas Instruments/mathlib_c674x_3_0_1_1/lib" -i"C:/Texas Instruments/mathlib_c674x_3_0_1_1/inc" -i"C:/ti/ccsv5/tools/compiler/c6000_7.3.4/include" -i"C:/ti/bios_5_41_13_42/packages/ti/rtdx/lib/c6000" -i"C:/ti/bios_5_41_13_42/packages/ti/bios/lib" -i"C:/ti/bios_5_41_13_42/packages/ti/pscl/lib" -i"C:/ti/bios_5_41_13_42/packages/ti/pmi/lib" -i"C:/ti/bios_5_41_13_42/packages/ti/psl/lib" --reread_libs --rom_model -o "slm_eigen_test_app.out" -l"./maincfg.cmd"  "./src/main.obj" "./maincfg_c.obj" "./maincfg.obj" -l"libc.a" -l"slm_eigen_lib.lib" -l"mathlib.a674"
    <Linking>

     undefined  first referenced                                                             
      symbol        in file                                                                  
     ---------  ----------------                                                             
     _atan2sp_v D:/projects/slm_lib_c6748/slm_eigen_lib/lib/slm_eigen_lib.lib<mathlib_if.obj>
     _jTable    D:/projects/slm_lib_c6748/slm_eigen_lib/lib/slm_eigen_lib.lib<mathlib_if.obj>
     _kTable    D:/projects/slm_lib_c6748/slm_eigen_lib/lib/slm_eigen_lib.lib<mathlib_if.obj>
     _logtable  D:/projects/slm_lib_c6748/slm_eigen_lib/lib/slm_eigen_lib.lib<mathlib_if.obj>

    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "slm_eigen_test_app.out" not
       built

    >> Compilation failure
    gmake: *** [slm_eigen_test_app.out] Error 1
    gmake: Target `all' not remade because of errors.

    **** Build Finished ****

    Note: I only changed the code back to its original form for atan2sp_v to illustrate the error.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • George Mock
    Posted by George Mock
    on Aug 06 2012 09:47 AM
    Verified Answer
    Verified by Reinier Coetzer
    Guru51495 points

    Reinier Coetzer
    undefined  first referenced                                                             
      symbol        in file                                                                  
     ---------  ----------------                                                             
     _atan2sp_v D:/projects/slm_lib_c6748/slm_eigen_lib/lib/slm_eigen_lib.lib<mathlib_if.obj>
     _jTable    D:/projects/slm_lib_c6748/slm_eigen_lib/lib/slm_eigen_lib.lib<mathlib_if.obj>
     _kTable    D:/projects/slm_lib_c6748/slm_eigen_lib/lib/slm_eigen_lib.lib<mathlib_if.obj>
     _logtable  D:/projects/slm_lib_c6748/slm_eigen_lib/lib/slm_eigen_lib.lib<mathlib_if.obj>

    I presume you expect this function and data tables to be supplied by mathlib.a674.  Well, they are not there.  I used the name utility nm6x (documented in the C6000 Assembly Language Tools User's Guide) to check.  First I checked for any function that includes the name atan2 ...

    C:\Program Files\Texas Instruments\mathlib_c674x_3_0_1_1\lib>nm6x -g mathlib.a674 | find "atan2"
    000001d0 T _atan2dp
    00000000 T _atan2sp

    I see those two functions, but no _atan2sp_v.

    Next I checked for anything that includes the name table, in upper or lower case ...

    C:\Program Files\Texas Instruments\mathlib_c674x_3_0_1_1\lib>nm6x -g mathlib.a674 | find /i "table"
    00000038 D Expon_Ctable
    00000000 D Expon_Ktable
    00000000 D expon_ctable
    00000000 D expon_ktable
    00000000 D exp_ctable
    00000000 D exp_ktable
    00000000 D Logtable_asm
    00000000 D log_table_asm

    I can see those tables, but not _jTable, _kTable, or _logtable.  (Side note: It is interesting how none of these names start with an underscore.  I suspect they are all defined in hand-coded assembly, and may not be intended for use by code outside the library.)  

    The bottom line is that those functions and data tables referenced by matlib_if.c are not in matlib.a674.  

    Thanks and regards,

    -George


    TI C/C++ Compiler Forum Moderator
    Please click Verify Answer on the best reply to your question.
    The Compiler Wiki answers most common questions.
    Track an issue with SDOWP. Enter your bug id in the "Find Record ID" box.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Reinier Coetzer
    Posted by Reinier Coetzer
    on Aug 06 2012 10:38 AM
    Expert1045 points

    Hi George,

    Thank you for confirming what I suspected.

    Some indication of this in the documentation would be desireable and would have saved me  quite some time!

    Regards

      Reinier

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Saurabh Kumar Singh
    Posted by Saurabh Kumar Singh
    on Aug 29 2012 02:36 AM
    Prodigy215 points

    Hello Reinier.

    Would be possible for you to post the C interface that you have developed for MATHLIB here?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Reinier Coetzer
    Posted by Reinier Coetzer
    on Aug 30 2012 09:38 AM
    Expert1045 points

    Example of the C header:

    <code>

    #ifndef MATHLIB_IF_H_
    #define MATHLIB_IF_H_

    #ifdef __cplusplus
    extern "C" {
    #endif

    //----------------------------------------------------------------------------------
    //    atan2 Single precision wrapper functions
    //----------------------------------------------------------------------------------
    void atan2sp_v_wrapper(float *a, float *b, float *output, int size);
    float atan2sp_wrapper(float a, float b);
    float atan2sp_i_wrapper(float a, float b);


    #ifdef __cplusplus
    }
    #endif

    #endif /* MATHLIB_IF_H_ */

    </code>

    Example of C source file

    <code>

    #include <mathlib.h>

    #include "mathlib_if.h"

    // Log table
    double logtable[8] = {
       0.0000000000,            //
      -0.1177830356,            //
      -0.2231435513,            //
      -0.3184537311,            //
      -0.4054651081,            //
      -0.4855078157,            //
      -0.5596157879,            //
      -0.6286086594             //
    };

    // kTable
    double kTable[4] = {
      1.000000000,              // 2^(0/4)
      1.189207115,              // 2^(1/4)
      1.414213562,              // 2^(2/4)
      1.681792831               // 2^(3/4)
    };

    // jTable
    double jTable[4] = {
      1.000000000,              // 2^(0/16)
      1.044273782,              // 2^(1/16)
      1.090507733,              // 2^(2/16)
      1.138788635               // 2^(3/16)
    };

    double V[4] = {
      0.00000000000000000000,   //
      0.52359877559829887308,   //
      1.57079632679489661923,   //
      1.04719755119659774615    //
    };


    //----------------------------------------------------------------------------------
    //    atan2 Single precision wrapper functions
    //----------------------------------------------------------------------------------
    void atan2sp_v_wrapper(float *a, float *b, float *output, int size) {

        int i;

        for (i = 0; i < size; i++) {
          output[i] = atan2sp_i (a[i],b[i]);
        }
    }

    float atan2sp_wrapper(float a, float b) {

        return atan2sp(a, b);
    }

    float atan2sp_i_wrapper(float a, float b) {

        return atan2sp_i(a, b);
    }

    </code>

    The rest of the wrapper functions you can just implement yourself in a similar fashion.

    Regards

      Reinier

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Saurabh Kumar Singh
    Posted by Saurabh Kumar Singh
    on Oct 09 2012 04:28 AM
    Prodigy215 points

    Hello Reinier.

    Thank you for posting the code developed by you. It was very helpful.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use