home Forums # Technical Support Fuzzylite + CPP (Windows) + Hopefully Visual Studio

Viewing 10 posts - 1 through 10 (of 14 total)
  • Author
    Posts
  • #1150
    Unknown
    Member

    Hello,
    Let’s say I would like to write my own app in C++ which uses fuzzylite and some fcl file. I did something similiar in JAVA, but unfortunately C++ is bit different in case of libraries.

    I’ve downloaded Windows package from site, there are sources and fuzzylite.dll.

    What should be the steps and compiler options to make it possible to make an app on windows? Preferably I will try to make this app in Visual Studio 2008.

    What I’m trying to do is making TORCS run based on fcl rules, I got TORCS running fine in VS, so I would like to stick with it.

    #1152
    Unknown
    Member

    Ok, here is what I managed to do.

    I created DummyFuzzy project with one file and main method, I successfully added include directory, library directory and lib itself – it works great.

    But when I do exactly the same steps in order to add fuzzylite to TORCS project i get following errors:

    1>------ Build started: Project: myrobot, Configuration: Release Win32 ------
    1>Compiling...
    1>driver.cpp
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/fuzzylite.h(116) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/fuzzylite.h(116) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Engine.h(52) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Engine.h(52) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(39) : error C2027: use of undefined type 'T'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(39) : error C2226: syntax error : unexpected type 'T'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(39) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(42) : error C2760: syntax error : expected '{' not ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(44) : error C2143: syntax error : missing '}' before ''template<''
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(45) : error C2143: syntax error : missing ',' before '<end Parse>'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(48) : error C2143: syntax error : missing ')' before ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(48) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/term/Term.h(40) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/term/Term.h(40) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/rule/RuleBlock.h(40) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/rule/RuleBlock.h(40) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/variable/Variable.h(42) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/variable/Variable.h(42) : error C2238: unexpected token(s) preceding ';'
    1>Build log was saved at "file://d:\Development\torcs\torcs-1.3.5\src\drivers\myrobot\Release\BuildLog.htm"
    1>myrobot - 18 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 26 up-to-date, 0 skipped ==========
    
    #1153
    Unknown
    Member

    Ok, somehow we manage to launch app, create fl::Engine but how can we import fcl file?
    We want to define rules in fcl file and to import them into application.

    Thanks.

    #1155

    Hi,

    fl::Engine* engine = fl::FclImporter().fromString(yourFileContents); will create an engine instance if there are no errors in your fcl file. Notice that you must read your file into an std::string first. For reading a file, please consult basic C++ operations.

    #1156
    Unknown
    Member

    Thank you Juan!

    After we made this post we found those *Importers and tried to use them, we just thought we can pass filename as attribute – that was causing exception (e.g. expected colon). Now we are back in business 😉

    #1157
    Unknown
    Member

    I did successful import of fcl file in simple DummyFuzzy project.
    But when we are trying the same code (or some variations) in TORCS it fails.

    What we can do, is to create “empty” engine like this:
    Engine * engine = new Engine();
    It works, we can sysout the allocated address.

    But it fails if we give e.g.
    Engine * engine = new Engine("NAME");

    or:

    Engine * engine = new Engine();
    engine->setName("NAME");

    So it also fails if we do this:

    ifstream ifs("D:\\rules.fcl");
    	string rules2( (std::istreambuf_iterator<char>(ifs) ),
    		(std::istreambuf_iterator<char>()    ) );
    	printf("%s\n--------------------------\n", rules2.c_str()); //this works
    	Engine * engine = fl::FllImporter().fromString(rules2.c_str());
    
    	printf("CREATED \n"); // this do not print
    	printf("%s\n", engine->getName().c_str());

    And the last bit of code ends with:
    torcs_fuzzylite_error

    • This reply was modified 8 years, 1 month ago by Unknown.
    #1159

    Hi,

    I think you should be instantiating your engines as Engine* engine = new Engine;, without the ().

    If the following statement is failing, Engine * engine = new Engine("NAME");, I would strongly recommend that you make sure the compilation of the library was successful. For some reason, it seems you are having issues with std::string, which is quite weird.

    Perhaps there are some settings in the TORCS project you are working on that may be affecting fuzzylite?

    Have you tried using fuzzylite outside of TORCS just for the sake of making sure the compilation of fuzzylite was correct? Please try this one first, and let me know.

    Cheers.

    #1160
    Unknown
    Member

    Acctually we succesfully initiated an Engine instance in a standalone Project using fuzzylite.

    We initiated the engine by Fllimport->fromString() method.

    We could reach into the engine.getName() and it returned the correct name, so in fact it did work.

    Maybe there are TORCS project propperties issue, but we don’t know where to start looking.

    We get different errors using setName() and Fllimport().

    #1161

    Hi,

    I think you might be having issues with the files encoding and non-ascii characters. Have you checked whether the file you are importing from contains invalid characters?

    Take a look at the following link, which appear to have the same issues you are experiencing.

    http://stackoverflow.com/questions/10178700/c-strip-non-ascii-characters-from-string

    #1500
    Unknown
    Member

    Hi
    I have the same problem than bartekz!!!
    “I created DummyFuzzy project with one file and main method, I successfully added include directory, library directory and lib itself – it works great.

    But when I do exactly the same steps in order to add fuzzylite to my project i get following errors:

    1>------ Build started: Project: myrobot, Configuration: Release Win32 ------
    1>Compiling...
    1>driver.cpp
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/fuzzylite.h(116) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/fuzzylite.h(116) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Engine.h(52) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Engine.h(52) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(39) : error C2027: use of undefined type 'T'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(39) : error C2226: syntax error : unexpected type 'T'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(39) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(42) : error C2760: syntax error : expected '{' not ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(44) : error C2143: syntax error : missing '}' before ''template<''
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(45) : error C2143: syntax error : missing ',' before '<end Parse>'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(48) : error C2143: syntax error : missing ')' before ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/Operation.h(48) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/term/Term.h(40) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/term/Term.h(40) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/rule/RuleBlock.h(40) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/rule/RuleBlock.h(40) : error C2238: unexpected token(s) preceding ';'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/variable/Variable.h(42) : error C2143: syntax error : missing ';' before '.'
    1>D:\Chrome\fuzzylite-4.0-win\fuzzylite-4.0\sources\fuzzylite-4.0\fuzzylite\fl/variable/Variable.h(42) : error C2238: unexpected token(s) preceding ';'
    1>Build log was saved at "file://d:\Development\torcs\torcs-1.3.5\src\drivers\myrobot\Release\BuildLog.htm"
    1>myrobot - 18 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 26 up-to-date, 0 skipped =========="
Viewing 10 posts - 1 through 10 (of 14 total)
  • You must be logged in to reply to this topic.