在C ++ / CLR项目中使用C ++ DLL库项目

时间:2022-09-01 19:12:25

I'm trying to use a unmanaged C++ DLL library project in a C++ /CLR managed wrapper project, but because the unmanaged project uses <thread> the managed project won't build: error C1189: #error : <thread> is not supported when compiling with /clr or /clr:pure.

我正在尝试在C ++ / CLR托管包装项目中使用非托管C ++ DLL库项目,但由于非托管项目使用 ,托管项目将无法生成:错误C1189:#error: 不受支持用/ clr或/ clr编译时:纯。

to be clear: the managed project itself does NOT use <thread>, only the referenced unmanaged

要明确:托管项目本身不使用 ,只使用引用的非托管

Is there anyway I can use threads in the unmanaged project and still have it interact properly with the managed wrapper project? (changing the project nature to use managed threads is not an option)

反正我是否可以在非托管项目中使用线程,并且仍然可以与托管包装器项目正确交互? (更改项目性质以使用托管线程不是一种选择)


Edit: I received -2. I'm not sure why, I couldn't find anything for this specific case and I have no idea what is wrong exactly but it seems like the managed project is also compiling the unmanaged project?

编辑:我收到-2。我不知道为什么,我找不到任何针对这个特定案例的内容,我不知道究竟有什么问题,但似乎托管项目也在编译非托管项目?

1 个解决方案

#1


Does the include file for the unmanaged project include <thread>, directly or indirectly? That's probably the cause of the error.

非托管项目的包含文件是直接还是间接包含 ?这可能是错误的原因。

Try to make the interface header of the unmanaged project just define the interface, and not include any implementation-dependent include files.

尝试使非托管项目的接口头只定义接口,而不包括任何依赖于实现的包含文件。

#1


Does the include file for the unmanaged project include <thread>, directly or indirectly? That's probably the cause of the error.

非托管项目的包含文件是直接还是间接包含 ?这可能是错误的原因。

Try to make the interface header of the unmanaged project just define the interface, and not include any implementation-dependent include files.

尝试使非托管项目的接口头只定义接口,而不包括任何依赖于实现的包含文件。