Adding Libraries in Visual C++

Posted on 2003-03-17
Medium Priority
Last Modified: 2013-12-14
Hello there!
I'm new to C++ (Mostly C/ASM before), and have joined the wonderful world of classes! :P

Anyway, when I try to implement a Win32 static library to my project, I get the following error:

LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library

I've tried to create both tiny and bigger libraries, but I always get the exact same warning.

What is this, and why does it happen?
Question by:Caminman
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8154967
Well, I'm no expert on Visual C++, but it seems like this error happens a lot when trying to incorporate static libraries with an MFC application.

You might try the compiler's suggestion and add the /nodefaultlib option to your project. Hopefully that'll solve your problem.

In Visual C++ 6.0, you can do this by going to:
Project -> Settings -> Link (tab)

Then go to the edit box at the bottom of the dialog box called "Project Options" and add "/nodefaultlib:libc.lib" (without quotations of course) to the options.

Good luck!

Accepted Solution

jadams117 earned 200 total points
ID: 8155644
You need to make sure the library files used by all your projects are the same - otherwise you'll get clashes between them

To do this:

1 - Go to 'Projects | Settings..' from the main menu
2 - Select all your included projects (by holding Ctrl/Shift while selecting them with the mouse) in the left pane
3 - Select the 'C/C++' tab in the right pane
4 - Select 'Code generation' from the 'Category' combo
5 - Where it says 'Use run-time library' select the library you want to use

Usually you'll want to use the DLL libraries as these will create smaller executable files. For your Debug build select the 'Debug Multithreaded DLL' library. For your Release build select the 'Multithreaded DLL'

Note: If you are planning a release on a machine which may not have the MFC DLLs then you should either build using the non-DLL libraries or include the MFC DLL with your installation

Tip: Always use multithreaded libraries!

Hope this helps

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question