Solved

Adding libraries into a project

Posted on 1998-08-25
17
233 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".
0
Comment
Question by:wmlim060298
  • 9
  • 7
17 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 70 total points
ID: 1171248
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
 

Author Comment

by:wmlim060298
ID: 1171249
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
 
LVL 23

Expert Comment

by:chensu
ID: 1171250
Try both. Either should work.
0
 
LVL 2

Expert Comment

by:warmcat
ID: 1171251
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
 
LVL 23

Expert Comment

by:chensu
ID: 1171252
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
 

Author Comment

by:wmlim060298
ID: 1171253
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
 
LVL 23

Expert Comment

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

Author Comment

by:wmlim060298
ID: 1171255
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 23

Expert Comment

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

Author Comment

by:wmlim060298
ID: 1171257
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
 
LVL 23

Expert Comment

by:chensu
ID: 1171258
Have you tried using /NODEFAULTLIB:library?
0
 

Author Comment

by:wmlim060298
ID: 1171259
No, I did not use /NODEFAULTLIB:library. If I try using it, there will be a few hundred errors.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1171260
Can you list the libraries you are currently using? And the project settings, such as using MFC?
0
 

Author Comment

by:wmlim060298
ID: 1171261
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
 
LVL 23

Expert Comment

by:chensu
ID: 1171262
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
 
LVL 23

Expert Comment

by:chensu
ID: 1171263
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
 

Author Comment

by:wmlim060298
ID: 1171264
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now