Skip to content

Mac OSX cmake libHalide.dylib path error #2821

@LoveDaisy

Description

@LoveDaisy

I'm working on mac OSX and trying to compile my small project with cmake. I wrote my CMakeLists.txt as follows:

# my CMakeLists.txt
cmake_minimum_required(VERSION 3.9)
set(CMAKE_CXX_STANDARD 11)

# path to distribution of halide
set(HALIDE_DISTRIB_DIR "/my/halide/path")
include("${HALIDE_DISTRIB_DIR}/halide_config.cmake")
include("${HALIDE_DISTRIB_DIR}/halide.cmake")

halide_library(blf
    SRCS bilateral_filter_generator.cpp
    GENERATOR_ARGS auto_schedule=true)

add_executable(process process.cpp)
target_link_libraries(process PUBLIC blf)

The problem is, when I finished cmake and start make, it reports an error:

$ make
Scanning dependencies of target halide_library_runtime.generator_binary
[ 12%] Building CXX object CMakeFiles/halide_library_runtime.generator_binary.dir/path/to/halide/tools/GenGen.cpp.o
[ 25%] Linking CXX executable halide_library_runtime.generator_binary
[ 25%] Built target halide_library_runtime.generator_binary
Scanning dependencies of target halide_rt_host_runtime_gen
dyld: Library not loaded: /Users/halidenightly/build_bot_new/worker/mac-64-trunk/halide-build/bin/libHalide.dylib
  Referenced from: /path/to/my/project/build/./halide_library_runtime.generator_binary
  Reason: image not found
make[2]: *** [genfiles/halide_rt_host/halide_rt_host.a] Abort trap: 6
make[1]: *** [CMakeFiles/halide_rt_host_runtime_gen.dir/all] Error 2
make: *** [all] Error 2

Note that it tried to find libHalide.dylib at /Users/halidenightly/build_bot_new/worker/mac-64-trunk/halide-build/bin/libHalide.dylib, which obviously is NOT path on my mac. Looks like it's a path on a building server.

I'm new to cmake and I have no idea about how to figure out what is going wrong. I guess there may be some mistakes in those cmake functions defined in halide.cmake? Any one has met similar problems?

P.S. It is totally OK and works well when I use hand-write g++ command to build my project, as follows:

# my build.sh
g++ bilateral_filter_generator.cpp /path/to/halide/tools/GenGen.cpp -g -std=c++11 -fno-rtti \
    -I /path/to/halide/include -L /path/to/halide/bin -lHalide -lpthread -ldl -o generate
DYLD_LIBRARY_PATH=/path/to/halide/bin ./generate -g blf -o . target=host auto_schedule=true
g++ process.cpp blf.a -g -std=c++11 -fno-rtti -I /path/to/halide/include \
    -I /path/to/halide/tools -L /path/to/halide/bin -lHalide -o process

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues related to building Halide and with CI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions