MFC winsock1 和 2
我的项目深陷麻烦。
我必须将两个雷达与我的程序链接,但第一个雷达有自己的使用winsock的库,而第二个雷达我想使用winsock2。
我怎样才能做到这一点?
目前,我从 winsock.h
和 winsock2.h
中的包含中收到许多重新定义错误。
考虑到第一个雷达库已经是一个 DLL,我只有一个头文件和 lib 文件(没有源代码)。
预先感谢您的任何答复。
I'm deep in trouble with my project.
I have to link two radar with my program, but the first has its own library that uses winsock, while in the second I want to use winsock2.
How can i do that?
At the moment i get many redefinition errors from the includes within winsock.h
and winsock2.h
.
Take into account that the first radar library is already an DLL, i've got only a header and lib file (no source).
Thank you in advance for any answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过构造代码(和预编译头)来解决编译问题,以便没有文件同时包含winsock.h和winsock2.h,这可能意味着根本不使用预编译头或以比更复杂的方式使用它们在 MFC 项目中是正常的...
您可以将每个 DLL 包装在 COM 对象中,并从主程序通过 COM 访问它们。这样做的优点是可以将两个 DLL 的使用与主编译完全分开。
您可以将每个 DLL 包装在一个新的 DLL 中(每个 DLL 一个),该 DLL 为您的程序提供一个接口,该程序不需要接口标头中的 winsock 标头。
当然,这可能只是您的 Windows.h 包含顺序的问题,请尝试将其放在预编译头的顶部...
You could possibly work around the compilation problem by structuring your code (and precompiled headers) so that no file includes both winsock.h and winsock2.h, this may mean either not using precompiled headers at all or using them in a more complex way than is normal in MFC projects...
You could wrap each DLL in a COM object and access them via COM from your main program. This has the advantage of completely separating the use of the two DLLs from your main compilation.
You could wrap each of the DLLs in a new DLL (one each) which provides an interface to your program that does not need the winsock headers in the interface headers.
Of course this may simply be an issue with your Windows.h include order, try putting this at the top of your precompiled header...