We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Adding libraries into a project

wmlim060298
wmlim060298 asked
on
Medium Priority
260 Views
Last Modified: 2010-04-01
How do I add additional libraries (other than the standard ones)for use in a new workspace?

I had tried to add it in the Link Tab in the Project Settings menu. However, when I try to put commas between 2 library filenames, I am unable to open the files during compilation. If I try to just leave a space between the 2 filenames, I get the following error message "LINK : warning LNK4098: defaultlib "libc.lib" conflicts with use of other libs; use /NODEFAULTLIB:library".
Comment
Watch Question

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
chensu,
However, I do not know whether the run-time library provided by the book is in debug or non-debug version. Hence, I do not know how to get my project compiled without errors.

Commented:
Try both. Either should work.

Commented:
In fact you can just add the libraries to your project in the same way as you would add another C or C++ file, using the file view window.

Commented:
Yes, that's another way. In general, I would use the method wmlim mentioned for the standard libraries and use the method warmcat mentioned for my own libraries. That's just a programmer's preference.

Author

Commented:
I had tried the method of adding the library files like adding C or C++ files but still does not work. I am still having the same error message.

Commented:
The result should be same regardless of the methods. That's a warning. What happens if you just ignore it?

Author

Commented:
I had tried the method of adding the library files like adding C or C++ files but still does not work. I am still having the same error message.

Commented:
The result should be same regardless of the methods. That's a warning. What happens if you just ignore it?

Author

Commented:
Nothing happens if I ignore it and try to run the exe file. It also says that there is an error executing the exe file.

Commented:
Have you tried using /NODEFAULTLIB:library?

Author

Commented:
No, I did not use /NODEFAULTLIB:library. If I try using it, there will be a few hundred errors.

Commented:
Can you list the libraries you are currently using? And the project settings, such as using MFC?

Author

Commented:
I am currently using Win32 Release. Use MFC in Static Library.
In the general section for Link, "ImageLoad.lib ImagePointProcesses.lib ImageObject.lib " is put in the object/library modules section.

"ImageLoad.lib ImagePointProcesses.lib ImageObject.lib /nologo /subsystem:windows /incremental:no /pdb:"Release/hands_on1.pdb" /machine:I386 " , this is the project options stated.

I hope the above information is sufficient for you to know what is wrong.

Commented:
Are those Image*.lib third party libraries? Are they release version or debug version? The problem is due to the mixture of release version and debug version of MFC libraries and/or C Run-Time Libraries, I think. Sometimes it causes problems. Do you have such a problem when you build a debug version?

Commented:
The following KB article says "Beginning with Visual C++ 4.0, the linker will issue a warning (LNK4098) if a resulting module attempts to combine more than one copy of the CRT library.".

http://support.microsoft.com/support/kb/articles/q140/5/84.asp

Author

Commented:
Thanks! I have tried to add /NODEFAULTLIB:library again and it's running fine now. I forgot to add the name of the /NODEFAULTLIB:"libcd.lib", I put it as /NODEFAULTLIB:library previously.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.