Error when run apps/howto_deploy


command: ./

Build the libraries…
Traceback (most recent call last):
File “”, line 22, in
prepare_test_libs(os.path.join(curr_path, “./lib”))
File “”, line 13, in prepare_test_libs
File “/tvm/python/tvm/”, line 121, in export_library
fcompile(file_name, files, **kwargs)
File “/tvm/python/tvm/contrib/”, line 33, in create_shared
_linux_shared(output, objects, options, cc)
File “/tvm/python/tvm/contrib/”, line 58, in _linux_shared
raise RuntimeError(msg)
RuntimeError: Compilation error:
/usr/bin/ld: /tmp/tmp2sr91udo/lib.o: relocation R_X86_64_32S against `.rodata.cst4’ can not be used when making a shared object; recompile with -fPIC
/tmp/tmp2sr91udo/lib.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

Makefile:24: recipe for target ‘lib/test_addone_sys.o’ failed
make: *** [lib/test_addone_sys.o] Error 1
Run the example
Run the deployment with all in one packed library… 10: lib/cpp_deploy_pack: not found
Run the deployment with all in normal library… 13: lib/cpp_deploy_normal: not found

how to solve this problem? thanks


This is weird, the normal behavior of the code should be something like:

Build the libraries..
g++ -c -std=c++11 -O2 -fPIC -I/tvm/include -I/tvm/dmlc-core/include -I/tvm/dlpack/include  -o lib/libtvm_runtime_pack.o
g++ -std=c++11 -O2 -fPIC -I/tvm/include -I/tvm/dmlc-core/include -I/tvm/dlpack/include  -o lib/cpp_deploy_pack lib/test_addone_sys.o lib/libtvm_runtime_pack.o -L/tvm/build -ldl -lpthread
g++ -std=c++11 -O2 -fPIC -I/tvm/include -I/tvm/dmlc-core/include -I/tvm/dlpack/include  -o lib/cpp_deploy_normal lib/test_addone_sys.o -L/tvm/build -ldl -lpthread -ltvm_runtime
Run the example
Run the deployment with all in one packed library...
[18:26:00] Verify dynamic loading from
[18:26:00] Finish verification...
[18:26:00] Verify load function from system lib
[18:26:00] Finish verification...
Run the deployment with all in normal library...


I think the problem is caused by TVM compilation with llvm, I build TVM from source, but I don’t know why. I rebuild TVM with llvm-5.0, it’s solved now. Thanks for your reply.


For LLVM, any version above 4.0 should be fine.


Hey I realize this is an old post but there are some mistakes in the Makefile.

TVM_ROOT=$(shell cd …/…; pwd)

PKG_CFLAGS = -std=c++11 -O2 -fPIC

Just remove “3rdparty” and make any other changes needed for these to match so that it matches your actual paths.