home › Forums › # Technical Support › Newbie experience with fuzzylite
- This topic has 4 replies, 2 voices, and was last updated 9 years, 3 months ago by
Unknown.
-
AuthorPosts
-
August 30, 2014 at 03:27 #1402
Unknown
MemberHi Juan, first of all thanks for your work with this application. I am in need of a fuzzy logic library, and when I saw your video I really thought this is what I needed. I am not very experienced with developing software, just some simple procedural programs. I wanted to buy the QtFuzzylite as it would simplify my work a lot but I wanted to see first if I could make at least the example work. Unfortunately it has been more than 24 hours and I can’t seem to make it work. I hope you can help my with at least building and running the example.
I will try to document everything I have done so far so that you will have an idea for my case and maybe it could help others in the future.
1. I downloaded the Windows files from the Downloads page.
2. I downloaded and installed CMake 3.0.1
3. I tried to build the files using CMake and VS 2010 (I have Windows 7 64bit OS)
4. Failure to build, I found out that .Net Framework 4.5 is giving me problems, I downgraded to .Net Framework 4.0
5. I manually added the path of the cl.exe under Visual Studio directory to the environment variables in My Computer>Properties>Advanced>Environment Variables>System Variables>path
5. Using CMake, I was able to generate the .sln and other files
6. I opened the .sln file using Visual Studio 2010 and used Build Solution under the Build tab
7. I was able to generate the .lib and .dll files
8. I created a new Windows Forms Application in Visual Studio 2010
9. I added the fuzzylite directory at the project’s Properties>C/C++>General>Additional Include directories
10. Then I added the fuzzylited.lib at the project’s Properties>Linker>Input
11. I tried to build the project and there were no errors
12. Now I created a new source file named example.cpp and I copied the example code in the C++ page#include “fl/Headers.h”
int main(int argc, char* argv[]){
using namespace fl;
Engine* engine = new Engine(“simple-dimmer”);InputVariable* ambient = new InputVariable;
ambient->setName(“Ambient”);
ambient->setRange(0.000, 1.000);
ambient->addTerm(new Triangle(“DARK”, 0.000, 0.500));
ambient->addTerm(new Triangle(“MEDIUM”, 0.250, 0.750));
ambient->addTerm(new Triangle(“BRIGHT”, 0.500, 1.000));
engine->addInputVariable(ambient);OutputVariable* power = new OutputVariable;
power->setName(“Power”);
power->setRange(0.000, 2.000);
power->setDefaultValue(fl::nan);
power->addTerm(new Triangle(“LOW”, 0.000, 1.000));
power->addTerm(new Triangle(“MEDIUM”, 0.500, 1.500));
power->addTerm(new Triangle(“HIGH”, 1.000, 2.000));
engine->addOutputVariable(power);RuleBlock* ruleblock = new RuleBlock;
ruleblock->addRule(Rule::parse(“if Ambient is DARK then Power is HIGH”, engine));
ruleblock->addRule(Rule::parse(“if Ambient is MEDIUM then Power is MEDIUM”, engine));
ruleblock->addRule(Rule::parse(“if Ambient is BRIGHT then Power is LOW”, engine));
engine->addRuleBlock(ruleblock);engine->configure(“”, “”, “Minimum”, “Maximum”, “Centroid”);
std::string status;
if (not engine->isReady(&status))
throw Exception(“Engine not ready. ”
“The following errors were encountered:\n” + status, FL_AT);for (int i = 0; i < 50; ++i){
scalar light = ambient->getMinimum() + i * (ambient->range() / 50);
ambient->setInputValue(light);
engine->process();
FL_LOG(“Ambient.input = ” << Op::str(light) << ” -> ” <<
“Power.output = ” << Op::str(power->getOutputValue()));
}
}13. I tried to build again but there was an error:
error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include “StdAfx.h”‘ to your source?
14. So I added the header specified by the error:
#include “StdAfx.h”
#include “fl\Headers.h”15. Now I tried to build again but there are new errors that I don’t understand:
Error 27 error LNK1120: 26 unresolved externals c:\users\amp23\documents\visual studio 2010\Projects\Vermiculture\Debug\Vermiculture.exe Vermiculture
Error 16 error LNK2019: unresolved external symbol “public: __clrcall fl::Centroid::Centroid(int)” (??0Centroid@fl@@$$FQAM@H@Z) referenced in function “int __clrcall main1(int,char * * const)” (?main1@@$$FYMHHQAPAD@Z) c:\Users\AMP23\documents\visual studio 2010\Projects\Vermiculture\Vermiculture\example.obj Vermiculture
Error 13 error LNK2028: unresolved token (0A00003A) “public: __clrcall fl::Engine::Engine(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)” (??0Engine@fl@@$$FQAM@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function “int __clrcall main1(int,char * * const)” (?main1@@$$FYMHHQAPAD@Z) c:\Users\AMP23\documents\visual studio 2010\Projects\Vermiculture\Vermiculture\example.obj Vermiculture
My plan was to try and solve these errors one by one until I can make the example work, but now I don’t know where to go next. Sorry for the long post, I hope someone could help me.
Allen
August 31, 2014 at 10:25 #1405Juan Rada-Vilela (admin)
KeymasterHello,
thank you for documenting the steps taken to prepare your project.
I remember running into a similar issue. The problem I had was that I was creating a Net project. As soon as I created a different kind of project (maybe console, or plain project?), I was able to compile source files. I did not add the option of pre-compiled headers.
I will try to document this information today or during the week.
September 1, 2014 at 01:06 #1407Unknown
MemberHi Juan,
Thanks for your reply, after some testing I now believe that there is no problem with the library, its linking the library to the project that’s giving me problems.
I am trying different methods to link the library properly such as
these: http://stackoverflow.com/questions/5487056/linking-library-in-visual-studio-2010
It would be great if someone could share the right process to do this.
Thanks!
AllenSeptember 2, 2014 at 05:40 #1409Unknown
MemberGood news! I am now able to build and run a program but it was a Console Application, now I need to find out how to do it using a Windows form application.
September 2, 2014 at 08:09 #1410Unknown
MemberAfter being able to build and compile a console application, I can now convert it to a Windows Forms applications following the instructions here:
http://jiangsheng.net/2012/12/17/how-to-migrating-a-clr-console-visual-c-project-to-windows-forms/
-
AuthorPosts
- You must be logged in to reply to this topic.