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

[bug]CMake无法编译.虚类不能实体化 #47

Open
edwardsun opened this issue Nov 21, 2023 · 0 comments
Open

[bug]CMake无法编译.虚类不能实体化 #47

edwardsun opened this issue Nov 21, 2023 · 0 comments

Comments

@edwardsun
Copy link

您好,
我克隆了openctp sina 和openctp华鑫sfp目录。系统为linux64
对于每个目录,我操作如下:

  1. mkdir build && cd build
  2. cmake .. && cmake --build .

编译会出现如下错误:
/cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.cpp: In static member function ‘static CThostFtdcMdApi* CThostFtdcMdApi::CreateFtdcMdApi(const char*, bool, bool)’:
/cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.cpp:14:35: error: invalid new-expression of abstract class type ‘CFtdcMdApiImpl’
14 | return new CFtdcMdApiImpl();
| ^
In file included from /cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.cpp:1:
/cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.h:14:7: note: because the following virtual functions are pure within ‘CFtdcMdApiImpl’:
14 | class CFtdcMdApiImpl : public CThostFtdcMdApi, public CTORATstpXMdSpi
| ^~~~~~~~~~~~~~
In file included from /cpp-subscriber/ctp2huaxinSTP/FtdcMdApiImpl.h:9:
/cpp-subscriber/ctp2huaxinSTP/6.5.1_20200908/ThostFtdcMdApi.h:163:21: note: ‘virtual int CThostFtdcMdApi::ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField*, int)’
163 | *virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField pQryMulticastInstrument, int nRequestID) = 0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~

这个编译错误貌似是合理的。不知道项目组有没有计划修复。
另外,如果我把上述return new CFtdcMdApiImpl(); 改为 return NULL; 则编译通过,但链接不通过,错误如下:
[root@7687c3c3c16c build]# cmake --build .
[ 8%] Building CXX object 6.3.15_20190220/CMakeFiles/thostmduserapi_se_6.3.15_20190220.dir//FtdcMdApiImpl.cpp.o
[ 16%] Linking CXX shared library /cpp-subscriber/ctp2huaxinSTP/6.3.15_20190220/libthostmduserapi_se.so
[ 16%] Built target thostmduserapi_se_6.3.15_20190220
[ 25%] Building CXX object 6.5.1_20200908/CMakeFiles/thostmduserapi_se_6.5.1_20200908.dir/
/FtdcMdApiImpl.cpp.o
[ 33%] Linking CXX shared library /cpp-subscriber/ctp2huaxinSTP/6.5.1_20200908/libthostmduserapi_se.so
[ 33%] Built target thostmduserapi_se_6.5.1_20200908
[ 41%] Building CXX object 6.3.19_P1_20200106/CMakeFiles/thostmduserapi_se_6.3.19_P1_20200106.dir/__/FtdcMdApiImpl.cpp.o
[ 50%] Linking CXX shared library /cpp-subscriber/ctp2huaxinSTP/6.3.19_P1_20200106/libthostmduserapi_se.so
/usr/bin/ld: cannot find -lxfastmdapi: No such file or directory
collect2: error: ld returned 1 exit status
gmake[2]: *** [6.3.19_P1_20200106/CMakeFiles/thostmduserapi_se_6.3.19_P1_20200106.dir/build.make:97: /cpp-subscriber/ctp2huaxinSTP/6.3.19_P1_20200106/libthostmduserapi_se.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:240: 6.3.19_P1_20200106/CMakeFiles/thostmduserapi_se_6.3.19_P1_20200106.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

我看到动态库在那里,但cmake没看到。不知道能否改进一下?
谢谢

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

1 participant