我有一个恼人的CMake问题。 我有一个包含多个目录的项目,例如(理论上):
编译器 - >生成compiler.exe和compiler.dll 这是纯C ++ 然而,由于使用了一些奇特的东西,compiler.dll需要链接到machine.dll(见下文)... 而compiler.dll是一个SHARED库 机器 - >生成machine.exe和machine.dll - 这是一半C和一半C ++。 C ++部分需要链接到compiler.dll所以这里出现了循环依赖,在Linux上非常优雅地解决了,但是在MSVS2012上,链接器抱怨LNK2019 ......未解析的外部符号。 这是可以理解的,因为当我看到编译时,顺序如下:
它编译机器的C文件 它试图编译机器的C ++文件...这里它在链接失败,因为编译器的C ++文件还没有编译......我该如何解决这个问题?
I have an annoying CMake issue. I have a project with more than one directories, such as (theoretically):
compiler -> generates compiler.exe and compiler.dll This is pure C++ However the compiler.dll needs to link to machine.dll (see below) due to use of some fancy things ... and the compiler.dll is a SHARED library machine -> generates machine.exe and machine.dll - this is half C and half C++. The C++ part needs to link to compiler.dllSo here a circular dependency arose, which is very elegantly solved on Linux, however on MSVS2012, the linker complains with LNK2019 ... unresolved external symbol. Which is understandable, since when I see the compilation, the order is the following:
it compiles the machine's C files it tries to compile the machine's C++ files ... and here it fails at the linking, since the compilers' C++ files were not compiled yet...How can I resolve this issue?
最满意答案
通过将共享库转换为静态库并将必要部分提取到共享库中来解决问题,而不保持循环性。
Problem was solved by converting the shared libraries into static ones and extracting the necessary parts into a shared library, without keeping the circularity.
更多推荐
发布评论