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!

link lib file 2

Status
Not open for further replies.

abcd12344445555

Programmer
May 10, 2009
24
BR
How do I link a lib file to my project?
Where do I set the path to the lib file?

Thanks,
Best regards.
Paul.
 
I know of two basic methods to link to a *.lib file. For both options you have to add to either your *.cpp file or your *.h (preferable) the #include statement for the header file.

Code:
#include "..\Function Collection\visa.h"

1.) In the IDE, click "Project"|"Add to Project..."
2.) In the "Add to Project" OpenDialog window, change the "File type" to "Library File (*.lib)"
3.) Specify the *.lib file and click "Open"

The other method is to include in the header file using a #pragma statement:

Code:
#pragma comment(lib, "C:\Documents and Settings\stemay\My Documents\Programs\Function Collection\visa32.lib")

I usually employ the first method unless I am building a wrapper class to conveniently use the functions made available by the *.lib.

Steve.
 
Thanks Steve, but how about the dll? do I have to include it somewhere? Maybe set a path?
I've put the dll in the same project's folder, but the linker cannot find it.
Every time I run I got a message of missing dll.

Thanks again,
Best Regards,
Paul.
 
Which version of C++ Builder you are using? Because there are quite some differences.
 
Ensure you've checked the properties in Tools/Option/C++ option/path and Diredtories and ../Project Properties.

C++ Builder 2007 can make it very easy for you if Include Path is checked in Tools/Option/C++ option/Project Properties, which is the default option.

You need to install your dll.
Component/Import component/Active X. then click next and follow the instructions.

C++Builder 2007 will do almost all the work for you. Version 2007 has many enhancements in comparison with earlier versions.

The error Cannot find it also means that the Dll isn't install correct. Uncheck the option during the installation of the dll: "link with rtl" almost always solve this problem.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top