Search code examples
c++image-processinginstallationhalide

Getting started with the Halide programming language?


I'm trying to get started with a domain-specific language (C++ extension) for image processing called Halide.

Following the Halide README, here's what I've tried:

  1. Downloaded the Ubuntu 12.04 Halide binary, and extracted in a directory called ~/halide.
  2. In the ~/halide directory, I created hello_halide.cpp, as described in the Using Halide section of this page.
  3. Tried to compile hello_halide.cpp:

    g++-4.6 -std=c++0x hello_halide.cpp -L halide -lHalide -ldl -lpthread -o hello_halide

    But, g++ can't find libhalide:

    /usr/bin/ld: error: cannot find -lHalide

  4. Tried adding ~/halide to my $PATH and $LD_LIBRARY_PATH, but this didn't help.

How can I compile this basic hello_halide.cpp Halide program?


Notes:

  • CUDA is one of Halide's dependencies. I have CUDA installed, and I can compile/run CUDA programs.
  • I'm using Ubuntu 12.04.
  • My g++ version is 4.6.3.

Solution

  • -L halide tells the linker to look for the library in the subdirectory halide. In this case that means that your source file hello_halide.cpp should be in a folder ~/myfolder/, and the library libHalide.so at ~/myfolder/halide/libHalide.so (or .a if it's static). If it's somewhere else, pass an absolute path to -L.

    Your idea of setting LD_LIBRARY_PATH or PATH does not work since the latter is for directories that will be searched for executables and the former is for directories that will be searched for shared libraries when you launch an executable that needs shared libraries.