I've seen that there are more posts about the following, but never with a conclusive answer :
We have
created an external library with a new function block
added code to the .c file
compiled it using Visual C++
created a new program in CoDeSys, and used the custom function block, without problems.
So far everything works fine.
However, when the C code has dependencies, such as when I add
\#include<math.h>
and I use for example a sin() function, I get the following error:
Error3162:CouldnotresolvereferenceinLibrary'C:\DOCUMENTS AND SETTINGS\WIM\MIJN DOCUMENTEN\CODESYSTEST11\EXTTEST.OBJ'(Symbol'_sin',Class'EXTERNAL',Type'REL32')
Is there anyone who could give some advice on how we could solve this?
For a project in the near future we're currently studying our different options, and CoDeSys seems very attractive so far, however in this project we really rely on external code.
Thank you very much.
Wim
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Zitat:
If you want to use any ANSI C standard library functions you must activate the following
selection in the project settings:
Build / Settings / C/C++ / Category: Optimizations : Customize: Generate Instrinsic
Functions
In this way the simplest ANSI C library functions are implemented in-line (strcpy(),...).
Otherwise no libraries may be used.
Does that mean that I cannot even use <math.h> functions such as sin() in my C code? Or am I missing the point and is there another way to do it?</math.h>
Thank you!
Wim
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Wim;
I had this same problem for long time and i had solved it.Normally it is not possible to compile math.h in SPS environment. But i have found a solution. U should write ur own function in Visual c++ like all math.h function.( Sin COS fabs) then it is possible and i have done it. My "Self math.H" has a accuracy almost 0.0001 to 0.005 comparing math.h.
it is little bit hard at the beginning. Anyway I hope, u understand what i have said.
Best Regards,
Asif
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
math.h is has different data types so you will have to rewrtite your own or make the datatypes available, or in math change the functions used.
However if you need better sin function another way is to have it calculated with the root function.
You could also look into w www.oscat.de w he has several functions available.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've seen that there are more posts about the following, but never with a conclusive answer :
We have
created an external library with a new function block
added code to the .c file
compiled it using Visual C++
created a new program in CoDeSys, and used the custom function block, without problems.
So far everything works fine.
However, when the C code has dependencies, such as when I add
and I use for example a sin() function, I get the following error:
Is there anyone who could give some advice on how we could solve this?
For a project in the near future we're currently studying our different options, and CoDeSys seems very attractive so far, however in this project we really rely on external code.
Thank you very much.
Wim
In "C_in_32Bit_E.pdf" I read:
Does that mean that I cannot even use <math.h> functions such as sin() in my C code? Or am I missing the point and is there another way to do it?</math.h>
Thank you!
Wim
Hi Wim;
I had this same problem for long time and i had solved it.Normally it is not possible to compile math.h in SPS environment. But i have found a solution. U should write ur own function in Visual c++ like all math.h function.( Sin COS fabs) then it is possible and i have done it. My "Self math.H" has a accuracy almost 0.0001 to 0.005 comparing math.h.
it is little bit hard at the beginning. Anyway I hope, u understand what i have said.
Best Regards,
Asif
math.h is has different data types so you will have to rewrtite your own or make the datatypes available, or in math change the functions used.
However if you need better sin function another way is to have it calculated with the root function.
You could also look into w www.oscat.de w he has several functions available.