0

I have installed mlpack via msys2.

Also I have installed gcc via msys2.

Made a simple program in c++ from the code on mlpack website

// This is an interactive demo, so feel free to change the code and click the 'Run' button.

// This simple program uses the mlpack::neighbor::NeighborSearch object
// to find the nearest neighbor of each point in a dataset using the L1 metric,
// and then print the index of the neighbor and the distance of it to stdout.

#include <C:\msys64\mingw64\include\mlpack\core.hpp>
#include <C:\msys64\mingw64\include\mlpack\methods\neighbor_search\neighbor_search.hpp>

using namespace mlpack;
using namespace mlpack::neighbor; // NeighborSearch and NearestNeighborSort
using namespace mlpack::metric; // ManhattanDistance

int main()
{
  // Load the data from data.csv (hard-coded).  Use CLI for simple command-line
  // parameter handling.
  arma::mat data("0.339406815,0.843176636,0.472701471; \
                  0.212587646,0.351174901,0.81056695;  \
                  0.160147626,0.255047893,0.04072469;  \
                  0.564535197,0.943435462,0.597070812"); 
  data = data.t(); 

  // Use templates to specify that we want a NeighborSearch object which uses
  // the Manhattan distance.
  NeighborSearch<NearestNeighborSort, ManhattanDistance> nn(data);

  // Create the object we will store the nearest neighbors in.
  arma::Mat<size_t> neighbors;
  arma::mat distances; // We need to store the distance too.

  // Compute the neighbors.
  nn.Search(1, neighbors, distances);

  // Write each neighbor and distance using Log.
  for (size_t i = 0; i < neighbors.n_elem; ++i)
  {
    std::cout << "Nearest neighbor of point " << i << " is point "
        << neighbors[i] << " and the distance is " << distances[i] << "." << std::endl;
  }

  return 0;
}

Trying to run this program as follows,

g++ nearest-neighbour.cpp -o nearest-neighbour -std=c++11 -larmadillo -l mlpack -lomp

I get the following error while executing the executable.

enter image description here

After installing dependency walker I see the above procedure as flagged in red colour, I dont know what it means. This time I have used below command to compile,

g++ -std=c++11 nearest_neighbour.cpp -o nearest_neighbour.exe -larmadillo -llapack -fopenmp -lmlpack -lboost_serialization-mt -lopenblas

enter image description here

Shoyeb Sheikh
  • 2,659
  • 2
  • 10
  • 19
  • Better to just use some normal operating system. But if windows is mandatory for you, use [dependencies](https://github.com/lucasg/Dependencies) or sth similar to check your exe for missing deps. In error msg `libarmadillo` (one of mlpack dependencies) is mentioned, so maybe some version conflict or whatever. – pptaszni May 04 '22 at 14:16
  • @pptaszni can you please look at the dependency walker screenshot I have uploaded ? I cant figure whats wrong and how to get it solved – Shoyeb Sheikh May 06 '22 at 03:17
  • or should I build mlpack from source ? – Shoyeb Sheikh May 06 '22 at 03:28
  • Hard to tell, looks like this `libarmadillo` does not have any required symbols, so maybe is corrupted, maybe was not built. Sure might be a good idea to rebuild from source. Otherwise, need to check with someone more experienced with windows. – pptaszni May 06 '22 at 11:20

0 Answers0