Adding libraries into a project

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".
wmlim060298Asked:
Who is Participating?
 
chensuCommented:
Use a space to seperate them. That's the correct way. The warning says that you are trying to link with incompatible libraries. See the documentation about Linker Tools Warning LNK4098.
0
 
wmlim060298Author 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.
0
 
chensuCommented:
Try both. Either should work.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
warmcatCommented:
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.
0
 
chensuCommented:
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.
0
 
wmlim060298Author 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.
0
 
chensuCommented:
The result should be same regardless of the methods. That's a warning. What happens if you just ignore it?
0
 
wmlim060298Author 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.
0
 
chensuCommented:
The result should be same regardless of the methods. That's a warning. What happens if you just ignore it?
0
 
wmlim060298Author 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.
0
 
chensuCommented:
Have you tried using /NODEFAULTLIB:library?
0
 
wmlim060298Author Commented:
No, I did not use /NODEFAULTLIB:library. If I try using it, there will be a few hundred errors.
0
 
chensuCommented:
Can you list the libraries you are currently using? And the project settings, such as using MFC?
0
 
wmlim060298Author 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.
0
 
chensuCommented:
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?
0
 
chensuCommented:
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
0
 
wmlim060298Author 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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.