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

build the example with ncnn #667

Closed
zineos opened this issue Nov 23, 2018 · 1 comment
Closed

build the example with ncnn #667

zineos opened this issue Nov 23, 2018 · 1 comment

Comments

@zineos
Copy link
Contributor

zineos commented Nov 23, 2018

I want to build the ncnn shared library and use it.

the modified part in src/CMakeLists.txt is show below

#add_library(ncnn STATIC ${ncnn_SRCS})
add_library(ncnn SHARED ${ncnn_SRCS})
if(NCNN_OPENMP AND OpenMP_CXX_FOUND)
if(NCNN_CMAKE_VERBOSE)
message("Building with OpenMP")
endif()
target_link_libraries(ncnn PUBLIC OpenMP::OpenMP_CXX)
endif()

if(COVERAGE)
target_compile_options(ncnn PRIVATE --coverage)
endif()

#install(TARGETS ncnn ARCHIVE DESTINATION lib)
install(TARGETS ncnn LIBRARY DESTINATION lib)
install(FILES
allocator.h
blob.h
cpu.h
layer.h
layer_type.h
mat.h
modelbin.h
net.h
opencv.h
paramdict.h
benchmark.h
${CMAKE_CURRENT_BINARY_DIR}/layer_type_enum.h
${CMAKE_CURRENT_BINARY_DIR}/platform.h
DESTINATION include
)


and the error happen

[ 81%] Linking CXX shared library libncnn.so
[ 81%] Built target ncnn
Scanning dependencies of target fasterrcnn
[ 82%] Building CXX object examples/CMakeFiles/fasterrcnn.dir/fasterrcnn.cpp.o
/data/backup/ncnn-master/examples/fasterrcnn.cpp:46:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
#pragma omp parallel sections
^
/data/backup/ncnn-master/examples/fasterrcnn.cpp:48:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
#pragma omp section
^
/data/backup/ncnn-master/examples/fasterrcnn.cpp:52:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
#pragma omp section
^
[ 83%] Linking CXX executable fasterrcnn
CMakeFiles/fasterrcnn.dir/fasterrcnn.cpp.o: In function main': fasterrcnn.cpp:(.text.startup+0x314): undefined reference to ncnn::Net::Net()'
fasterrcnn.cpp:(.text.startup+0x32a): undefined reference to ncnn::Net::load_param(char const*)' fasterrcnn.cpp:(.text.startup+0x339): undefined reference to ncnn::Net::load_model(char const*)'
fasterrcnn.cpp:(.text.startup+0x3b0): undefined reference to ncnn::Mat::from_pixels_resize(unsigned char const*, int, int, int, int, int, ncnn::Allocator*)' fasterrcnn.cpp:(.text.startup+0x3e1): undefined reference to ncnn::Mat::substract_mean_normalize(float const*, float const*)'
fasterrcnn.cpp:(.text.startup+0x4ac): undefined reference to ncnn::Net::create_extractor() const' fasterrcnn.cpp:(.text.startup+0x4d0): undefined reference to ncnn::Extractor::input(char const*, ncnn::Mat const&)' fasterrcnn.cpp:(.text.startup+0x4f0): undefined reference to ncnn::Extractor::input(char const*, ncnn::Mat const&)' fasterrcnn.cpp:(.text.startup+0x584): undefined reference to ncnn::Extractor::extract(char const*, ncnn::Mat&)'
fasterrcnn.cpp:(.text.startup+0x5a4): undefined reference to ncnn::Extractor::extract(char const*, ncnn::Mat&)' fasterrcnn.cpp:(.text.startup+0x63f): undefined reference to ncnn::Net::create_extractor() const'
fasterrcnn.cpp:(.text.startup+0x6dc): undefined reference to ncnn::Extractor::input(char const*, ncnn::Mat const&)' fasterrcnn.cpp:(.text.startup+0x6ee): undefined reference to ncnn::Extractor::input(char const*, ncnn::Mat const&)' fasterrcnn.cpp:(.text.startup+0x771): undefined reference to ncnn::Extractor::extract(char const*, ncnn::Mat&)' fasterrcnn.cpp:(.text.startup+0x783): undefined reference to ncnn::Extractor::extract(char const*, ncnn::Mat&)'
fasterrcnn.cpp:(.text.startup+0x108f): undefined reference to ncnn::Net::~Net()' fasterrcnn.cpp:(.text.startup+0x1aba): undefined reference to ncnn::Net::~Net()'
collect2: error: ld returned 1 exit status
examples/CMakeFiles/fasterrcnn.dir/build.make:98: recipe for target 'examples/fasterrcnn' failed
make[2]: *** [examples/fasterrcnn] Error 1
CMakeFiles/Makefile2:99: recipe for target 'examples/CMakeFiles/fasterrcnn.dir/all' failed
make[1]: *** [examples/CMakeFiles/fasterrcnn.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2


how can I solve this problem

@nihui
Copy link
Member

nihui commented Nov 28, 2018

build ncnn as static library
ncnn ABI is not stable enough, that's why we provide static library only.

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

2 participants