473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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:library

libcpmtd.lib(cerr.obj) : error LNK2005: "public: __thiscall
std::basic_ostream<char,struct std::char_traits<char>
>::basic_ostream<char,struct std::char_traits<char(class std::basic_streambuf<char,struct std::char_traits<char *,bool)" (??0?$basic_ostream@DU?$char_traits@D@std@@@std@@Q AE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@ _N@Z) already defined in msvcprtd.lib(MSVCP80D.dll)
LIBCMTD.lib(stdexcpt.obj) : error LNK2005: "public: __thiscall
std::exception::exception(void)" (??0exception@std@@QAE@XZ) already
defined in MSVCRTD.lib(MSVCR80D.dll)

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

Aug 11 '06 #1
6 2671
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:LIBCMTD" 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\native.lib" /NOLOGO /NODEFAULTLIB:"libcmtd.lib"
/NODEFAULTLIB:"libcpmtd.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
-----------------
/manifestdependency:"type='win32'
name='Microsoft.VC80.DebugCRT'
version='8.0.50608.0'
processorArchitecture='x86'
publicKeyToken='1fc8b3b9a1e18e3b'"
/DEFAULTLIB:"msvcprtd"
/manifestdependency:"type='win32'
name='Microsoft.VC80.DebugCRT'
version='8.0.50608.0'
processorArchitecture='x86'
publicKeyToken='1fc8b3b9a1e18e3b'"

/alternatename:__imp_??$?5DU?$char_traits@D@std@@@s td@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0 @AAV10@AAD@Z=__imp_??5std@@YAAAV?$basic_istream@DU ?$char_traits@D@std@@@0@AAV10@AAD@Z
/DEFAULTLIB:"MSVCRTD"
/DEFAULTLIB:"OLDNAMES"

Linker Directives
-----------------
/DEFAULTLIB:"libcpmtd"
/DEFAULTLIB:"LIBCMTD"
/DEFAULTLIB:"OLDNAMES"

Linker Directives
-----------------
/DEFAULTLIB:"libcpmtd"
/DEFAULTLIB:"LIBCMTD"
/DEFAULTLIB:"OLDNAMES"

Linker Directives
-----------------
/DEFAULTLIB:"LIBCMTD"
/DEFAULTLIB:"OLDNAMES"

Linker Directives
-----------------
/DEFAULTLIB:"libcpmtd"
/DEFAULTLIB:"uuid.lib"
/DEFAULTLIB:"uuid.lib"
/include:?id@?$numpunct@D@std@@2V0locale@2@A

/include:?id@?$num_put@DV?$ostreambuf_iterator@DU?$ char_traits@D@std@@@std@@@std@@2V0locale@2@A
/DEFAULTLIB:"LIBCMTD"
/DEFAULTLIB:"OLDNAMES"

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:LIBCMTD" 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\native.lib" /NOLOGO /NODEFAULTLIB:"libcmtd.lib"
/NODEFAULTLIB:"libcpmtd.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.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.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
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...
4
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: ...
3
by: Dave | last post by:
Hello all, Please consider this code: #ifndef FOO_INCLUDED #define FOO_INCLUDED // File: foo.h class foo {
50
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
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:...
9
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
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...
7
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...
1
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...
1
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:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.