Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Header to LIB ...

Status
Not open for further replies.

HadiRezaee

Technical User
Mar 9, 2001
165
IR
Hi all,
I wrote some functions in my header file,
I wanna create .LIB file of my header file, How can i do that ?
Thanks for all helps ...
 
Lib files is created automatically in oyur debug/release folders ONLY if you have at least one exported function(That means prefixed with __declspec(dllexport).

If you do not use a .def file for the exported functions you have to take care to the name mangling of your exported functions.

Hope this helps, HTH s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Thank you for your reply ...
I have other question,
If i defined class in LIB ...
I must first link .LIB to my project ...
Then i'll can use of class in .LIB ...
And i don't need to any otherthings ..
Is it true ???

 
If you want to export an entire class to a lib/dll file you have to put AFX_EXT_CLASS before class declaration like:
class AFX_EXT_CLASS CMyClass.

However exported classes can be used only inside the same compiler that exportde it(it means that if you export some class to a .lib file from VC++ you won't be able to import it in Borland C++)

You will have to include de .h generated file in your target aplication. the lib file you include form ProjectSettings->Link->Object/modules in VC++.

Also, with the line in stdafx.h:
#pragma comment( lib, "mylib" ) //without .lib suffix

HTH, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Hi,
Thanks for nice reply ... ;)
I have two other questions:

1- What does it mean: #progma comment(lib, "mylib")
2- Please explain, How can i wanna import my DLL to my project ... and how can i use of that ?
i must define .h to my project again ?
 
--hadi
the .h and.lib files work together like this: .h keeps the declarations from your function (you have to #include it) and the .lib files keeps the implementations(from all .cpp files involved)

#pragma comment(lib, "mylib") is a linker directive which instructs the compiler to include the specified .lib file in the linkage process.(it is echvalent with including it with ProjectSettings->Link->Object/modules)

You don't need to redefine your .h again. Just call directly to the functions from your dll, with the same parameter type and return variable type.

Anyway you have to read a little from MSDN to get a better grasp on it. see also the dllhusk sample from MSDN samples.

HTH,
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Can i use of #import function for importing .DLL file to my project ?

What is .DEF file ?
 
#import - no
".DEF files" - look for this topic in MSDN index. There is everything you need.
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top