Make cpptest failed


#1

I tried to follow Testing instructions on https://docs.tvm.ai/contribute/pull_request.html#testing

I used Ubuntu 18.04.1 LTS
I installed
googletest-release-1.8.1
cmake version 3.10.2
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

cloned tvm 92a0048907bebfbf7b9a0f1e9c68a28c97866595

git clone --recursive https://github.com/dmlc/tvm

after that I run

cd tvm

# assume you are in tvm source root
TVM_ROOT=`pwd`

# you need to install google test first, gtest will be installed to $TVM_ROOT/lib
CACHE_PREFIX=. make -f 3rdparty/dmlc-core/scripts/packages.mk gtest

mkdir build
cd build
GTEST_LIB=$TVM_ROOT/lib cmake ..
make cpptest -j1 VERBOSE=1

Error:

/usr/bin/cmake -H/home/dlc/tvm -B/home/dlc/tvm/build --check-build-system CMakeFiles/Makefile.cmake 0
make -f CMakeFiles/Makefile2 cpptest
make[1]: Entering directory '/home/dlc/tvm/build'
/usr/bin/cmake -H/home/dlc/tvm -B/home/dlc/tvm/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/dlc/tvm/build/CMakeFiles 78
make -f CMakeFiles/Makefile2 CMakeFiles/cpptest.dir/all
make[2]: Entering directory '/home/dlc/tvm/build'
make -f CMakeFiles/tvm.dir/build.make CMakeFiles/tvm.dir/depend
make[3]: Entering directory '/home/dlc/tvm/build'
cd /home/dlc/tvm/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dlc/tvm /home/dlc/tvm /home/dlc/tvm/build /home/dlc/tvm/build /home/dlc/tvm/build/CMakeFiles/tvm.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/home/dlc/tvm/build'
make -f CMakeFiles/tvm.dir/build.make CMakeFiles/tvm.dir/build
make[3]: Entering directory '/home/dlc/tvm/build'
make[3]: Nothing to be done for 'CMakeFiles/tvm.dir/build'.
make[3]: Leaving directory '/home/dlc/tvm/build'
[ 88%] Built target tvm
make -f CMakeFiles/pattern_match_test.dir/build.make CMakeFiles/pattern_match_test.dir/depend
make[3]: Entering directory '/home/dlc/tvm/build'
cd /home/dlc/tvm/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dlc/tvm /home/dlc/tvm /home/dlc/tvm/build /home/dlc/tvm/build /home/dlc/tvm/build/CMakeFiles/pattern_match_test.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/home/dlc/tvm/build'
make -f CMakeFiles/pattern_match_test.dir/build.make CMakeFiles/pattern_match_test.dir/build
make[3]: Entering directory '/home/dlc/tvm/build'
[ 88%] Linking CXX executable pattern_match_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/pattern_match_test.dir/link.txt --verbose=1
/usr/bin/c++  -faligned-new -O2 -Wall -fPIC -fvisibility=hidden -std=c++11   -rdynamic CMakeFiles/pattern_match_test.dir/tests/cpp/pattern_match_test.cc.o  -o pattern_match_test -Wl,-rpath,/home/dlc/tvm/build libtvm.so /usr/local/lib/libgtest.a -lpthread 
CMakeFiles/pattern_match_test.dir/tests/cpp/pattern_match_test.cc.o: In function `_GLOBAL__sub_I_pattern_match_test.cc':
pattern_match_test.cc:(.text.startup+0xae): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
pattern_match_test.cc:(.text.startup+0xf7): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
libtvm.so: undefined reference to `dlopen'
libtvm.so: undefined reference to `dlclose'
libtvm.so: undefined reference to `dlerror'
libtvm.so: undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
CMakeFiles/pattern_match_test.dir/build.make:96: recipe for target 'pattern_match_test' failed
make[3]: *** [pattern_match_test] Error 1
make[3]: Leaving directory '/home/dlc/tvm/build'
CMakeFiles/Makefile2:778: recipe for target 'CMakeFiles/pattern_match_test.dir/all' failed
make[2]: *** [CMakeFiles/pattern_match_test.dir/all] Error 2
make[2]: Leaving directory '/home/dlc/tvm/build'
CMakeFiles/Makefile2:120: recipe for target 'CMakeFiles/cpptest.dir/rule' failed
make[1]: *** [CMakeFiles/cpptest.dir/rule] Error 2
make[1]: Leaving directory '/home/dlc/tvm/build'
Makefile:177: recipe for target 'cpptest' failed
make: *** [cpptest] Error 2

#2

Perhaps was due to missing flags (for dlsym) on your side? Seems works fine on my local machine


#3

I added -ldl to the following command. Now I have the following error

$ ~/tvm/build$ /usr/bin/c++ -faligned-new -O2 -Wall -fPIC -fvisibility=hidden -std=c++11   -rdynamic CMakeFiles/pattern_match_test.dir/tests/cpp/pattern_match_test.cc.o  -o pattern_match_test  -Wl,-rpath,/home/dlc/tvm/build libtvm.so  /usr/local/lib/libgtest.a -lpthread -ldl
CMakeFiles/pattern_match_test.dir/tests/cpp/pattern_match_test.cc.o: In function `_GLOBAL__sub_I_pattern_match_test.cc':
pattern_match_test.cc:(.text.startup+0xae): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
pattern_match_test.cc:(.text.startup+0xf7): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
collect2: error: ld returned 1 exit status


#4

I tried to follow Testing instructions again on fresh Ubuntu 16.04 LTS
Other people can easily reproduce the issue.
https://docs.tvm.ai/contribute/pull_request.html#testing

docker run -it ubuntu:16.04

I installed gtest using apt

apt install libgtest-dev

Still having the error.

git clone --recursive https://github.com/dmlc/tvm tvm-test
cd tvm-test

TVM_ROOT=`pwd`
CACHE_PREFIX=. make -f 3rdparty/dmlc-core/scripts/packages.mk gtest

mkdir build
cd build
GTEST_LIB=$TVM_ROOT/lib cmake ..

make cpptest -j2 VERBOSE=1

[ 88%] Linking CXX shared library libtvm.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/tvm.dir/link.txt --verbose=1
/usr/bin/c++  -fPIC -O2 -Wall -fPIC -fvisibility=hidden -std=c++11   -shared -Wl,-soname,libtvm.so -o libtvm.so CMakeFiles/tvm.dir/src/api/dsl_api.cc.o CMakeFiles/tvm.dir/src/api/api_base.cc.o CMakeFiles/tvm.dir/src/api/api_arith.cc.o CMakeFiles/tvm.dir/src/api/api_ir.cc.o CMakeFiles/tvm.dir/src/api/api_schedule.cc.o CMakeFiles/tvm.dir/src/api/api_codegen.cc.o CMakeFiles/tvm.dir/src/api/api_lang.cc.o CMakeFiles/tvm.dir/src/api/api_pass.cc.o CMakeFiles/tvm.dir/src/api/api_test.cc.o CMakeFiles/tvm.dir/src/arithmetic/domain_touched.cc.o CMakeFiles/tvm.dir/src/arithmetic/analyzer.cc.o CMakeFiles/tvm.dir/src/arithmetic/int_set.cc.o CMakeFiles/tvm.dir/src/arithmetic/modular_set.cc.o CMakeFiles/tvm.dir/src/arithmetic/canonical.cc.o CMakeFiles/tvm.dir/src/arithmetic/bound_deducer.cc.o CMakeFiles/tvm.dir/src/arithmetic/rewrite_simplify.cc.o CMakeFiles/tvm.dir/src/arithmetic/detect_linear_equation.cc.o CMakeFiles/tvm.dir/src/arithmetic/const_int_bound.cc.o CMakeFiles/tvm.dir/src/autotvm/feature_visitor.cc.o CMakeFiles/tvm.dir/src/autotvm/touch_extractor.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_opengl.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_opencl.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_cuda.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_source_base.cc.o CMakeFiles/tvm.dir/src/codegen/intrin_rule.cc.o CMakeFiles/tvm.dir/src/codegen/intrin_rule_opengl.cc.o CMakeFiles/tvm.dir/src/codegen/source_module.cc.o CMakeFiles/tvm.dir/src/codegen/intrin_rule_cuda.cc.o CMakeFiles/tvm.dir/src/codegen/intrin_rule_vhls.cc.o CMakeFiles/tvm.dir/src/codegen/build_module.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_aocl.cc.o CMakeFiles/tvm.dir/src/codegen/intrin_rule_opencl.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_c_host.cc.o CMakeFiles/tvm.dir/src/codegen/codegen.cc.o CMakeFiles/tvm.dir/src/codegen/intrin_rule_metal.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_vhls.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_c.cc.o CMakeFiles/tvm.dir/src/codegen/codegen_metal.cc.o CMakeFiles/tvm.dir/src/codegen/intrin_rule_aocl.cc.o CMakeFiles/tvm.dir/src/lang/lowered_func.cc.o CMakeFiles/tvm.dir/src/lang/api_registry.cc.o CMakeFiles/tvm.dir/src/lang/data_layout.cc.o CMakeFiles/tvm.dir/src/lang/expr.cc.o CMakeFiles/tvm.dir/src/lang/ir.cc.o CMakeFiles/tvm.dir/src/lang/buffer.cc.o CMakeFiles/tvm.dir/src/lang/channel.cc.o CMakeFiles/tvm.dir/src/lang/tensor.cc.o CMakeFiles/tvm.dir/src/lang/attrs.cc.o CMakeFiles/tvm.dir/src/lang/target_info.cc.o CMakeFiles/tvm.dir/src/lang/reflection.cc.o CMakeFiles/tvm.dir/src/lang/expr_operator.cc.o CMakeFiles/tvm.dir/src/pass/remap_thread_axis.cc.o CMakeFiles/tvm.dir/src/pass/ir_deep_compare.cc.o CMakeFiles/tvm.dir/src/pass/lower_tvm_builtin.cc.o CMakeFiles/tvm.dir/src/pass/split_pipeline.cc.o CMakeFiles/tvm.dir/src/pass/lower_intrin.cc.o CMakeFiles/tvm.dir/src/pass/storage_rewrite.cc.o CMakeFiles/tvm.dir/src/pass/ir_visitor.cc.o CMakeFiles/tvm.dir/src/pass/split_host_device.cc.o CMakeFiles/tvm.dir/src/pass/lift_attr_scope.cc.o CMakeFiles/tvm.dir/src/pass/vectorize_loop.cc.o CMakeFiles/tvm.dir/src/pass/storage_flatten.cc.o CMakeFiles/tvm.dir/src/pass/ir_mutator.cc.o CMakeFiles/tvm.dir/src/pass/ir_util.cc.o CMakeFiles/tvm.dir/src/pass/inject_copy_intrin.cc.o CMakeFiles/tvm.dir/src/pass/verify_gpu_code.cc.o CMakeFiles/tvm.dir/src/pass/coproc_sync.cc.o CMakeFiles/tvm.dir/src/pass/lower_warp_memory.cc.o CMakeFiles/tvm.dir/src/pass/remove_no_op.cc.o CMakeFiles/tvm.dir/src/pass/storage_sync.cc.o CMakeFiles/tvm.dir/src/pass/detect_device.cc.o CMakeFiles/tvm.dir/src/pass/rewrite_unsafe_select.cc.o CMakeFiles/tvm.dir/src/pass/inline.cc.o CMakeFiles/tvm.dir/src/pass/narrow_channel_access.cc.o CMakeFiles/tvm.dir/src/pass/ssa.cc.o CMakeFiles/tvm.dir/src/pass/arg_binder.cc.o CMakeFiles/tvm.dir/src/pass/inject_prefetch.cc.o CMakeFiles/tvm.dir/src/pass/bound_checker.cc.o CMakeFiles/tvm.dir/src/pass/unroll_loop.cc.o CMakeFiles/tvm.dir/src/pass/verify_memory.cc.o CMakeFiles/tvm.dir/src/pass/lower_thread_allreduce.cc.o CMakeFiles/tvm.dir/src/pass/loop_partition.cc.o CMakeFiles/tvm.dir/src/pass/storage_access.cc.o CMakeFiles/tvm.dir/src/pass/simple_passes.cc.o CMakeFiles/tvm.dir/src/pass/inject_virtual_thread.cc.o CMakeFiles/tvm.dir/src/pass/inject_double_buffer.cc.o CMakeFiles/tvm.dir/src/pass/make_api.cc.o CMakeFiles/tvm.dir/src/pass/combine_context_call.cc.o CMakeFiles/tvm.dir/src/op/scan_op.cc.o CMakeFiles/tvm.dir/src/op/op_util.cc.o CMakeFiles/tvm.dir/src/op/hybrid_op.cc.o CMakeFiles/tvm.dir/src/op/tensorize.cc.o CMakeFiles/tvm.dir/src/op/tensor_compute_op.cc.o CMakeFiles/tvm.dir/src/op/compute_op.cc.o CMakeFiles/tvm.dir/src/op/placeholder_op.cc.o CMakeFiles/tvm.dir/src/op/cross_thread_reduction.cc.o CMakeFiles/tvm.dir/src/op/extern_op.cc.o CMakeFiles/tvm.dir/src/schedule/schedule_lang.cc.o CMakeFiles/tvm.dir/src/schedule/schedule_ops.cc.o CMakeFiles/tvm.dir/src/schedule/auto_inline_elem_wise.cc.o CMakeFiles/tvm.dir/src/schedule/schedule_dataflow_rewrite.cc.o CMakeFiles/tvm.dir/src/schedule/message_passing.cc.o CMakeFiles/tvm.dir/src/schedule/graph.cc.o CMakeFiles/tvm.dir/src/schedule/bound.cc.o CMakeFiles/tvm.dir/src/relay/ir/alpha_equal.cc.o CMakeFiles/tvm.dir/src/relay/ir/text_printer.cc.o CMakeFiles/tvm.dir/src/relay/ir/op.cc.o CMakeFiles/tvm.dir/src/relay/ir/type.cc.o CMakeFiles/tvm.dir/src/relay/ir/type_functor.cc.o CMakeFiles/tvm.dir/src/relay/ir/base.cc.o CMakeFiles/tvm.dir/src/relay/ir/expr.cc.o CMakeFiles/tvm.dir/src/relay/ir/adt.cc.o CMakeFiles/tvm.dir/src/relay/ir/error.cc.o CMakeFiles/tvm.dir/src/relay/ir/expr_functor.cc.o CMakeFiles/tvm.dir/src/relay/ir/module.cc.o CMakeFiles/tvm.dir/src/relay/ir/hash.cc.o CMakeFiles/tvm.dir/src/relay/ir/pattern_functor.cc.o CMakeFiles/tvm.dir/src/relay/backend/interpreter.cc.o CMakeFiles/tvm.dir/src/relay/backend/param_dict.cc.o CMakeFiles/tvm.dir/src/relay/backend/compile_engine.cc.o CMakeFiles/tvm.dir/src/relay/backend/graph_plan_memory.cc.o CMakeFiles/tvm.dir/src/relay/op/type_relations.cc.o CMakeFiles/tvm.dir/src/relay/op/image/resize.cc.o CMakeFiles/tvm.dir/src/relay/op/annotation/annotation.cc.o CMakeFiles/tvm.dir/src/relay/op/tensor/reduce.cc.o CMakeFiles/tvm.dir/src/relay/op/tensor/transform.cc.o CMakeFiles/tvm.dir/src/relay/op/tensor/unary.cc.o CMakeFiles/tvm.dir/src/relay/op/tensor/binary.cc.o CMakeFiles/tvm.dir/src/relay/op/vision/rcnn_op.cc.o CMakeFiles/tvm.dir/src/relay/op/vision/multibox_op.cc.o CMakeFiles/tvm.dir/src/relay/op/vision/yolo.cc.o CMakeFiles/tvm.dir/src/relay/op/vision/nms.cc.o CMakeFiles/tvm.dir/src/relay/op/nn/nn.cc.o CMakeFiles/tvm.dir/src/relay/op/nn/upsampling.cc.o CMakeFiles/tvm.dir/src/relay/op/nn/pooling.cc.o CMakeFiles/tvm.dir/src/relay/op/nn/pad.cc.o CMakeFiles/tvm.dir/src/relay/op/nn/convolution.cc.o CMakeFiles/tvm.dir/src/relay/op/device_copy.cc.o CMakeFiles/tvm.dir/src/relay/op/debug.cc.o CMakeFiles/tvm.dir/src/relay/pass/canonicalize_ops.cc.o CMakeFiles/tvm.dir/src/relay/pass/expr_subst.cc.o CMakeFiles/tvm.dir/src/relay/pass/dead_code.cc.o CMakeFiles/tvm.dir/src/relay/pass/quantize.cc.o CMakeFiles/tvm.dir/src/relay/pass/alter_op_layout.cc.o CMakeFiles/tvm.dir/src/relay/pass/kind_check.cc.o CMakeFiles/tvm.dir/src/relay/pass/type_infer.cc.o CMakeFiles/tvm.dir/src/relay/pass/util.cc.o CMakeFiles/tvm.dir/src/relay/pass/device_annotation.cc.o CMakeFiles/tvm.dir/src/relay/pass/fuse_ops.cc.o CMakeFiles/tvm.dir/src/relay/pass/to_a_normal_form.cc.o CMakeFiles/tvm.dir/src/relay/pass/eliminate_common_subexpr.cc.o CMakeFiles/tvm.dir/src/relay/pass/fold_constant.cc.o CMakeFiles/tvm.dir/src/relay/pass/to_graph_normal_form.cc.o CMakeFiles/tvm.dir/src/relay/pass/well_formed.cc.o CMakeFiles/tvm.dir/src/relay/pass/forward_rewrite.cc.o CMakeFiles/tvm.dir/src/relay/pass/pass_manager.cc.o CMakeFiles/tvm.dir/src/relay/pass/gradient.cc.o CMakeFiles/tvm.dir/src/relay/pass/fold_scale_axis.cc.o CMakeFiles/tvm.dir/src/relay/pass/simplify_inference.cc.o CMakeFiles/tvm.dir/src/relay/pass/type_solver.cc.o CMakeFiles/tvm.dir/src/relay/pass/mac_count.cc.o CMakeFiles/tvm.dir/src/relay/pass/combine_parallel_conv2d.cc.o CMakeFiles/tvm.dir/src/codegen/verilog/codegen_verilog.cc.o CMakeFiles/tvm.dir/src/codegen/verilog/verilog_ir.cc.o CMakeFiles/tvm.dir/src/codegen/verilog/verilog_module.cc.o CMakeFiles/tvm.dir/src/codegen/verilog/vpi_device_api.cc.o CMakeFiles/tvm.dir/src/codegen/verilog/vpi_session.cc.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/ir/IRPrinter.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/ir/IROperator.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/ir/IR.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/ir/IRMutator.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/ir/IREquality.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/ir/IRVisitor.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/arithmetic/Simplify.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/arithmetic/Substitute.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/arithmetic/Interval.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/arithmetic/ModulusRemainder.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/arithmetic/Deinterleave.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/base/Debug.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/base/Float16Opt.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/base/Util.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/base/Type.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/base/Error.cpp.o CMakeFiles/tvm.dir/3rdparty/HalideIR/src/tvm/node/node.cpp.o CMakeFiles/tvm.dir/src/codegen/stackvm/codegen_stackvm.cc.o CMakeFiles/tvm.dir/src/runtime/stackvm/stackvm.cc.o CMakeFiles/tvm.dir/src/runtime/stackvm/stackvm_module.cc.o CMakeFiles/tvm.dir/src/codegen/opt/build_cuda_off.cc.o CMakeFiles/tvm.dir/src/codegen/opt/build_sdaccel_off.cc.o CMakeFiles/tvm.dir/src/codegen/opt/build_aocl_off.cc.o CMakeFiles/tvm.dir/src/codegen/opt/build_opencl_off.cc.o CMakeFiles/tvm.dir/src/codegen/opt/build_opengl_off.cc.o CMakeFiles/tvm.dir/src/codegen/opt/build_metal_off.cc.o CMakeFiles/tvm.dir/src/codegen/opt/build_rocm_off.cc.o CMakeFiles/tvm.dir/src/contrib/hybrid/codegen_hybrid.cc.o CMakeFiles/tvm.dir/src/runtime/thread_pool.cc.o CMakeFiles/tvm.dir/src/runtime/system_lib_module.cc.o CMakeFiles/tvm.dir/src/runtime/c_dsl_api.cc.o CMakeFiles/tvm.dir/src/runtime/c_runtime_api.cc.o CMakeFiles/tvm.dir/src/runtime/cpu_device_api.cc.o CMakeFiles/tvm.dir/src/runtime/builtin_fp16.cc.o CMakeFiles/tvm.dir/src/runtime/workspace_pool.cc.o CMakeFiles/tvm.dir/src/runtime/ndarray.cc.o CMakeFiles/tvm.dir/src/runtime/module_util.cc.o CMakeFiles/tvm.dir/src/runtime/file_util.cc.o CMakeFiles/tvm.dir/src/runtime/module.cc.o CMakeFiles/tvm.dir/src/runtime/registry.cc.o CMakeFiles/tvm.dir/src/runtime/dso_module.cc.o CMakeFiles/tvm.dir/src/runtime/threading_backend.cc.o CMakeFiles/tvm.dir/src/runtime/rpc/rpc_module.cc.o CMakeFiles/tvm.dir/src/runtime/rpc/rpc_socket_impl.cc.o CMakeFiles/tvm.dir/src/runtime/rpc/rpc_event_impl.cc.o CMakeFiles/tvm.dir/src/runtime/rpc/rpc_device_api.cc.o CMakeFiles/tvm.dir/src/runtime/rpc/rpc_server_env.cc.o CMakeFiles/tvm.dir/src/runtime/rpc/rpc_session.cc.o CMakeFiles/tvm.dir/src/runtime/graph/graph_runtime.cc.o 
make[3]: Leaving directory '/root/tvm-test/build'
[ 88%] Built target tvm
make -f CMakeFiles/build_module_test.dir/build.make CMakeFiles/build_module_test.dir/depend
make -f CMakeFiles/simple_passes_test.dir/build.make CMakeFiles/simple_passes_test.dir/depend
make[3]: Entering directory '/root/tvm-test/build'
cd /root/tvm-test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/tvm-test /root/tvm-test /root/tvm-test/build /root/tvm-test/build /root/tvm-test/build/CMakeFiles/build_module_test.dir/DependInfo.cmake --color=
make[3]: Entering directory '/root/tvm-test/build'
cd /root/tvm-test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/tvm-test /root/tvm-test /root/tvm-test/build /root/tvm-test/build /root/tvm-test/build/CMakeFiles/simple_passes_test.dir/DependInfo.cmake --color=
Dependee "/root/tvm-test/build/CMakeFiles/build_module_test.dir/DependInfo.cmake" is newer than depender "/root/tvm-test/build/CMakeFiles/build_module_test.dir/depend.internal".
Dependee "/root/tvm-test/build/CMakeFiles/simple_passes_test.dir/DependInfo.cmake" is newer than depender "/root/tvm-test/build/CMakeFiles/simple_passes_test.dir/depend.internal".
Dependee "/root/tvm-test/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/root/tvm-test/build/CMakeFiles/build_module_test.dir/depend.internal".
Dependee "/root/tvm-test/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/root/tvm-test/build/CMakeFiles/simple_passes_test.dir/depend.internal".
Scanning dependencies of target build_module_test
Scanning dependencies of target simple_passes_test
make[3]: Leaving directory '/root/tvm-test/build'
make -f CMakeFiles/build_module_test.dir/build.make CMakeFiles/build_module_test.dir/build
make[3]: Leaving directory '/root/tvm-test/build'
make -f CMakeFiles/simple_passes_test.dir/build.make CMakeFiles/simple_passes_test.dir/build
make[3]: Entering directory '/root/tvm-test/build'
make[3]: Entering directory '/root/tvm-test/build'
[ 88%] Building CXX object CMakeFiles/build_module_test.dir/tests/cpp/build_module_test.cc.o
[ 88%] Building CXX object CMakeFiles/simple_passes_test.dir/tests/cpp/simple_passes_test.cc.o
/usr/bin/c++   -DDMLC_USE_FOPEN64=0 -I/root/tvm-test/include -I/root/tvm-test/3rdparty/dlpack/include -I/root/tvm-test/3rdparty/dmlc-core/include -I/root/tvm-test/3rdparty/rang/include -I/root/tvm-test/3rdparty/compiler-rt -I/root/tvm-test/3rdparty/HalideIR/src -I/root/tvm-test/topi/include  -O2 -Wall -fPIC -fvisibility=hidden -std=c++11    -o CMakeFiles/simple_passes_test.dir/tests/cpp/simple_passes_test.cc.o -c /root/tvm-test/tests/cpp/simple_passes_test.cc
/usr/bin/c++   -DDMLC_USE_FOPEN64=0 -I/root/tvm-test/include -I/root/tvm-test/3rdparty/dlpack/include -I/root/tvm-test/3rdparty/dmlc-core/include -I/root/tvm-test/3rdparty/rang/include -I/root/tvm-test/3rdparty/compiler-rt -I/root/tvm-test/3rdparty/HalideIR/src -I/root/tvm-test/topi/include  -O2 -Wall -fPIC -fvisibility=hidden -std=c++11    -o CMakeFiles/build_module_test.dir/tests/cpp/build_module_test.cc.o -c /root/tvm-test/tests/cpp/build_module_test.cc
[ 89%] Linking CXX executable simple_passes_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/simple_passes_test.dir/link.txt --verbose=1
/usr/bin/c++   -O2 -Wall -fPIC -fvisibility=hidden -std=c++11    CMakeFiles/simple_passes_test.dir/tests/cpp/simple_passes_test.cc.o  -o simple_passes_test -rdynamic libtvm.so ../lib/libgtest.a -lpthread -Wl,-rpath,/root/tvm-test/build 
libtvm.so: undefined reference to `dlopen'
libtvm.so: undefined reference to `dlclose'
libtvm.so: undefined reference to `dlerror'
libtvm.so: undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
CMakeFiles/simple_passes_test.dir/build.make:96: recipe for target 'simple_passes_test' failed
make[3]: *** [simple_passes_test] Error 1
make[3]: Leaving directory '/root/tvm-test/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/simple_passes_test.dir/all' failed
make[2]: *** [CMakeFiles/simple_passes_test.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
[ 91%] Linking CXX executable build_module_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/build_module_test.dir/link.txt --verbose=1
/usr/bin/c++   -O2 -Wall -fPIC -fvisibility=hidden -std=c++11    CMakeFiles/build_module_test.dir/tests/cpp/build_module_test.cc.o  -o build_module_test -rdynamic libtvm.so ../lib/libgtest.a -lpthread -Wl,-rpath,/root/tvm-test/build 
libtvm.so: undefined reference to `dlopen'
libtvm.so: undefined reference to `dlclose'
libtvm.so: undefined reference to `dlerror'
libtvm.so: undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
CMakeFiles/build_module_test.dir/build.make:96: recipe for target 'build_module_test' failed
make[3]: *** [build_module_test] Error 1
make[3]: Leaving directory '/root/tvm-test/build'
CMakeFiles/Makefile2:746: recipe for target 'CMakeFiles/build_module_test.dir/all' failed
make[2]: *** [CMakeFiles/build_module_test.dir/all] Error 2
make[2]: Leaving directory '/root/tvm-test/build'
CMakeFiles/Makefile2:391: recipe for target 'CMakeFiles/cpptest.dir/rule' failed
make[1]: *** [CMakeFiles/cpptest.dir/rule] Error 2
make[1]: Leaving directory '/root/tvm-test/build'
Makefile:279: recipe for target 'cpptest' failed
make: *** [cpptest] Error 2

#5

can you look a bit into how to fix this? From the error message, it seems to be as simple as missing linking flag dlopen(which should be in -ldl)


#6

see also https://github.com/dmlc/tvm/blob/master/docker/install/ubuntu_install_core.sh on how did we install gtest in docker


#8

I found the place in CMakeLists.txt where I need to add dl
I also did some clarification in testing docs
PR: https://github.com/dmlc/tvm/pull/2798


#9

Hi apivovarov,
My code has already had what you promoted in PR #2798, but i still meet follwing link error in ubuntu.
shangqiu@ubuntu:~/tvm/tvm/build$ make cpptest
[ 88%] Built target tvm
[ 88%] Linking CXX executable ir_simplify_test
CMakeFiles/ir_simplify_test.dir/tests/cpp/ir_simplify_test.cc.o: In function _GLOBAL__sub_I_ir_simplify_test.cc': ir_simplify_test.cc:(.text.startup+0xae): undefined reference totesting::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void ()(), void ()(), testing::internal::TestFactoryBase*)’
ir_simplify_test.cc:(.text.startup+0xf7): undefined reference to testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' ir_simplify_test.cc:(.text.startup+0x140): undefined reference totesting::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void ()(), void ()(), testing::internal::TestFactoryBase*)’
ir_simplify_test.cc:(.text.startup+0x18a): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void ()(), void ()(), testing::internal::TestFactoryBase*)’
collect2: error: ld returned 1 exit status
CMakeFiles/ir_simplify_test.dir/build.make:101: recipe for target ‘ir_simplify_test’ failed
make[3]: *** [ir_simplify_test] Error 1
CMakeFiles/Makefile2:843: recipe for target ‘CMakeFiles/ir_simplify_test.dir/all’ failed
make[2]: *** [CMakeFiles/ir_simplify_test.dir/all] Error 2
CMakeFiles/Makefile2:121: recipe for target ‘CMakeFiles/cpptest.dir/rule’ failed
make[1]: *** [CMakeFiles/cpptest.dir/rule] Error 2
Makefile:177: recipe for target ‘cpptest’ failed
make: *** [cpptest] Error 2

Can you help give a help?
Thanks


#10

This is a problem of gtest, likely you will need to install a correct version of gtest to resolve this problem


#11

Solved after updating gtest. Thank you very much!