So, I'm trying to add a function in which you pass a string that is a function (for example, "sin (x)") and some borders, and it graphs the string, creating GL_LINE_STRIP. I wrote a function based on Example 1, which the developer did. Here is the function I created. // Excerpt from draw.h template void GraphY (std :: string ln) {typedef exprtk :: symbol_table symbol_table_t; typedef exprtk :: expression expression_t; typedef exprtk :: parser parser_t;
T x; symbol_table_t symbol_table; symbol_table.add_variable("x", x); symbol_table.add_constant(); expression_t expression; expression.register_symbol_table(symbol_table); parser_t parser; parser.compile(ln, expression); glLineWidth(w); glColor4f(outline.r / 255, outline.g / 255, outline.b / 255, outline.a / 255); glBegin(GL_LINE_LOOP); for (x = T(-5); x <= T(+5); x += T(0.001)) { T y = expression.value(); glVertex3f(x, y, 0); } glEnd(); }
This function has no errors, and I am sure that it will work very well as soon as its work works. I have a function that calls this function (it is inside another file). He does it like that.
//Excerpt from render.cpp GraphY("sin(x)");
It produces the following error:
1>Render.obj : error LNK2019: unresolved external symbol "void __cdecl GraphY(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" ( ?GraphY@ @ YAXV?$basic_string@DU ?$char_traits@D @ std@ @ V?$allocator@D @ 2@ @ std@ @@Z) referenced in function "void __cdecl Render(void)" ( ?Render@ @YAXXZ)
Although this error has already been set, I really donβt know how to fix it, because I am not familiar with exprtk.hpp templates or interpolations. I was hoping someone could help me.
I checked, and that is not because it cannot find the function. Something is wrong. I suspect this is due to patterns. Which, although I read, I really do not understand. However, I put it together somehow, I have to name the function as follows:
GraphY<somedatatype>("sin(x)");
However, I do not know what type of data should be invested to make it happy. Could you help me make this function work? You can download the library (exprtk.hpp) from https://github.com/ArashPartow/exprtk . You can also see how you should use the library in code (unfortunately, it has no examples where it performs such a function).
Thanks a lot!