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?
Please show the exact text of one of the linker error messages.
Thanks and regards,
-George
TI C/C++ Compiler Forum ModeratorPlease 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.
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 remainerror #10010: errors encountered during linking; "slm_eigen_test_app.out" not built>> Compilation failuregmake: *** [slm_eigen_test_app.out] Error 1gmake: 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.
Reinier Coetzerundefined 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 _atan2dp00000000 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_Ctable00000000 D Expon_Ktable00000000 D expon_ctable00000000 D expon_ktable00000000 D exp_ctable00000000 D exp_ktable00000000 D Logtable_asm00000000 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.
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
Hello Reinier.
Would be possible for you to post the C interface that you have developed for MATHLIB here?
Example of the C header:
<code>
#ifndef MATHLIB_IF_H_#define MATHLIB_IF_H_#ifdef __cplusplusextern "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
#include <mathlib.h>#include "mathlib_if.h"// Log tabledouble logtable[8] = { 0.0000000000, // -0.1177830356, // -0.2231435513, // -0.3184537311, // -0.4054651081, // -0.4855078157, // -0.5596157879, // -0.6286086594 //};// kTabledouble kTable[4] = { 1.000000000, // 2^(0/4) 1.189207115, // 2^(1/4) 1.414213562, // 2^(2/4) 1.681792831 // 2^(3/4)};// jTabledouble 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);}
The rest of the wrapper functions you can just implement yourself in a similar fashion.
Thank you for posting the code developed by you. It was very helpful.