# Weird linker warning -- never seen it.

This topic is 4969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 on other sites
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 on other sites
I just built a Win32 Static Library, and I'm importing it into a Win32 Console App, could that be the problem?

##### Share on other sites
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 on other sites
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 on other sites
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 on other sites
Quote:
 Original post by IronWolfWhy 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 on other sites
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 on other sites
Quote:
 Original post by IronWolfOh, 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 on other sites
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 on other sites
I'm positive. I was surprised when I read it, too, but I assume that Bjarne Stroustrup knows his stuff about C++. ;)

##### Share on other sites
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.

 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 executingreturn 0;"

Mmmm standard fresh...

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