Skip to main content
GameDev.net gamedev.net
🔒 Locked

Wierd Linking Problem

Started by Evil Bill Aug 7, 2002 at 10:11 AM 15 replies 1k views
Original Post
Evil Bill
Evil Bill
Hi, anyone know whats going on with these errors?
Linking...
LIBCD.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj)
...
LIBCD.lib(crt0dat.obj) : warning LNK4006: __winver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __osver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __umaskval already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
   Creating library Debug/ObjectCore.lib and object Debug/ObjectCore.exp
LINK : warning LNK4098: defaultlib "LIBCD" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/ObjectCore.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

ObjectCore.dll - 23 error(s), 23 warning(s)
 
I''ve got a couple of helper librarys i made: CFMath.lib which is a pile of math functions and classes, and DXUtil.lib which is full of D3D classed like CTexture and CMatrixStack. DXUtil.lib uses math functions from CFMath.lib, so if you want to incluse DXUtil.lib, you also need CFMath.lid, d3d8.lib and dxguid.lib. [random guess] LIBCMTD - does the ''MT'' bit stand for Muti-Threaded? I''m not using multi-threading, and i haven''t touched any options for it in any of the projects. [/random guess] I''m using MSVC - although you can probably tell that from the errors. Thanks for any help, Steve Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
Evil Bill
Evil Bill
I can get it down to 1 linking error by removing DXUtil.lib:

Linking...
Creating library Debug/ObjectCore.lib and object Debug/ObjectCore.exp
LINK : warning LNK4098: defaultlib "LIBCD" conflicts with use of other libs; use /NODEFAULTLIB:library
ParticleSystem.obj : error LNK2001: unresolved external symbol "public: void __thiscall CTexture::Release(void)" (?Release@CTexture@@QAEXXZ)
Debug/ObjectCore.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

ObjectCore.dll - 2 error(s), 1 warning(s)

But obviously i can;t use functions in DXUtil.lib (Like Texture::Release())

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
daerid
daerid
Well, I spent $20 and grabbed the PDF of the C++ ISO standard, which defines the language and the std library, so I''ll give that a browse
daerid@gmail.com
Evil Bill
Evil Bill
Cheers.
I''ve got a tempoary fix by just not using my DXUtil.lib library, which is probably a good way to do it anyway since i''m trying to make this section more portable.



Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
Evil Bill
Evil Bill
Damn Hotmail...

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
Evil Bill
Evil Bill
Really, i didn''t touch the multi-threading settings.
I just looked through the setting in every project, and none of them even have an option to enable multi-threading.

Any ideas?

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
niyaw
niyaw
1) you may have the lib project settings use multithreaded crt.
2) you may have individual files using multithreaded crt, possibly in the lib project.
3) you may include some headers that force libcmtd into your object files (however the only headers i know for sure that do this are mfc ones)

the point is, somewhere you are using the multithreaded crt. i suggest you open msdn on "compiler options" and find the switch that controls multithreaded crt, then search for that switch (/MDd, i even looked it up for you) in all .dsp files.

and is there a reason why everyone avoids multithreaded crt dlls and bloats their exe sizes with useless statically linked crt code?
siaspete
siaspete
Finding which lib uses the multithreaded runtime can be tricky, especially if you''re linking to libs provided by someone else. The solution is usually to go multithreaded all the way, because something you''re using must need it.

As for choosing whether to use the DLL version or not, it comes down to either making the user have the DLL too, or making your exe a bit bigger.

I go for the bigger exe, as it''s nothing compared to the size of the smallest of hard drives, and it saves on some troubleshooting later on when the user has a different DLL version.

By the way, I live in Edinburgh too.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Cyberdrek
Cyberdrek
quote:
Original post by Evil Bill
Hi, anyone know whats going on with these errors?

Linking...
LIBCD.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in LIBCMTD.lib(crt0dat.obj)
LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj)
...
LIBCD.lib(crt0dat.obj) : warning LNK4006: __winver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __osver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
LIBCD.lib(crt0dat.obj) : warning LNK4006: __umaskval already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored
Creating library Debug/ObjectCore.lib and object Debug/ObjectCore.exp
LINK : warning LNK4098: defaultlib "LIBCD" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/ObjectCore.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

ObjectCore.dll - 23 error(s), 23 warning(s)

I''ve got a couple of helper librarys i made: CFMath.lib which is a pile of math functions and classes, and DXUtil.lib which is full of D3D classed like CTexture and CMatrixStack.
DXUtil.lib uses math functions from CFMath.lib, so if you want to incluse DXUtil.lib, you also need CFMath.lid, d3d8.lib and dxguid.lib.

[random guess]
LIBCMTD - does the ''MT'' bit stand for Muti-Threaded? I''m not using multi-threading, and i haven''t touched any options for it in any of the projects.
[/random guess]

I''m using MSVC - although you can probably tell that from the errors.

Thanks for any help,
Steve

Steve
DirectX Programmer
Soon to be the new Bill Gates



The answer is /NODEFAULTLIB . Simply add that in your project setting for Libs.



"DaHjajmajQa''jajHeghmeH!"

Cyberdrek
danielc@iquebec.com
Founder
Laval Linux

/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash
[Cyberdrek | ]
Evil Bill
Evil Bill
using /NODEFAULTLIB for the libraries seems to have solved it.
I tried changing the removing the "/MTd" from the DLL (Doesn''t that create a multithreaded .exe?!?), and i got a pile of link errors (shown below) and the compiler added "/MLd" instead?!?

Compiling...
ParticleSystem.cpp
Linking...
Creating library Debug/ObjectCore.lib and object Debug/ObjectCore.exp
ObjectCore.obj : error LNK2001: unresolved external symbol _strcmp
ObjectCore.obj : error LNK2001: unresolved external symbol __chkesp
ParticleSystem.obj : error LNK2001: unresolved external symbol __chkesp
cfmath.lib(CFMath.obj) : error LNK2001: unresolved external symbol __chkesp
ParticleSystem.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
ParticleSystem.obj : error LNK2001: unresolved external symbol ___CxxFrameHandler
ParticleSystem.obj : error LNK2001: unresolved external symbol __except_list
ParticleSystem.obj : error LNK2001: unresolved external symbol __assert
ParticleSystem.obj : error LNK2001: unresolved external symbol __fltused
cfmath.lib(CFMath.obj) : error LNK2001: unresolved external symbol __fltused
ParticleSystem.obj : error LNK2001: unresolved external symbol __purecall
ParticleSystem.obj : error LNK2001: unresolved external symbol _rand
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
cfmath.lib(CFMath.obj) : error LNK2001: unresolved external symbol _sin
cfmath.lib(CFMath.obj) : error LNK2001: unresolved external symbol _cos
cfmath.lib(CFMath.obj) : error LNK2001: unresolved external symbol _sqrt
cfmath.lib(CFMath.obj) : error LNK2001: unresolved external symbol _memcmp
libcpd.lib(delop.obj) : error LNK2001: unresolved external symbol _free
Debug/ObjectCore.dll : fatal error LNK1120: 15 unresolved externals
Error executing link.exe.

ObjectCore.dll - 19 error(s), 0 warning(s)


I can''t seem to find any ''sensible'' way to enable or disable multithreading (e.g. a checkbox), apart from changing the options by putting in "/MTd". Is there a way?

Cheers for all the replies.
Steve

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
Evil Bill
Evil Bill
D''oh" I was looking for a checkbox, not a drop list!
quote:

This option determines whether the program being built has single or multithreaded support. This setting changes the values of the /MD, /ML, and /MT compiler switches. It is usually best to use the multi-threaded options when wuilding a DLL. If you specify a single-threaded option, your DLL will work reliably only when called by single-threaded applications.


Thats why the DLL was set up for multithreading. The Libs were built with single-threading, so when i link them to my DLL... Boom.

Now i see (Finally!)

Thanks everyone!

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.