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.
From another thread: http://e2e.ti.com/support/development_tools/compiler/f/343/p/228422/1002585.aspx#1002585
Archaeologist said:
For the TI compiler, the pragma syntax is different between C and C++, and even an 'extern"C"' block won't patch over this difference.
Create a separate C source file in your project and compile it as C code. Place all references to mathlib.h in that file. You can create wrapper functions which make direct calls to mathlib.h features, and then call those wrapper functions from your C++ code.
Could you please tell me exactly which file line 821 is in, and what the exact text of the pragma on that line is? This is something that can be worked around by changing mathlib.h to be sensitive to whether it is being compiled for C++, but there are probably other things that need to be adjusted.
I am trying to follow this advice to use MATHLIB in a simple c++ program. I am still getting 50 pragma-related errors in CCS, even after creating the wrapper function for the MATHLIB division function. Here's my simple test code:
***** In CJmathlib.c
#include <mathlib.h>
#include "divsp.h"
float CJdivide (float a, float b) {
float d;
d = divsp(a,b); // "C" function! (NOT c++)
return d;
}
***** In main.cpp
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <CJmathlib.c>
/*
* main.cpp
*
* This program is to test the TI MATHLIB library
*/
int main(void) {
float a = 1.23456;
float b = 9.87654;
float c;
c = b / a;
printf("Result: %f",c);
// *********************************************
float asdf;
asdf = CJdivide(b, a);
printf("Result: %f",asdf);
return 0;
}
Am I correctly implementing the wrapper function for the MATHLIB divsp() function? I have never merged c & c++ before, I greatly appreciate any thoughts on this work-around. Thanks!
Do not include C files, especially from C++ files. Create a new file named CJmathlib.h that has the prototypes for each C function you want to call:
#ifdef __cplusplus extern "C" { #endif float CJdivide (float a, float b); #ifdef __cplusplus } #endif
Now include CJmathlib.h in main.cpp instead of the C file itself.
Thank you. It doesn't quite work yet...
Could this warning about my library be related?
#10373-D library "/data/opt/ti/mathlib_c66x_3_0_1_1/lib/mathlib.a66" contains TI-COFF object files which are incompatible with the ELF output file. Ensure you are using the proper library.
I need Little Endian, not sure about COFF vs ELF though.
Anyway - for reference the error I'm getting now is from the .c file:
unresolved symbol divsp, first referenced in ./CJmathlib.obj
Thanks for your help!
All of the code in the system must be either all ELF or all COFF. No mixing allowed.
I presume rebuilding MATHLIB for ELF is not practical. Thus, you have to rebuild your code for COFF. Add --abi=coffabi to your compile build options.
Thanks and regards,
-George
Thanks. I don't understand the difference between ELF and COFF, or why I would need to care which one I used. Also, what makes you presume that MATLIB for ELF is not practical?
The MATHLIB User Guide provided to me from TI also does not explain the differences, and it has a typo describing the libraries.
By switching from mathlib.a66 to mathlib.ae66, my errors & warnings went away. Unfortunately, I do not know which libraries those are because of the aforementioned typo.
As I mentioned on a previous thread, it would be helpful to customers to have this sort of information listed on the MATHLIB Wiki or on the FAQ page (which is currently 100% empty).
George said that rebuilding MATHLIB would probably be impractical for you to do, which is true unless you have the source code. If there is an ELF version of the library available, rebuilding it is moot.
The linker will not allow you to mix big and little endian files, nor will it allow you to mix COFF and ELF files, so if the library you selected links without errors, it's the right one to use.
This is the compiler forum. The compiler team does not provide or support MATHLIB. You'll need to raise issues regarding documentation on a forum where MATHLIB is supported.