Sign in to follow this  
GroZZleR

Weird linker warning -- never seen it.

Recommended Posts

GroZZleR    820
Hey all, I'm getting this bizarre linker error. I'm building a utility library and this started popping up. Linking... LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library Heres the program if it makes a difference:
#pragma comment(lib, "GroZUtilities.lib")

#include <iostream>

#include <CBox2D.h>

int main(void)
{
	CBox2D box;

	std::cout << box.DoSomething() << std::endl;

	return 0;
}

Share this post


Link to post
Share on other sites
merlin9x9    174
This usually happens when one or more libraries you're linking with uses a different variety of the C runtime library. For example, your main program might be using single-threaded, and one of your libraries is using multithreaded.

Share this post


Link to post
Share on other sites
merlin9x9    174
No, it doesn't depend on the type of application. Check the "Use runtime library" setting for both projects and ensure that they're the same.

Share this post


Link to post
Share on other sites
GroZZleR    820
Ah, my testing app was set to Debug and my library was set to Release. I guess that caused the conflict?

I can't seem to reproduce the error in Release mode, but if I switch back to Debug it still does it.

Thanks for the help.

Share this post


Link to post
Share on other sites
Wavewash    202
Go to the Debug Build Settings and make sure that they are being built in the same thread setting(ie. Single threaded or multi threaded) like merlin9x9 said. It should be a pulldown that you can select it from if you are using MS visual studio.

~Wave

Share this post


Link to post
Share on other sites
Quote:
Original post by IronWolf
Why do you have void in the () by main? I would imagine this would be uneeded.


It's not needed nor harmfull but it's a habit many people with a solid C background uses, since the meaning of
foo() and foo(void) is diffrent in some flavours of C, the first meaning "any number of arguments" or what would today be written with elipsis ... C++ doesn't have this distinction but I still find it nicer to look at :)

Share this post


Link to post
Share on other sites
Promit    13246
It's not a serious error, really.

For example, I have my project set up to use the Debug Multithreaded DLL runtime in Debug mode, and the release version, Multithreaded DLL. SDL, however, uses the Multithreaded DLL either way, so I get that warning with debug builds.

Share this post


Link to post
Share on other sites
Promit    13246
Quote:
Original post by IronWolf
Oh, I see its like how I can use int main or void main. My background is C++ so I have not seen that.


Not quite, because void main is non-standard and won't compile on most compilers [grin]

Share this post


Link to post
Share on other sites
merlin9x9    174
To make it even more fun, the standard says that you don't explicitly have to return anything in int main. If you don't, return 0; is assumed.

Share this post


Link to post
Share on other sites
foniks munkee    133
Yup that is true, return 0 is assumed. But using "void" in a function to denote an empty parameter list is not correct in C++. Again according to Bjarne and the standard.

[edit] Well - I hate it when I am wrong - Bjarne is definitely not keen on the use of void as an empty parameter list, however the standard has not problem with it:

Quote:

"The parameter list (void) is equivalent to the empty parameter list. Except for this special case, void shall not be a parameter type (though types derived from void, such as void* can)."


And the standard has this to say about main and return 0
Quote:

"A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling exit with the return value as the argument. If control reaches the end of main without encountering a return statement, the effect is that of executing

return 0;"


Mmmm standard fresh...

[Edited by - foniks munkee on July 13, 2004 7:02:29 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this