Login Page - Create Account

Support Board


Date/Time: Thu, 09 Jan 2025 19:59:22 +0000



Post From: Header File Help Needed

[2016-08-02 05:26:48]
User147461 - Posts: 33
Newbie from TS and MC to Sierra Chart. Trying to learn SC basics to start converting my code.
My thoughts are to create 3 files for my SC code:
MyStudies.cpp
MyFunctions.cpp
MyFunctions.h
I'm having a problem compiling, getting this error:
C:\WINDOWS\cc7SbtVs.o:examplestudy.cpp:(.text+0x51): undefined reference to `ExampleFunction_S(float, float, float)'collect2.exe: error: ld returned 1 exit status
If I change the #include statement from "examplefunction.h" to "examplefunction.cpp" the error goes away and compiles fine.
I think the function prototype in my header file needs additional code, but I don't know for sure.
My code is below. All suggestions and thoughts are welcomed. Thank you for helping me get started!


//#include "examplefunction.h" // C:\WINDOWS\cc7SbtVs.o:examplestudy.cpp:(.text+0x51): undefined reference to `ExampleFunction_S(float, float, float)'collect2.exe: error: ld returned 1 exit status
#include "examplefunction.cpp"
#include "sierrachart.h"

SCDLLName("examplestudy")

SCSFExport scsf_ExampleStudy(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
        sc.GraphName = "Example Study";
        sc.GraphRegion = 1;

        //During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
        sc.FreeDLL = 1;

        sc.Subgraph[0].Name = "Function Return Value";
        sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;
        sc.Subgraph[0].LineWidth = 4;
        sc.Subgraph[0].PrimaryColor = RGB(255,0,0);

        sc.AutoLoop = 1;

        return;
}

float FunctionValue;
FunctionValue = ExampleFunction_S(100.25, 200.50, 300.75); // 601.5

sc.Subgraph[0][sc.Index] = FunctionValue;

return;
}


#include "examplefunction.h"
#include "sierrachart.h"

/*****************************************************************************

  User note: The functions in this file are intermediate level functions you can
  copy and call from your primary scsf_ functions. These functions are not
  complete study functions, but are used by primary study functions to
  perform calculations. Where you see _S at the end, this means that the
  function is a single step function, and only fills in the array element
  at Index.

*****************************************************************************/

float ExampleFunction_S(float a, float b, float c)
{
  float r;
  r=a+b+c;
  return (r);
}


// examplefunction.h file

float ExampleFunction_S(float a, float b, float c);