如何链接到VS2008从g ++生成的.libs [英] How to link to VS2008 generated .libs from g++
问题描述
我有.h文件,它指向由MS使用MS生成的.dll导出的对象。 Visual Studio 2008.我链接到用.dll生成的.lib。
当我运行g ++时,我得到了很多像这样的错误
/cygdrive/c/dev/blox/ulfx/ulfx/JavaInterface.cpp:206:对__imp___ZNK18DLLSafeDoubleArray4sizeEv'
$ c $的未定义引用c>
我想链接到的.dll公开一个名为
的函数pre >
?size @ DLLSafeDoubleArray @@ QBEIXZ
我假设这里的问题是g ++名称mangling与VS2008 name mangling不兼容。
有没有办法让g ++可以使用兼容的mangling?
我没有安装任何版本的Visual Studio。
由不同的 C ++
编译器是不兼容的。 这是有意完成的 :编译器使用不同的ABI,如果名称混淆并不妨碍你连接,你现在想知道/调试为什么最简单的操作会导致你的可执行文件崩溃。
你应该感激不同的名称修改方案免除了您的调试工作。
I am trying to build a dll using mingw g++ under cygwin.
I have .h files that refer to objects exported by a .dll that was build using MS Visual Studio 2008. I link to the .lib generated with that .dll.
When I run g++ I get lots of errors like this
/cygdrive/c/dev/blox/ulfx/ulfx/JavaInterface.cpp:206: undefined reference to `__imp___ZNK18DLLSafeDoubleArray4sizeEv'
The .dll that I want to link to exposes a function named
?size@DLLSafeDoubleArray@@QBEIXZ
And I assume that the problem here is that the g++ name mangling is incompatible with the VS2008 name mangling.
Is there a way I can force g++ to use a compatible mangling ?
I do not have any version of Visual Studio installed on my machine.
Object code produced by different C++
compilers is not link compatible.
This is done on purpose: compilers use different ABI, and if the name maingling didn't prevent you from linking, you'd now be wondering/debugging why the simplest operations are causing your executable to crash.
You should be grateful that the different name mangling scheme spared you that debugging effort.
这篇关于如何链接到VS2008从g ++生成的.libs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!