LibLinear with Visual Studio 2012

331 views Asked by At

How do I use Liblinear (as a developer) in a C++ Visual Studio 2012 project? I tried adding the files "linear.h", "linear.cpp", "tron.h", "tron.cpp" to my project; but there are additional dependencies that I could not resolve related to the "blas" directory located inside the liblinear directory. Can anyone please provide a step-by-step explanation on how to use liblinear in visual studio?

Thanks in advance!

2

There are 2 answers

0
junsheng On

You should add the files in the folder "liblinear-1.94\blas" to your project.

0
Hardik Dobariya On

If you do not want the source code then you can try directly calling the windows train.exe and predict.exe from windows directory located in libnear directory

        Process p = new Process();
        p.StartInfo.FileName = @"E:\liblinear-1.94\windows\train.exe";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.RedirectStandardError = true;
        p.StartInfo.CreateNoWindow = false;
        p.StartInfo.Arguments = @" -s 0 E:\Data.train";

        p.Start();
        StreamReader so = p.StandardOutput;
        string a = "";
        while (!p.HasExited)
        {
            Thread.Sleep(100);
            if (!so.EndOfStream)
            {
                Console.WriteLine(so.ReadLine());

            }
        }


        if (!p.StandardError.EndOfStream)
        {
             Console.WriteLine("StdError:" + p.StandardError.ReadToEnd());

        }