DSL_dataset Problem in Visual Studio 2008

The engine.
Post Reply
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

DSL_dataset Problem in Visual Studio 2008

Post by shenxu »

I am using SMILE lib over one week now, everything works good. However, when I change my configuration to "Release", there is a run time error when DSL_dataset.ReadFile() has been called.

Here is a sample code:

Code: Select all

#include <iostream>
#include <string>
#include "smile.h"
#include "smilearn.h"

using namespace std;

int main()
{
	DSL_dataset ds;
	int result;
	result = ds.ReadFile("test_dis.txt");
	return 0;
}

When I change the configuration to "Debug" mode, everything works well.

Here is the run time error:
Debug Assertion Failed!
Program:
..........\bin\Bayes.exe
File: C:\vs9\vc\include\vector
line: 70

Expression:("_Pvector==NULL||(((_Myvec*)_Pvector)->_Myfirst<=
_Ptr&&_Ptr<=((_Myvec*)_Pvector)->_Mylast)",0)

For information on how your program can cause an assertion failure,.......
And I think my configuration is correct, because there is no link error or something.

Thank you very much!!!
shooltz[BayesFusion]
Site Admin
Posts: 1457
Joined: Mon Nov 26, 2007 5:51 pm

Re: DSL_dataset Problem in Visual Studio 2008

Post by shooltz[BayesFusion] »

Asserts shouldn't fire in release mode, because the preprocessor removes them. I'd check the project configuration - the library settings are per-config, so you may have the Debug configured properly (no explicit reference to SMILE libs), and Release can have config problems.
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Re: DSL_dataset Problem in Visual Studio 2008

Post by shenxu »

Thank you for your reminder! I fixed it. Share it here, if any other guy have the similar problem:

In the Release Mode, the Default Run time Library has been set as "Multi-threaded DLL (/MD)".

However, SMILE require that "runtime library must be set to Multi-threaded Debug DLL".

I changed the run time library, the problem solved.
shooltz[BayesFusion]
Site Admin
Posts: 1457
Joined: Mon Nov 26, 2007 5:51 pm

Re: DSL_dataset Problem in Visual Studio 2008

Post by shooltz[BayesFusion] »

shenxu wrote:Thank you for your reminder! I fixed it. Share it here, if any other guy have the similar problem:
In the Release Mode, the Default Run time Library has been set as "Multi-threaded DLL (/MD)".
However, SMILE require that "runtime library must be set to Multi-threaded Debug DLL".
Sorry, but this is not correct. The notice from SMILE download page says:

SMILE distributions for Visual C++ contais three sets of libraries: two optimized builds for static and dynamic CRT, and another unoptimized build linking against debug DLL runtime without NDEBUG defined.
smile.h and smilearn.h contain autolink #pragma directives and will select correct library, depending on CRT configuration of your project.
DO NOT add smile.lib as additional linker input in project settings - smile.h takes care of that.


Release builds with SMILE are possible with both /MT (Multi-threaded) and /MD (Multi-threaded DLL). Debug builds support only /MDd (Multi-threaded debug DLL). If you had to manually change the runtime library to /MDd in order to run the app, you have some superfluous linker settings wrt to SMILE libs. Let the smile.h/smilearn.h #pragmas work and you should be fine.
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Re: DSL_dataset Problem in Visual Studio 2008

Post by shenxu »

Oh, then I am confused. Here is the steps I create a project in visual studio 2008 with SMILE:

1. In VS 2008, create an empty project. Add a new cpp file. Write the simple code I pasted above in the cpp file.


2. In the project property page, change configuration from "Debug" to "Release", Platform "Win32".

3. Go to c/c++ / General / Additional Include Directories. Add the SMILE folder path, such as ..\..\smile

3. Go to Liker / General / Additional library Directories. Add the SMILE folder path, such as ..\..\smile

4. Active "Release" mode and build the app.

Then, when I run this app, a run time error occurs. However, if I change run time library to "Multi-threaded Debug DLL", no error anymore.

Would you kindly help me out? What's wrong with my configuration? I am using VS 2008 SP1.

Thanks a lot!!!
shooltz[BayesFusion]
Site Admin
Posts: 1457
Joined: Mon Nov 26, 2007 5:51 pm

Re: DSL_dataset Problem in Visual Studio 2008

Post by shooltz[BayesFusion] »

I've just tested it with VS 2008/fresh console project and SMILE binaries from the download page. I've used your code from the original post and everything works fine without any manual tweaks wrt to C++ runtime.

I thought you have problem with _SECURE_SCL=0, but smile.h would bomb if this was not set in release build. I still think you have some leftover library settings in release build. If possible, zip your solution directory and post it here (clean first, so no binaries/objs are inside the archive file).
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Re: DSL_dataset Problem in Visual Studio 2008

Post by shenxu »

I attached my sample project here. I soooo appreciate.
Last edited by shenxu on Fri Sep 17, 2010 1:22 am, edited 1 time in total.
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Re: DSL_dataset Problem in Visual Studio 2008

Post by shenxu »

Here is the zip file with project. pls copy the SMILE lib vs 2008 into the "smile" folder.

Thank you very much
Attachments
conSMILE.zip
(375.82 KiB) Downloaded 763 times
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Re: DSL_dataset Problem in Visual Studio 2008

Post by shenxu »

I think I finally solved the problem this time. I did create a whole empty VC++ project, which is the reason it does not work. Instead, I create a Win32 Console Application with an empty file. After I defined _SECURE_SCL as 0 in preprocessor definition, the app works good.

Thank you again!
Post Reply