Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile "TensorRT-introduction" #34

Open
zccyman opened this issue Jul 23, 2020 · 3 comments
Open

compile "TensorRT-introduction" #34

zccyman opened this issue Jul 23, 2020 · 3 comments

Comments

@zccyman
Copy link

zccyman commented Jul 23, 2020

I compile "TensorRT-introduction", but have some error as follow:

CMakeFiles/main.dir/ioHelper.cpp.o: In function `nvinfer1::readTensorProto(std::string const&, float*)':
ioHelper.cpp:(.text+0x131): undefined reference to `onnx::TensorProto::TensorProto()'
ioHelper.cpp:(.text+0x232): undefined reference to `onnx::TensorProto::~TensorProto()'
ioHelper.cpp:(.text+0x255): undefined reference to `onnx::TensorProto::~TensorProto()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/main.dir/build.make:201: main] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/main.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

project(simpleOnnx)

add_executable(main simpleOnnx_2.cpp cudaWrapper.h ioHelper.cpp ioHelper.h logger.cpp)

include_directories(/usr/local/include)

include_directories(/home/developer/zhangcc/download/TensorRT-7.0.0.11/include)
include_directories(/home/developer/zhangcc/download/TensorRT-7.0.0.11/samples/common)
set(TENSORRT_DIR /home/developer/zhangcc/download/TensorRT-7.0.0.11/lib)

find_package(CUDA 10.2 REQUIRED)
message(STATUS "CUDA status:")
message(STATUS "    include path: ${CUDA_INCLUDE_DIRS}")
message(STATUS "    libraries: ${CUDA_LIBRARIES}")
include_directories(${CUDA_INCLUDE_DIRS})
target_link_libraries(main ${CUDA_LIBRARIES})

find_package(Protobuf REQUIRED)
message(STATUS "Protobuf library status:")
message(STATUS "    version: ${Protobuf_VERSION}")
message(STATUS "    libraries: ${Protobuf_LIBS}")
message(STATUS "    include path: ${Protobuf_INCLUDE_DIRS}")

target_link_libraries(main /usr/local/lib/libprotobuf-lite.so)
target_link_libraries(main /usr/local/lib/libonnxifi.so)
target_link_libraries(main /usr/local/lib/libprotoc.so)

target_link_libraries(main ${TENSORRT_DIR}/libnvinfer.so ${TENSORRT_DIR}/libnvinfer_plugin.so ${TENSORRT_DIR}/libnvonnxparser.so ${TENSORRT_DIR}/libnvparsers.so)
@zccyman
Copy link
Author

zccyman commented Jul 23, 2020

@zccyman add target_link_libraries like as follow.

target_link_libraries(main /usr/local/lib/libprotobuf-lite.so)
target_link_libraries(main /usr/local/lib/libprotoc.so)
target_link_libraries(main /usr/local/lib/libonnx.a)
target_link_libraries(main /usr/local/lib/libonnx_proto.a)
target_link_libraries(main /usr/local/lib/libonnxifi_dummy.so)
target_link_libraries(main /usr/local/lib/libonnxifi_loader.a)
target_link_libraries(main /usr/local/lib/libonnxifi.so)

@dxbdxx
Copy link

dxbdxx commented Sep 8, 2020

I successfully compile the project by adding

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -DONNX_ML=1 -Wall")

and
target_link_libraries(main /usr/local/lib/libprotobuf.so)

@Tramac
Copy link

Tramac commented Jun 23, 2021

@zccyman hello, do you remember how to solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants