473,611 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with multiply defined symbols in a mixed-mode DLL

I have 5 native static libraries that are being compiled in Visual
Studio 2005 with the /MDd C Runtime option. I have 2 CLR DLLs (all
managed code) in Visual Studio 2005 and the /MDd C Runtime setting.
They are in the same solution, and compile/link without problems (Debug
configuration).

I also have 1 mixed-mode CLR DLL that consumes both the static
libraries and managed DLLs. It is configured to use the /MDd C Runtime
library. When I add it to the solution (making sure its references are
correct), it gives linking errors shown below.

I am a relatively young developer, spoiled by Java and C#. I
understand that the problems indicate an attempt to link against 2
versions of the C Runtime Library -- but I have no idea what settings
to check (or what to look for in the code) in order to resolve the
problem. I have been making sure that C++ --Code Generation -->
Runtime Library is set to /MDd for everything. Are there other
settings or places in code that could cause me to link to another
version?

Thanks for any advice you could give,
John

-----=[ Begin Example Linking Errors ]=-----
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of
other libs; use /NODEFAULTLIB:li brary

libcpmtd.lib(ce rr.obj) : error LNK2005: "public: __thiscall
std::basic_ostr eam<char,struct std::char_trait s<char>
>::basic_ostrea m<char,struct std::char_trait s<char(class std::basic_stre ambuf<char,stru ct std::char_trait s<char *,bool)" (??0?$basic_ost ream@DU?$char_t raits@D@std@@@s td@@QAE@PAV?$ba sic_streambuf@D U?$char_traits@ D@std@@@1@_N@Z) already defined in msvcprtd.lib(MS VCP80D.dll)
LIBCMTD.lib(std excpt.obj) : error LNK2005: "public: __thiscall
std::exception: :exception(void )" (??0exception@s td@@QAE@XZ) already
defined in MSVCRTD.lib(MSV CR80D.dll)

C:\path\MixedMo de.dll : fatal error LNK1169: one or more multiply
defined symbols found

Aug 11 '06 #1
6 2692
John wrote:
I have 5 native static libraries that are being compiled in Visual
Studio 2005 with the /MDd C Runtime option. I have 2 CLR DLLs (all
managed code) in Visual Studio 2005 and the /MDd C Runtime setting.
They are in the same solution, and compile/link without problems
(Debug
configuration).

I also have 1 mixed-mode CLR DLL that consumes both the static
libraries and managed DLLs. It is configured to use the /MDd C
Runtime
library. When I add it to the solution (making sure its references
are
correct), it gives linking errors shown below.

I am a relatively young developer, spoiled by Java and C#. I
understand that the problems indicate an attempt to link against 2
versions of the C Runtime Library -- but I have no idea what settings
to check (or what to look for in the code) in order to resolve the
problem. I have been making sure that C++ --Code Generation -->
Runtime Library is set to /MDd for everything. Are there other
settings or places in code that could cause me to link to another
version?
Something in that mix was compiled with /MTd, not /MDd. Re-check your
project settings for everything in the link, and make sure to do a
Rebuild-All.

You can also use

dumpbin /directives myfile.obj (or .lib)

to see the defaultlib directives in an object or library file. That could
help you pin down which module is at fault.

-cd

Aug 12 '06 #2
Carl,

Thanks very much for telling me about the 'dumpbin' command: I never
knew about it. I've run it on one of the native libraries, and have
come up with the output below.

I can see that this library has "/DEFAULTLIB:LIBC MTD" but I'm confused
as to why because my C++ --Code Generation --Runtime Library is set
to "/MDd" and my librarian command line looks like the following:
/OUT:"Debug\nati ve.lib" /NOLOGO /NODEFAULTLIB:"l ibcmtd.lib"
/NODEFAULTLIB:"l ibcpmtd.lib"

When I set my libraries and DLLs to compile with option /MDd, which C
Runtime Library should I expect to see in /dumpbin? libcmdd.lib?

As you can see, I've done enough searching/reading to know what my
problem is. But every time someone has this sort of problem, the
answer is always, "oh, just make sure you're linking against the same C
Runtime throughout" -- with no explaination of which settings to check
in the project's properties, so I'm very lost. =(

Can anyone please help me understand what my next steps should be?

Thanks!
John
-----=[ Begin /dumpbin output ]=-----
Microsoft (R) COFF/PE Dumper Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file native.lib

File Type: LIBRARY

Linker Directives
-----------------
/manifestdepende ncy:"type='win3 2'
name='Microsoft .VC80.DebugCRT'
version='8.0.50 608.0'
processorArchit ecture='x86'
publicKeyToken= '1fc8b3b9a1e18e 3b'"
/DEFAULTLIB:"msv cprtd"
/manifestdepende ncy:"type='win3 2'
name='Microsoft .VC80.DebugCRT'
version='8.0.50 608.0'
processorArchit ecture='x86'
publicKeyToken= '1fc8b3b9a1e18e 3b'"

/alternatename:_ _imp_??$?5DU?$c har_traits@D@st d@@@std@@YAAAV? $basic_istream@ DU?$char_traits @D@std@@@0@AAV1 0@AAD@Z=__imp_? ?5std@@YAAAV?$b asic_istream@DU ?$char_traits@D @std@@@0@AAV10@ AAD@Z
/DEFAULTLIB:"MSV CRTD"
/DEFAULTLIB:"OLD NAMES"

Linker Directives
-----------------
/DEFAULTLIB:"lib cpmtd"
/DEFAULTLIB:"LIB CMTD"
/DEFAULTLIB:"OLD NAMES"

Linker Directives
-----------------
/DEFAULTLIB:"lib cpmtd"
/DEFAULTLIB:"LIB CMTD"
/DEFAULTLIB:"OLD NAMES"

Linker Directives
-----------------
/DEFAULTLIB:"LIB CMTD"
/DEFAULTLIB:"OLD NAMES"

Linker Directives
-----------------
/DEFAULTLIB:"lib cpmtd"
/DEFAULTLIB:"uui d.lib"
/DEFAULTLIB:"uui d.lib"
/include:?id@?$n umpunct@D@std@@ 2V0locale@2@A

/include:?id@?$n um_put@DV?$ostr eambuf_iterator @DU?$char_trait s@D@std@@@std@@ @std@@2V0locale @2@A
/DEFAULTLIB:"LIB CMTD"
/DEFAULTLIB:"OLD NAMES"

Summary

E8 .CRT$XCU
6A1 .bss
685 .data
4CEB8 .debug$S
208 .debug$T
3EE .drectve
114D .rdata
9DD .rdata$r
14 .rtc$IMZ
14 .rtc$TMZ
19C .sxdata
1360A .text
135A .text$x
67B .text$yc
1A2 .text$yd
19E0 .xdata$x

Aug 14 '06 #3
I've answered one of my own questions but still have a long way to go..
John wrote:
When I set my libraries and DLLs to compile with option /MDd, which C
Runtime Library should I expect to see in /dumpbin? libcmdd.lib?
The article at http://msdn2.microsoft.com/en-us/library/2kzt1wy3.aspx
answers this question.

Also, http://msdn2.microsoft.com/en-us/library/abx4dbyh.aspx is another
resource.

Aug 14 '06 #4
John wrote:
Carl,

Thanks very much for telling me about the 'dumpbin' command: I never
knew about it. I've run it on one of the native libraries, and have
come up with the output below.

I can see that this library has "/DEFAULTLIB:LIBC MTD" but I'm confused
as to why because my C++ --Code Generation --Runtime Library is
set
to "/MDd" and my librarian command line looks like the following:
OK, your project is set correctly. The next step is to check the settings
on every individual .cpp file in the project. Those settings can be
overridden on a file by file basis.
/OUT:"Debug\nati ve.lib" /NOLOGO /NODEFAULTLIB:"l ibcmtd.lib"
/NODEFAULTLIB:"l ibcpmtd.lib"
I'm not sure that the /nodefaultlib option has any bearing on the lib
command (which is really just a wrapper over link /lib).
>
When I set my libraries and DLLs to compile with option /MDd, which C
Runtime Library should I expect to see in /dumpbin? libcmdd.lib?
You should see msvcrtd.lib
>
As you can see, I've done enough searching/reading to know what my
problem is. But every time someone has this sort of problem, the
answer is always, "oh, just make sure you're linking against the same
C
Runtime throughout" -- with no explaination of which settings to check
in the project's properties, so I'm very lost. =(

Can anyone please help me understand what my next steps should be?
-cd
Aug 15 '06 #5

Carl Daniel [VC++ MVP] wrote:
OK, your project is set correctly. The next step is to check the settings
on every individual .cpp file in the project. Those settings can be
overridden on a file by file basis.
Carl,

That was the problem. I didn't know that individual files could
overwrite the project-level setting! Some of them were - as you can
guess - set to /MTd.

After resetting every single file (groan) for /MDd, everything compiles
and links!

Thanks so much!
John

Aug 15 '06 #6
"John" <ja****@gmail.c omwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
>
Carl Daniel [VC++ MVP] wrote:
>OK, your project is set correctly. The next step is to check the
settings
on every individual .cpp file in the project. Those settings can be
overridden on a file by file basis.

Carl,

That was the problem. I didn't know that individual files could
overwrite the project-level setting! Some of them were - as you can
guess - set to /MTd.

After resetting every single file (groan) for /MDd, everything compiles
and links!
Glad it worked!

Those per-file overrides are really handy when you need 'em, but quite a
nuisance when you don't know they're there! There were problems with
project conversion from VC6 to VC7 (and 7.1, I think) that would sometimes
duplicate project-level settings as file-level settings, so if your project
was migrated from VC6 through VC7.x, that may be how those per-file settings
got in there.

-cd
Aug 15 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1788
by: Michael | last post by:
I'm trying to compile on VC++ and am having a linking error. I basically have a library for all my maths functions: 3DMaths.lib, and a library for my for my engine and also my game, but get the following problems: I try and include tnt/tnt.h and tnt/jama/jama.h inside 2 cpp's in my 3DMaths library, but get the following erros: What Am I doing wrong, As it undertand the error messages, the librarys
4
2494
by: shannontbailey | last post by:
I reorganized my VC6 MFC project a bit, and ended up having to rebuild my precompiled header file. I'm not sure if that is relevant or not. I can't get past the following error, however: MISO_i.obj : error LNK2005: _LIBID_MISOLib already defined in MISO.obj (MISO being the name of the application.) Any ideas?
3
4634
by: Dave | last post by:
Hello all, Please consider this code: #ifndef FOO_INCLUDED #define FOO_INCLUDED // File: foo.h class foo {
50
4174
by: sabarish | last post by:
Hi to all. find out the biggest among two numbers without using any conditional statements and any relational operators.
0
833
by: timo6666 | last post by:
Hi all, VC7 makes a problem in my application while linking: ------ Build started: Project: Test, Configuration: Debug Win32 ------ Linking... libcimtd.lib(ifstream.obj) : error LNK2005: "void __cdecl operator delete(void *,int,char const *,int)" (??3@YAXPAXHPBDH@Z) already defined in nafxcwd.lib(afxmem.obj)
9
4038
by: chat | last post by:
Hi, every body. I have 3 files like this: -------------------------------------------------------- file name : header.h #ifndef TEST_H #define TEST_H int a=1; double b=0.5;
3
2166
by: hamishd | last post by:
TestClass.obj : error LNK2005: "int volatile bIsProcessing" (?bIsProcessing@@3HC) already defined in OtherClass.obj Creating library Release/TestDLL.lib and object Release/TestDLL.exp Release/TestDLL.dll : fatal error LNK1169: one or more multiply defined symbols found In TestClass header file I have: volatile BOOL bIsProcessing;
7
2204
by: DBMS_Plumber | last post by:
Having a hard time with a UDF. Wonder if folk might care to take a look and tell me what's up. All of this kicked off from trying to build a set of C++ iostream derived classes that can make DB2's gimped BLOB API (sqludf_append() etc) look--to the extent that this is possible--like something C++ libraries can use to serialize stuff to (via iostream::read(), iostream::write() and what-not).
1
4331
by: toefraz | last post by:
Hey, guys. I have an assignment to work with static data members with numbers. I've done all the programming needed, but I keep getting this error when I try to compile: 1>Number.obj : error LNK2005: "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * Number::tens" (?tens@Number@@0PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) already defined in driver.obj...
1
1884
by: Gavin Chen | last post by:
Hello: I tried to install Tk800.015 on SunOS 4.1.4 with perl 5.6.2. At "make test" time, I got the error message as below: collect2: ld returned 2 exit status ld: /usr/local/lib/perl5/site_perl/5.6.2/sun4-sunos/auto/Tk/Event/Event.a(Event.o): _LangExit: multiply defined ld: /usr/local/lib/perl5/site_perl/5.6.2/sun4-sunos/auto/Tk/Event/Event.a(Event.o): _Tcl_Free: multiply defined ld:...
0
8596
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8561
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8411
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5527
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4042
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2546
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1692
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.