Solved

Adding libraries into a project

Posted on 1998-08-25
17
237 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to print into std::string like sprintf using C++11? 12 125
Beginner to Unreal Engine 4 5 107
C++ help/ Toy problem 19 57
learn programming 8 73
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

696 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