Solved

Adding libraries into a project

Posted on 1998-08-25
17
238 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
Independent Software Vendors: 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

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!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

695 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