DLL运行时和/ CLR编译 [英] DLL runtime and /CLR compiling

查看:185
本文介绍了DLL运行时和/ CLR编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在试验VisualC ++ 2005 Express Edition Beta

并发现了一些奇怪的行为,我似乎无法找到解决方法。

我所做的是为Lua 5.0.2和

LuaBind beta-6设置两个静态库项目,编译两者都没有CLR支持并配置为使用

多线程DLL运行时。然后我创建了一个新的控制台应用程序,

使用这两个静态库(当然,也设置为MT DLL)。所以

非常好,一切正常。


当我打开CLR支持这个控制台应用程序时,链接器

抱怨运行时库中的符号被多次定义

次 - 例如。在msvcprtd.lib(DLL运行时)和* libcpmtd.lib *(静态

运行时)。

它来自哪里?

我认为CLR模式事件需要MT DLL编译?


我得到的一些错误:

MSVCRTD.lib(MSVCR80D.dll):错误LNK2005:public:virtual __thiscall

std :: exception ::〜exception(void)" (?? 1exception @std @@ UAE @XZ)已定义

in vc8test.obj

MSVCRTD.lib(MSVCR80D.dll):错误LNK2005:public: __thiscall

std :: exception :: exception(void)" (?? 0exception @ std @@ QAE @XZ)已定义

in vc8test.obj

MSVCRTD.lib(MSVCR80D.dll):错误LNK2005:public: __thiscall

std :: exception :: exception(class std :: exception const&)"

(?? 0exception @ std @@ QAE @ ABV01 @@ Z )已在vc8test.obj中定义

msvcprtd.lib(MSVCP80D.dll):错误LNK2005:" public:__ thishisall

std :: _ Container_base :: ~_Container_base(void )

(?? 1_Container_base @std @@ QAE @XZ)已在vc8test.obj中定义

msvcprtd.lib(MSVCP80D.dll):错误LNK2005:" ; public:__ thishisall

std :: _ Lockit :: ~_Lockit(void)" (?? 1_Lockit @std @@ QAE @XZ)已经定义在

libcpmtd.lib(xlock.obj)

msvcprtd.lib(MSVCP80D.dll):错误LNK2005 :public:__ thiscall

std :: _ Lockit :: _ Lockit(int)" (?? 0_Lockit @ std @@ QAE @ H @ Z)已经定义在

libcpmtd.lib(xlock.obj)


如果有人可以推荐一个解决方法或知道可能导致的原因

libcpmt(d).lib要链接我会非常高兴;-)


-Markus-

解决方案

我自己在留言中写道:uZ ************** @ tk2msftngp13.phx.gbl。 ..

我只是在试验VisualC ++ 2005 Express Edition Beta,并发现了一些奇怪的行为,我似乎无法找到一个
我所做的是为Lua 5.0.2和LuaBind beta-6设置两个静态库项目,编译两者都没有CLR支持并配置为使用
多线程DLL运行时。然后我创建了一个新的控制台应用程序
,它使用了这两个静态库(当然,也设置为MT
DLL)。到目前为止一切都很好,一切正常。

当我为这个控制台应用程序启用CLR支持时,链接器抱怨运行时库中的符号被定义多次
次 - 例如。在msvcprtd.lib(DLL运行时)和* libcpmtd.lib *(静态
运行时)。




我已经尝试过其他一些库和观察到,只要我将使用C ++

运行时的非托管静态库链接到托管项目,就会出现那些错误

。纯C项目不会发生这种情况。


因此,在我的初始项目中,使用/ CLR

选项编译LuaBind解决了问题。奇怪。


-Markus-


看起来这个假设有点为时过早。要崩溃我的应用程序,我不需要

多于此:


1)创建一个基于Windows窗体的新应用程序

2 )将CLR选项从纯CLR更改为正常CLR链接

3)#include< string>并写一些像std :: string test =" hello

world" ;;在Main()

- > dbgheap.c#1301断言pUserData!= 0

- >忽略导致访问冲突


断言时的调用堆栈是

msvcr80d.dll!_ mss_dbg(void * pUserData = 0x00000000,int nBlockUse = 2)

行1301 + 0x26字节C ++

msvcr80d.dll!_dllonexit_nolock(int(void)* func = 0x004535e0,void(void)* *

* pbegin = 0x0046a4f4,void(void)* * * pend = 0x0046a4f0)282行+ 0xd字节

C

msvcr80d.dll!__ dllonexit(int(void)* func = 0x004535e0,void(void)* * *

pbegin = 0x0046a4f4,void(void)* * * pend = 0x0046a4f0)259行+ 0x11字节

C

VC8Test.exe!_onexit(int(void)* func = 0x004535e0)第83行+ 0x2e字节C

VC8Test.exe!atexit(void(void)* func = 0x004535e0)第98行+ 0x9字节C

VC8Test.exe!std :: initlocks ::`dynamic initializer''()第49行+ 0x17字节

C ++

VC8Test.exe!_initterm(void ** pfbegin = 0x00469008,void pfend =)第140行

C ++

VC8Test.exe!?。cctor @@


FYMXXZ()第297行C ++


-Markus-


I''m just experimenting around with the VisualC++ 2005 Express Edition Beta
and found some strange behavior for which I can''t seem to find a workaround.

What I''ve done is set up two static library projects for Lua 5.0.2 and
LuaBind beta-6, compiling both with no CLR support and configured to use the
Multithreaded DLL runtime. Then I created a new console application which
makes use of these two static libraries (of course, also set to MT DLL). So
far so good, everything works.

When I then turned on CLR support for this console application, the linker
complained about symbols from the runtime libraries being defined mutiple
times - eg. in msvcprtd.lib (DLL runtime) and *libcpmtd.lib* (static
runtime).
Where does that come from ?
I thought the CLR mode event requires MT DLL compilation ?

Some of the errors I''m getting:
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: virtual __thiscall
std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined
in vc8test.obj
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: __thiscall
std::exception::exception(void)" (??0exception@std@@QAE@XZ) already defined
in vc8test.obj
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: "public: __thiscall
std::exception::exception(class std::exception const &)"
(??0exception@std@@QAE@ABV01@@Z) already defined in vc8test.obj
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall
std::_Container_base::~_Container_base(void)"
(??1_Container_base@std@@QAE@XZ) already defined in vc8test.obj
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall
std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in
libcpmtd.lib(xlock.obj)
msvcprtd.lib(MSVCP80D.dll) : error LNK2005: "public: __thiscall
std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in
libcpmtd.lib(xlock.obj)

If anyone can suggest a workaround or knows what might be causing
libcpmt(d).lib to be linked I''d be more than happy ;-)

-Markus-

解决方案

I myself wrote in message news:uZ**************@tk2msftngp13.phx.gbl...

I''m just experimenting around with the VisualC++ 2005 Express Edition Beta
and found some strange behavior for which I can''t seem to find a
workaround.

What I''ve done is set up two static library projects for Lua 5.0.2 and
LuaBind beta-6, compiling both with no CLR support and configured to use
the Multithreaded DLL runtime. Then I created a new console application
which makes use of these two static libraries (of course, also set to MT
DLL). So far so good, everything works.

When I then turned on CLR support for this console application, the linker
complained about symbols from the runtime libraries being defined mutiple
times - eg. in msvcprtd.lib (DLL runtime) and *libcpmtd.lib* (static
runtime).



I''ve tried around with some other libraries and observed, that those errors
appear whenever I link an unmanaged static library making use of the C++
runtime into a managed project. It doesn''t happen with pure C projects.

So, in the context of my initial project, compiling LuaBind with the /CLR
option solves the problem. Strange.

-Markus-


Looks like that assumption was a bit premature. To crash my app, I need no
more than this:

1) Create a new windows forms based application
2) Change the CLR option from pure CLR to normal CLR linkage
3) #include <string> and write something like std::string test = "hello
world"; in Main()
-> dbgheap.c #1301 Assertion pUserData != 0
-> Ignore leads to Access Violation

Callstack at time of assertion is
msvcr80d.dll!_msize_dbg(void * pUserData=0x00000000, int nBlockUse=2)
Line 1301 + 0x26 bytes C++
msvcr80d.dll!_dllonexit_nolock(int (void)* func=0x004535e0, void (void)* *
* pbegin=0x0046a4f4, void (void)* * * pend=0x0046a4f0) Line 282 + 0xd bytes
C
msvcr80d.dll!__dllonexit(int (void)* func=0x004535e0, void (void)* * *
pbegin=0x0046a4f4, void (void)* * * pend=0x0046a4f0) Line 259 + 0x11 bytes
C
VC8Test.exe!_onexit(int (void)* func=0x004535e0) Line 83 + 0x2e bytes C
VC8Test.exe!atexit(void (void)* func=0x004535e0) Line 98 + 0x9 bytes C
VC8Test.exe!std::initlocks::`dynamic initializer''() Line 49 + 0x17 bytes
C++
VC8Test.exe!_initterm(void** pfbegin = 0x00469008, void pfend = ) Line 140
C++
VC8Test.exe!?.cctor@@


FYMXXZ() Line 297 C++

-Markus-


这篇关于DLL运行时和/ CLR编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆