Hey guys,

I am trying to implement something in VC++ and have to use a library for this purpose. This library is in C++ and the authors have provided a seperate download for VC++

How exactly do I use the functions provided in this library in my own code? They have provided all the source and header files but at the same time, a object file library, is also present in the same folder.

Do I need to included this object file library direclty in my VC++ project, or do I need to make a new one using all the source and header files provided?

The library can be found here..

http://crypto.stanford.edu/pbc/download.html


Regards,

Abhi

Usually libraries will come with a .lib or .dll file that you can link with, and headers for compiling. But if you have all of the source, you might be able to build it all fresh too.

Hey Tom,

Yes. Your are right. Authors have provided a separate download for windows binaries and it contains the .dll and .lib files..

How do I add them in VC++ ( VS 2005)

Regards,

Abhijit

In your project properties there is a linker tab. You can specify libraries and directories there.

Hi Tom,

I did that. Tested building it.. and it worked fine..

how do I call the functions in the DLL?

the name is pbc.dll...
can u explain a little on this?

Here is a tutorial on DLLs. It includes writing them, but the part on explicit linking is the one that shows how to load one. You can read more about LoadLibrary here.

commented: Helped a lot. Thanks +1

Hi Tom,

Thanks a ton for this wonderful link. I tried both the methods, implicit as well as explicit and now understand the concept of DLL's better. :)

I have couple of more questions for you..

First of all, how different is your method from P/Invoke, which is also used to call functions in dll's.

Also, is it necessary, that if someone has published a dll/lib for a library, it will contain all the functions defined in their source code..
what if some functions are not exported.... will I still be able to use them?


Many thanks for your time..

Regards,

Abhi

First of all, how different is your method from P/Invoke, which is also used to call functions in dll's.

P/Invoke is a way to access unmanaged COM DLLs from managed code. The implicit and explicit linking you read about in the tutorial were strictly unmanaged methods. The only way you can use P/Invoke, AFAIK, is to jump into C++/CLI, which is technically a different language from standard C++.

what if some functions are not exported.... will I still be able to use them?

Officially, as good little programmers we are not allowed to use functions that were not exported. Unofficially, we can do anything well damn well please given sufficient knowledge of the file formats. But circumventing the rules is tricky and complex. For example, signature scanning is one way to find and use functions that are not part of the export table in a DLL or executable.

There are lots of reasons why you do not want to do that. First and foremost is versioning. Unexported functions are not bound by the interface and can change or go away entirely between versions of a DLL. It is the same as circumventing the access restrictions in C++ to get at a class' private methods.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.