digitalmars.D.learn - linking in static c library
- akcom (1/1) Mar 16 2008 I've got some cipher/hashing routines (AES, RSA, and SHA256, not that it...
- torhu (14/15) Mar 16 2008 Yes, you need to use dmc. msvc uses a different object file format.
- bearophile (4/5) Mar 17 2008 I think you may be ignorant about this matter, but I don't think you are...
I've got some cipher/hashing routines (AES, RSA, and SHA256, not that it matters) that are written C. I'd like to compile them into a static library so that I can basically wrap it in D bindings and use it in my application. Feel free to correct me if I'm wrong, but I'm under the impression that I must compile my C static library with the digitalmars C compiler. Unfortunately having come from Visual C++ 6.0, I'm not very well adept at console compiling/linking. I feel quite stupid asking this, but could someone explain to me how I can build a static library in C that can be used in a D project?
Mar 16 2008
akcom wrote:I've got some cipher/hashing routines (AES, RSA, and SHA256, not that it matters) that are written C. I'd like to compile them into a static library so that I can basically wrap it in D bindings and use it in my application. Feel free to correct me if I'm wrong, but I'm under the impression that I must compile my C static library with the digitalmars C compiler. Unfortunately having come from Visual C++ 6.0, I'm not very well adept at console compiling/linking. I feel quite stupid asking this, but could someone explain to me how I can build a static library in C that can be used in a D project?Yes, you need to use dmc. msvc uses a different object file format. You compile the files with dmc, then use the lib tool if you want to collect in a static link library. A static link library is really just an archive of object files, with an index telling the linker which object file contains which symbols. Here are some sample command lines: dmc -c file1.c file2.c lib -c mylib file1 file2 Then you can do: dmd myapp mylib.lib And it'll be like linking with file1.obj and file2.obj. docs for lib: http://www.digitalmars.com/ctg/lib.html
Mar 16 2008
akcom:Unfortunately having come from Visual C++ 6.0, I'm not very well adept at console compiling/linking. I feel quite stupid asking this, butI think you may be ignorant about this matter, but I don't think you are stupid. Stupid people are the ones that don't want to learn, etc. Bye, bearophile
Mar 17 2008