Wednesday, April 28, 2010


If you're working with Borland C++ Builder compiler and you want to use functions from a DLL file, usually you have to make a library file first. Otherwise your compiler will produce an error message showing that there's an error in linking with the library. Something like this:

[Linker Error] Unresolved external 'name_of_the_function_from_the_library' referenced from E:\TEST\MAINFORM.OBJ

Then in order to resolve this problem, you need to build a library that is suitable with your compiler. Most of the library files shipped with the product are made for Microsoft's compiler, so you need to make some modification to the library file.

These are some possible steps that you need to do before using the library/dll file:
1. If you have the library file for Microsoft Visual C++, then you have to convert it into Borland C++ Builder library by using 'coff2omf' command line program.

example: coff2omf cv.lib cv2.lib

2. If you have the dll file together with the header file and you have to generate the library file by yourself, you have to use 'implib' command line program.

example: implib -a fftw3-3.lib libfftw3-3.dll

These programs are provided by Borland C++ Builder, you can find them in the installation directory. For example, mine is in "C:\Program Files\Borland\CBuilder6\Bin" and it depends on where you installed your compiler, they will be available in the Bin\ directory. My compiler is a rather old compiler because I'm having difficulties in upgrading to newer version. Some of my hardwre doesn't support the new C++ Builder version. So I stick with this version.

Hope this tip will be useful for you. It works with me, so if it doesn't apply to your situation, just let me know. I might be able to explain what's wrong.

Good luck!

Labels: , ,


Post a Comment

<< Home