Compiling DLL's

This is a discussion on Compiling DLL's within the C++ Programming forums, part of the General Programming Boards category; As a middle-aged Delphi programmer who has been programming in Pascal for nearly a quarter of a century, I don't ...

Compiling DLL's

As a middle-aged Delphi programmer who has been programming in Pascal for nearly a quarter of a century, I don't know a thing about C.

I have the source code for a DLL and someone has offered to supply some modifications to the source to add some extra functions. However, these modifications will be in C - which as I said I know absolutely nothing about.

What do I need to be able to re-compile the DLL? Are there any free compilers which will do this? What files do I need to have with regards to the DLL source code? I have .C, .H, .DEF and .RC files, but not knowing what they are, I don't know what actually should be there.

Learning a new language like C from scratch isn't viable when you are closer to 50 years old than 40, so I'm hoping someone on here will take pity and help guide me through the process.

As a Delphi programmer, I'm hoping not to be treated as an 'enemy in the camp'. I'm not here to claim that Delphi is better than C or anything like that - it isn't. I just use Delphi because of my background in Pascal, so please don't flame the hell out of me.

C is an excellent language and it's programmers are extremely talented. I'm hoping someone out there is able to help.

I myself have not DLL's before either, but I've been doing the C-languages for some time.

Now of course they may actually be in every DLL, but those file extensions look suspiciously like files I've seen in Borland Compilers. Borland Compilers are pretty good - they're well known, and having done Delphi there's a pretty good chance you've used them too. Go to their website (www.borland.com I believe), and have a look. I've heard that they do have a free IDE (C++Builder) available for download from their website, but I'm afraid I can't confirm this.

Dev-C++ (free download - only a few MB) is a very popular compiler, and it too does DLL's - the only reason I mention Borland is because I know I've seen those file types in my Borland Compiler.

edit: to answer your other questions, all you need is a compiler. You can do DLL's as a project type, just like you would a Windows Application. You tell it to start a new project, it'll give you some options, and if you select DLL, it'll get some more information from you and then set up all the necessary files. When it comes time to compile, it'll know you want it in DLL form. A DLL is basically just a library of code that's partially compiled that you can use in other programs - so all you really need is a source file, but you can have other things in there too. the *.rc file contains resources - usually the data for windows forms, etc... for example.

I'd try to find out what compiler is being used by the guy whos writing the extra code for you. Some features may differ between compilers when it comes to dlls. For instance the RC file relates to a resource script - some tools come with different resource compilers.

You might be alright, but I'd want to know what the original tools were - could save you difficulty in the future.

Thanks for the replies everyone. Having received a helpful response, I'll offer a bit more info...

Sean:

I wasn't sure if the extensions I quoted were compiler-specific or not. Having not used one, I had thoughts of different compilers generating different filetypes other than .c and .h but hoped that source from any C/C++ IDE could be compiled by any other. I guess from your comments that this *may* be so, but I've taken on board Fordy's comments warning that there might be issues.

Fordy:

The 'other guy' isn't writing any code for me. To the best of my knowledge, he will only be telling me what I need to do on top of what the DLL already does. This may or may not include some C source code.

The AKRip DLL grabs data off audio CD's to WAV files, but he says he will tell me how to grab the sub-code CDG data as well.

manofsteel972:

Thanks for the links, but I don't need to convert any of the code to Pascal - I'm already using the DLL from within Delphi. What I need to do is modify some C code within the DLL and compile it back into a DLL.

Although I have someone who can tell me what is involved, unfortunately, pressure of work does not allow him the time to assist me any further than that, though he did supply me with a link to the DLL along with all it's source code.

The DLL itself is Andy Key's AKRip.DLL, which is open source and distributed under Gnu LGPL which will be fully adhered to.

Unfortunately, it's unlikely that I will be able to find out which exact compiler was used to write it, (my e-mail to Andy Key was returned as undeliverable), but if anyone needs any further info, I'd be only too happy to e-mail a list of the files and any other info.

A few more comments:

You need a Windows compiler... a compiler that makes Windows programs. (Microsoft didn't invent invent dynamic linking, but .dll files are for Windows.) The compiler will have an option to "Compile as DLL".

but I'd want to know what the original tools were

RIGHT! If the source file uses only standard-portable C++, and standard Windows library functions, then any Windows compiler should work. But, the source file may contain some compiler-specific stuff. The Dev-C++ (aka Bloodshed) IDE, recommended above by sean_mackrory, uses the Mingw compiler, so that should be an excellent choice.

Sorry for the delay in getting back - I've been waiting for the e-mail detailing what needs to be done.

The info I now have is very short and *looks* very simple - if you know what you are doing - which I don't!

I basically need to alter the dll so that it also grabs subcode data. Although doing this looks very simple in the e-mail, my lack of skills in the subject leads me to think that it would be better done by someone who knows what they are doing.

For one, I don't know what tools I would need. I've downloaded freecommandlinetools.exe from the Borland web site on which it says that it is a C compiler, but from what I've read above, it may not be what I need.

Secondly, although the alterations are only tiny, am I right in thinking that once applied, then the modified dll function in question would stop working as it did before and that I would need to use both the ammended *and* the original dll? If so, then I think that another function would need to be added to the dll - once again, well above my abilities.

Would anyone with a compatible compiler (and the necessary experience) be willing to have a crack at it for me please? If so, I will post my e-mail address (if that is allowed) and happily share the info with anyone who contacts me.

For anyone tempted to assist, but think they don't have enough time, can I just say that the info I have says that the modifications required are no more than changing two values - the buffer size and a flag.

This should take a mere few minutes to do if you know what you are doing. I now have a compiler which I believe is compatible and will have a go myself.