相关疑难解决方法(0)

带有模板的C++共享库:未定义的符号错误

我正在尝试使用模板类链接到共享库,但它给了我"未定义的符号"错误.我已经将问题浓缩为大约20行代码.

shared.h

template <class Type> class myclass {
  Type x;
public:
  myclass() { x=0; }
  void setx(Type y);
  Type  getx();
};
Run Code Online (Sandbox Code Playgroud)

shared.cpp

#include "shared.h"
template <class Type> void myclass<Type>::setx(Type y) { x = y; }
template <class Type> Type myclass<Type>::getx() { return x; }
Run Code Online (Sandbox Code Playgroud)

main.cpp中

#include <iostream>
#include "shared.h"
using namespace std;

int main(int argc, char *argv[]) {
   myclass<int> m;
   cout << m.getx() << endl;
   m.setx(10);
   cout << m.getx() << endl;
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是我编译库的方式:

g++ -fPIC -c shared.cpp -o …
Run Code Online (Sandbox Code Playgroud)

c++ linker gcc templates class

42
推荐指数
3
解决办法
2万
查看次数

是否有java的dlib库端口?

我实际上是在使用OpenCV进行人脸检测,但在观看了这个视频之后:https://www.youtube.com/watch?v = LsK0hzcEyHI,我注意到dlib更准确,即使在我的测试中,也给出了很多故事肯定(但不会错过任何面孔),有没有人知道如何在Java Web应用程序(而不是Android)中使用dlib?我已经找到了Android的端口,但我不认为可以在java Web应用程序中使用它.谢谢

java dlib

5
推荐指数
1
解决办法
5479
查看次数

标签 统计

c++ ×1

class ×1

dlib ×1

gcc ×1

java ×1

linker ×1

templates ×1