This is the mail archive of the cygwin@cygwin.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]
Other format: [Raw text]

Re: DLL Linking Problem


Niraj schrieb:

[dll problems with simple dll]

Your example is not simple, see this really simple example:

TestDll.c:
==========
#include <stdio.h>
void  printVal()
{
        printf("Hello World!");
}

TestDll.h:
==========
void printVal();

testmain.c:
===========
#include "TestDll.h"
int main()
{
        printVal();
        return 1;
}


$ gcc -c TestDll.c -o TestDll.o

$ gcc -shared -o cygTestDll.dll \
      -Wl,--out-implib=libTestDll.dll.a \
      -Wl,--export-all-symbols \
      -Wl,--enable-auto-import \
      -Wl,--whole-archive TestDll.o \
      -Wl,--no-whole-archive
Creating library file: libTestDll.dll.a

$ gcc -o testmain testmain.c -L. -lTestDll

$ ./testmain
Hello World!


Gerrit
-- 
=^..^=

Attachment: testmain.c
Description: Text document

Attachment: TestDll.h
Description: Text document

Attachment: TestDll.c
Description: Text document

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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