<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to External C code</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/8187c52934/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/8187c52934/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/8187c52934/</id><updated>2020-02-27T21:04:05.082000Z</updated><subtitle>Recent posts to External C code</subtitle><entry><title>External C code</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/8187c52934/?limit=25#4990" rel="alternate"/><published>2020-02-27T21:04:05.082000Z</published><updated>2020-02-27T21:04:05.082000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com80252309f7f5e7996615335ad795e6104bfa98f0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;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.&lt;br/&gt;
However if you need better sin function another way is to have it calculated with the root function.&lt;br/&gt;
You could also look into  w &lt;a class="" href="http://www.oscat.de" rel="nofollow"&gt;www.oscat.de&lt;/a&gt; w  he has several functions available.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External C code</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/8187c52934/?limit=25#e028" rel="alternate"/><published>2020-02-27T21:04:03.647000Z</published><updated>2020-02-27T21:04:03.647000Z</updated><author><name>asifdip</name><uri>https://forge.codesys.com/u/asifdip/</uri></author><id>https://forge.codesys.comcf71f37ce926ca8c544c254b63106767ad053f83</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Wim;&lt;br/&gt;
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 "&lt;strong&gt;Self math.H&lt;/strong&gt;" has a accuracy almost 0.0001 to 0.005 comparing &lt;strong&gt;math.h&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;it is little bit hard at the beginning. Anyway I hope, u understand what i have said.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;br/&gt;
Asif&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External C code</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/8187c52934/?limit=25#2665" rel="alternate"/><published>2020-02-27T21:03:59.620000Z</published><updated>2020-02-27T21:03:59.620000Z</updated><author><name>wim12</name><uri>https://forge.codesys.com/u/wim12/</uri></author><id>https://forge.codesys.com90875ff420450ccaf3c6690f66b693a8e5ac1cd4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;In "C_in_32Bit_E.pdf" I read:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Zitat:&lt;/strong&gt;&lt;br/&gt;
 If you want to use any ANSI C standard library functions you must activate the following&lt;br/&gt;
 selection in the project settings:&lt;br/&gt;
 Build / Settings / C/C++ / Category: Optimizations : Customize: Generate Instrinsic&lt;br/&gt;
 Functions&lt;br/&gt;
 In this way the simplest ANSI C library functions are implemented in-line (strcpy(),...).&lt;br/&gt;
 Otherwise no libraries may be used.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Does that mean that I cannot even use &amp;lt;math.h&amp;gt; functions such as sin() in my C code? Or am I missing the point and is there another way to do it?&amp;lt;/math.h&amp;gt;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;
&lt;p&gt;Wim&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>External C code</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/8187c52934/?limit=25#cbb1" rel="alternate"/><published>2020-02-27T21:03:58.129000Z</published><updated>2020-02-27T21:03:58.129000Z</updated><author><name>wim12</name><uri>https://forge.codesys.com/u/wim12/</uri></author><id>https://forge.codesys.comad681ca629d2b3985fd5dc11d92f54e2c1311412</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I've seen that there are more posts about the following, but never with a conclusive answer :&lt;/p&gt;
&lt;p&gt;We have&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;created an external library with a new function block&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;added code to the .c file&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;compiled it using Visual C++&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;created a new program in CoDeSys, and used the custom function block, without problems.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So far everything works fine.&lt;/p&gt;
&lt;p&gt;However, when the C code has dependencies, such as when I add &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;\#&lt;span class="k"&gt;include&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;math&lt;/span&gt;.&lt;span class="nv"&gt;h&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and I use for example a sin() function, I get the following error:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt; &lt;span class="mi"&gt;3162&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Could&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="n"&gt;resolve&lt;/span&gt; &lt;span class="n"&gt;reference&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;Library&lt;/span&gt; &lt;span class="s1"&gt;'C:\DOCUMENTS AND SETTINGS\WIM\MIJN DOCUMENTEN\CODESYSTEST11\EXTTEST.OBJ'&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Symbol&lt;/span&gt; &lt;span class="s1"&gt;'_sin'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;Class&lt;/span&gt; &lt;span class="s1"&gt;'EXTERNAL'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;Type&lt;/span&gt; &lt;span class="s1"&gt;'REL32'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Is there anyone who could give some advice on how we could solve this? &lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Thank you very much.&lt;/p&gt;
&lt;p&gt;Wim&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>