Skip to content

Problem with STB support #3514

@jaja360

Description

@jaja360

Issue description

Since on my system (Ubuntu 23.04) the mlpack-dev package does not seem available, I installed the library using cmake by following the steps in the readme file. Everything installs with no error. However, when I try to load an image with the data::Load function, I always get "false" and the image is not loaded.

Your environment

  • version of mlpack: latest at the time of writing this (5e8beeb)
  • operating system: Ubuntu 23.04
  • compiler: g++ 12.2
  • version of dependencies (Boost/Armadillo): (Armadillo: 11.4.2, Ensmallen: 2.19.1, Cereal: 1.3.2)
  • any other environment information you think is relevant:

When doing cmake .., the output contains the following lines:

-- Found StbImage: /usr/include/stb/
-- Check that STB static implementation mode links correctly...
-- Check that STB static implementation mode links correctly... success

According to the readme, "If the STB library headers are available, image loading support will be available.", therefore I assume I don't need to specify a flag manually when compiling the library with cmake .. and sudo make install.

Steps to reproduce

I compile this simple program:

#include <mlpack.hpp>
using namespace mlpack;
int main() {
  data::ImageInfo info;
  arma::mat matrix;
  data::Load("test.bmp", matrix, info, true);
}

using this command: g++ -std=c++17 -I/usr/include/stb/ -I/usr/local/include/ test.cpp -larmadillo -L/usr/lib/gcc/x86_64-linux-gnu/12/ -lgomp -lpthread (I used the flags given by pkg-config --cflags mlpack and pkg-config --libs mlpack).

Expected behavior

I expect no runtime error.

Actual behavior

I receive the following error:

[FATAL] Load(): mlpack was not compiled with STB support, so images cannot be loaded!

terminate called after throwing an instance of 'std::runtime_error'
  what():  fatal error; see Log::Fatal output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions