error: ‘PaddleMobile’ is not a member of ‘paddle_mobile’
Created by: zhangscth
修改CMakeList 生成静态库,但是在运行mobile ssd的时候报错 CMakeList 修改后:
add_library(paddle-mobile STATIC ${PADDLE_MOBILE_CC} ${PADDLE_MOBILE_H})
代码:ncnn_face.cpp
#include <cmath>
#include <string>
#include <iostream>
#include <vector>
#include "paddle_inference_api.h"
int test() {
paddle_mobile::PaddleMobile<paddle_mobile::CPU> paddle_mobile;
//paddle_mobile.SetThreadNum(4);
auto time1 = time();
auto isok = paddle_mobile.Load(
std::string(g_mobilenet_ssd_gesture) + "/model",
std::string(g_mobilenet_ssd_gesture) + "/params", true);
// auto isok = paddle_mobile.Load(g_mobilenet_ssd, false);
if (isok) {
auto time2 = time();
std::cout << "load cost :" << time_diff(time1, time2) << "ms" << std::endl;
std::vector<float> input;
std::vector<int64_t> dims{1, 3, 300, 300};
GetInput<float>(g_hand, &input, dims);
// 预热十次
for (int i = 0; i < 10; ++i) {
auto output = paddle_mobile.Predict(input, dims);
}
auto time3 = time();
for (int i = 0; i < 10; ++i) {
auto output = paddle_mobile.Predict(input, dims);
}
auto time4 = time();
std::cout << "predict cost :" << time_diff(time3, time4) / 10 << "ms"
<< std::endl;
}
return 0;
}
make 报错:
/home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp: In function ‘int test()’: /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:19:3: error: ‘PaddleMobile’ is not a member of ‘paddle_mobile’ paddle_mobile::PaddleMobile<paddle_mobile::CPU> paddle_mobile; ^~~~~~~~~~~~~ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:19:31: error: ‘CPU’ is not a member of ‘paddle_mobile’ paddle_mobile::PaddleMobile<paddle_mobile::CPU> paddle_mobile; ^~~~~~~~~~~~~ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:19:64: error: expected primary-expression before ‘;’ token paddle_mobile::PaddleMobile<paddle_mobile::CPU> paddle_mobile; ^ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:21:21: error: too few arguments to function ‘time_t time(time_t*)’ auto time1 = time(); ^ In file included from /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/include/pthread.h:26:0, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/arm-linux-uclibceabi/bits/gthr-default.h:35, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/arm-linux-uclibceabi/bits/gthr.h:148, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/ext/atomicity.h:35, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/bits/basic_string.h:39, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/string:52, from /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:2: /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/include/time.h:189:15: note: declared here extern time_t time (time_t __timer) __THROW; ^~~~ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:22:28: error: expected primary-expression before ‘.’ token auto isok = paddle_mobile.Load( ^ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:23:19: error: ‘g_mobilenet_ssd_gesture’ was not declared in this scope std::string(g_mobilenet_ssd_gesture) + "/model", ^~~~~~~~~~~~~~~~~~~~~~~ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:27:23: error: too few arguments to function ‘time_t time(time_t)’ auto time2 = time(); ^ In file included from /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/include/pthread.h:26:0, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/arm-linux-uclibceabi/bits/gthr-default.h:35, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/arm-linux-uclibceabi/bits/gthr.h:148, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/ext/atomicity.h:35, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/bits/basic_string.h:39, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/string:52, from /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:2: /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/include/time.h:189:15: note: declared here extern time_t time (time_t __timer) __THROW; ^~~~ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:28:57: error: ‘time_diff’ was not declared in this scope std::cout << "load cost :" << time_diff(time1, time2) << "ms" << std::endl; ^ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:32:5: error: ‘GetInput’ was not declared in this scope GetInput(g_hand, &input, dims); ^~~~~~~~ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:32:14: error: expected primary-expression before ‘float’ GetInput(g_hand, &input, dims); ^~~~~ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:36:34: error: expected primary-expression before ‘.’ token auto output = paddle_mobile.Predict(input, dims); ^ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:38:23: error: too few arguments to function ‘time_t time(time_t)’ auto time3 = time(); ^ In file included from /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/include/pthread.h:26:0, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/arm-linux-uclibceabi/bits/gthr-default.h:35, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/arm-linux-uclibceabi/bits/gthr.h:148, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/ext/atomicity.h:35, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/bits/basic_string.h:39, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/string:52, from /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:2: /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/include/time.h:189:15: note: declared here extern time_t time (time_t __timer) __THROW; ^~~~ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:40:34: error: expected primary-expression before ‘.’ token auto output = paddle_mobile.Predict(input, dims); ^ /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:42:23: error: too few arguments to function ‘time_t time(time_t)’ auto time4 = time(); ^ In file included from /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/include/pthread.h:26:0, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/arm-linux-uclibceabi/bits/gthr-default.h:35, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/arm-linux-uclibceabi/bits/gthr.h:148, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/ext/atomicity.h:35, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/bits/basic_string.h:39, from /opt/hisi-linux/x86-arm/arm-himix100-linux/arm-linux-uclibceabi/include/c++/6.3.0/string:52, from /home/zhangshengchao/workspace/paddle_mobile/paddle_mobile_demo/ncnn_face.cpp:2: /opt/hisi-linux/x86-arm/arm-himix100-linux/target/usr/include/time.h:189:15: note: declared here extern time_t time (time_t *__timer) __THROW; ^~~~ CMakeFiles/ncnn_face.dir/build.make:62: recipe for target 'CMakeFiles/ncnn_face.dir/ncnn_face.cpp.o' failed make[2]: *** [CMakeFiles/ncnn_face.dir/ncnn_face.cpp.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ncnn_face.dir/all' failed make[1]: *** [CMakeFiles/ncnn_face.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2