This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: building a DLL


> For me, step 2 fails with "dlltool: Can't open def file: libt.def".
> 
> Was step 1 supposed to produce this file? It didn't give an error. It
> didn't even give a non-zero exit value.

Sorry, I was being stupid. It seems to work now. For the benefit of
anyone else, here's what I did.

To make a library out of t.c and link p.c with it:

$ gcc -c t.c
$ echo -e "EXPORTS\nfoo" > libt.def
$ gcc -s -Wl,--base-file,libt.base -o libt.dll t.o -Wl,-e,_libt_init@12
$ dlltool --base-file libt.base --def libt.def --output-exp libt.exp --dllname libt.dll
$ gcc -s -Wl,--base-file,libt.base,libt.exp -o libt.dll t.o -Wl,-e,_libt_init@12
$ dlltool --base-file libt.base --def libt.def --output-exp libt.exp --dllname libt.dll
$ gcc -Wl,libt.exp -o libt.dll t.o -Wl,-e,_libt_init@12
$ dlltool --def libt.def --dllname libt.dll --output-lib libt.a
$ gcc -c p.c
$ gcc -o p p.o libt.a

Apart from the function foo, t.c also contains the following:

__declspec(dllexport) int foo(int);

#include <windows.h>
int WINAPI libt_init(HANDLE h, DWORD reason, void *q)
{
  return 1;
}

int main()
{
  return 0;
}

Now to try building a real DLL out of source code in Prolog ...

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]