问题
Has anyone done this before ? I am not able to get it to work. Following are my steps:
- Download the windows package from link
- I can run qfuzzylite (gui-tool) without any problem. Now I want to use the fuzzylite lib in my Visual Studio + Qt Integration Project.
- In the CMake GUI I give fuzzylite source folder as the input folder and select Visual Studio 2010 as the compiler.
- I am able to generate the Visual Studio fuzzylite solution in CMake without any errors.
- Then, I tried to build the Visual Studio solution, but it fails with some weird errors. However, it does generate the fuzzylite-dbg.lib file (which I need).
- Then I use this lib file and the fuzzylite.dll and include the path to the Headers in the VS Project. The project builds without any errors.
Now in the code I am doing
fl::Engine* engine = new fl::Engine("simple-dimmer");
This fails with the following exception:
exception text: bad allocation
exception type: class std::bad_alloc
回答1:
Thank you for your detailed steps, but the solution seems to be a bit random (or weird as you put it). Unless more information is provided about the error, I strongly discourage the use of such a solution to attempt any fix to fuzzylite.
If you are running into problems, I strongly encourage you to report the problem in the forums at http://www.fuzzylite.com, where I and others will be very happy to help you.
As for the compiling errors, fuzzylite treats warnings as errors. A warning that is being raised in fuzzylite 4.0 when compiled using Visual Studio (not from console via nmake), and potentially in previous versions, is warning C4702, which refers to unreachable code. You can fix this by adding in file fl/fuzzylite.h
the following line within the #ifdef FL_WINDOWS
(together other #pragma
s):
#pragma warning(disable:4702) //Ignore unreachable code
If the library was not built correctly, errors are bound to happen during runtime.
回答2:
Ok, got it :)
Here are the steps for future reference:
- Download the windows package from link
- In the CMake GUI I give fuzzylite source folder as the input folder and select Visual Studio 2010 as the compiler. Now, if you want to use the lib in Debug mode tick the FL_DEBUG box (this is where I went wrong)
- Now on clicking "generate", it will generate 5 projects:
- ALL_BUILD
- fl-bin
- fl-shared
- fl-static
- INSTALL
- ZERO_CHECK
Now in the Project properties in fl-bin, shared and static go to the Project Properties. In C/C++ go to Preprocessor get rid of the space in FL_DATA="mm.dd.yyyy " to "mm.dd.yyyy" (weird). The solution should build fine and will generate fuzzylite-dbg.dll and fuzzylite-dbg.lib in the lib folder.
Use these files in your VC Project by adding the fuzzy-dbg.lib as the linker input and place the dll in the solution folder. Give the path "path\to\fuzzylite\fuzzylite." to the Include Directories.
Do the same process for Release mode (don't tick the FL_DEBUG flag)
来源:https://stackoverflow.com/questions/17339500/using-fuzzylite-in-visual-studio-2010