Solved

Adding libraries into a project

Posted on 1998-08-25
17
236 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

808 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