Click here to Skip to main content
15,914,820 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everybody...
I have a little problem:
Suppose you want include some libraries For example: "Parentlib/test1.h" , "Parentlib/test2.h" and so on.
How can i define "Parentlib" somehow so "test1.h" and "test2.h" work? How that is possible?
Posted
Comments
Sergey Alexandrovich Kryukov 22-Jan-12 16:10pm    
What is your development environment, compiler, etc.?
--SA
alizadeh91 22-Jan-12 16:13pm    
Qt
alizadeh91 22-Jan-12 16:14pm    
Actually "Qt Creator"
alizadeh91 22-Jan-12 16:18pm    
My Compiler is gcc. For more information i've downloaded a math package(trilinos) and when i want to use its libraries i must include "trilinos/etc...h" but in its own libraries there is no trilinos keywork in include terms. And that is why compiler complain : no such a directory or class. So i have to define "trilinos" somehow..

It's possible that you are looking for #pragma comment( lib, ... )[^]

if the lib file required by the headers is called Parentlib.lib you can add
#pragma comment( lib, "Parentlib" )

to the file containing your main function. Make sure that the linker knows where to find the lib file too.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
alizadeh91 22-Jan-12 16:25pm    
My IDE won't recognize 'comment'! :S
Espen Harlinn 22-Jan-12 16:33pm    
Are you running this on linux or windows - and if this is on windows, are you using cygwin or mingw. Which ide are you using?
alizadeh91 22-Jan-12 16:38pm    
Ubuntu! and my compiler is gcc. IDE: Qt Creator
alizadeh91 22-Jan-12 16:37pm    
Ubuntu! and my compiler is gcc. IDE: Qt Creator
Espen Harlinn 22-Jan-12 16:39pm    
Have a look at http://doc.qt.nokia.com/qtcreator-2.2/creator-project-qmake-libraries.html
Those are header files, not the library itself. For a library, you should have source files in C or C++. If the source is not available, you should be provided object files or library file(s).

Also, there is a change that you are trying to use a library which is supplied not through the static library file, bit as an executable file called shared library or dynamic-link library. In this case, you will also need this library during run-time. The methods of linking this library can be different. It can be definition file, a special static link library containing binding code and being used by a linker (please see below) and more.

If you are given the source code, you should include it in your compilation. If you are given object or library files, you should reference the in the parameter of your linker. In both cases, it can be added to your make file and/or your project file (for example, the files accepted by MSBuild). If you are using some IDE, you will probably find appropriate options which let you to add the library in your project(s) and/or solution.

You did not share what development environment you are using, so find out it by yourself. This is not the biggest problem. What concerns me more, from your question I suspect you don't clearly understand compilation and linking phases of the software builds. This is where you may need some education:

http://en.wikipedia.org/wiki/Compiler[^],
http://en.wikipedia.org/wiki/Compiled_language[^],
http://en.wikipedia.org/wiki/Linker_%28computing%29[^],
http://en.wikipedia.org/wiki/Include_file[^],
http://en.wikipedia.org/wiki/Object_file[^],
http://en.wikipedia.org/wiki/Dynamic-link_library[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 22-Jan-12 16:34pm    
5'ed - it will get him started
Sergey Alexandrovich Kryukov 22-Jan-12 17:15pm    
Hope so.

Thank you, Espen.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900