digitalmars.D.learn - linking with a C library
- Oliver (10/10) May 11 2005 Hello !
- Andrew Fedoniouk (11/24) May 11 2005 As usual with C/C++
- Dejan Lekic (6/7) May 11 2005 Does it work on LINUX too?
- Walter (3/5) May 11 2005 Not yet.
- Lukas Pinkowski (12/29) May 11 2005 First of all:
- Oliver (8/18) May 11 2005 I did the following :dmd -d boing.d -L-lglfw
Hello ! I want to use a C library lib*.a that has been compiled with gcc I have 3 D-modules that declare all the functions in the library like this : version(Linux) { extern(C): } ..List of data types and functions .... How do I compile and link if I want to make use of the library ? regards, oliver
May 11 2005
I want to use a C library lib*.a that has been compiled with gcc... How do I compile and link if I want to make use of the library ?As usual with C/C++ 1) compile your library. 2) Link it in your D project using command line parameters or 3) use pragma(lib) in D source code: pragma(lib, "imageio.lib"); Example: http://www.terrainformatica.com/harmonia/imageio.d.zip ( DecodeImage using standard libPNG and libJPEG in D ) Andrew. "Oliver" <Oliver_member pathlink.com> wrote in message news:d5t652$141g$1 digitaldaemon.com...Hello ! I want to use a C library lib*.a that has been compiled with gcc I have 3 D-modules that declare all the functions in the library like this : version(Linux) { extern(C): } ..List of data types and functions .... How do I compile and link if I want to make use of the library ? regards, oliver
May 11 2005
3) use pragma(lib) in D source code:Does it work on LINUX too? -- ........... Dejan Lekic http://dejan.lekic.org
May 11 2005
"Dejan Lekic" <leka entropy.tmok.com> wrote in message news:d5tfic$1bqo$1 digitaldaemon.com...Not yet.3) use pragma(lib) in D source code:Does it work on LINUX too?
May 11 2005
Oliver wrote:Hello ! I want to use a C library lib*.a that has been compiled with gcc I have 3 D-modules that declare all the functions in the library like this : version(Linux) { extern(C): } ..List of data types and functions .... How do I compile and link if I want to make use of the library ? regards, oliverFirst of all: Do not compile the modules with the C-declarations! There are basically two possibilities: dmd yourapp.d ... -L-lyourlib This will call gcc automagically, and link with libyourlib.a, (the dots are your other object files) or dmd -c yourapp.d gcc -o yourapp yourapp.o ... -lphobos -lyourlib kind regards, Lukas
May 11 2005
In article <d5t652$141g$1 digitaldaemon.com>, Oliver says...Hello ! I want to use a C library lib*.a that has been compiled with gcc I have 3 D-modules that declare all the functions in the library like this : version(Linux) { extern(C): } ..List of data types and functions .... How do I compile and link if I want to make use of the library ? regards, oliverI did the following :dmd -d boing.d -L-lglfw But I should have done it this way : dmd -d boing.d -L-lglfw -L-lglib -L-lglut -L-lXxf86vm Because the other libs are required by glfw !? That took quite some time - THX for all the answers regards, Oliver
May 11 2005