This is the mail archive of the 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]

dlltool & link to VC++ generated DLL

I am reasonably unknowledgable about CYGWIN and anything to do with a UNIX
type environment, and only average over on the Microsoft side of things.
That being said, here is my problem:

1. I have a MS VC++ generated DLL, MYDLL, that has a shared memory area that
is use to share data between 2 applications.

2. There are 2 functions that I am calling in MYDLL, Set_Status_Nav and

3. App1, which happens to be a VB program, calls the above 2 functions all
the time, no problem.

4. Someone else developed App2. It was done on a UNIX system and rehosted
under W2000 using CYGWIN. It works just fine.

5. I need to communicate between App1 and App2 via the above mentioned DLL
shared memory area.

6. By reading thru the CYGWIN documentation, I stumbled upon the following:

Linking Against DLLs
If you have an existing DLL already, you need to build a Cygwin-compatible
import library (The supplied ones should work, but you might not have them)
to link against. Unfortunately, there is not yet any tool to do this
automatically. However, you can get most of the way by creating a .def file
with these commands (you might need to do this in bash for the quoting to
work correctly):
echo EXPORTS > foo.defnm foo.dll | grep ' T _' | sed 's/.* T _//' >> foo.def
Note that this will only work if the DLL is not stripped. Otherwise you will
get an error message: "No symbols in foo.dll".
Once you have the .def file, you can create an import library from it like
dlltool --def foo.def --dllname foo.dll --output-lib foo.a

7. I  skipped the "echo EXPORTS ..." part and just built my own .def file,
MYDLL.def. See below:



8. I started up the CYGWIN environment, found my way down to where the other
guy had his makefile, and did the building of his App2.

9. Running the makefile and executing App2 was no problem, and works just

10. I added references to Set_Status_Nav and Get_Status_Nav in one of his
modules, and wrote a little code to call them:

   struct        NAV_STAT_MSG statMsg = {0};

   extern int  Get_Status_Nav (struct NAV_STAT_MSG* m);
   extern int  Set_Status_Nav (struct NAV_STAT_MSG* m);



11. The command line to invoke dlltool is:

dlltool --def MYDLL.def --dllname MYDLL.dll --output-lib MYDLL.a

12. The above command line appears to work OK. When I run "nm MYDLL.a" under
CYGWIN I see the entry point names

13. I included MYDLL.a in the makefile and invoked the makefile. It appears
to work OK in that it processes MYDLL.a with no complaints

14. HOWEVER, when I execute App2 it tells me that it cannot find

15. I tried commenting out the function call to Set_Status_Nav and rebuilt
everything. It then tells me that it cannot find Get_Status_Nav when I try
to execute App2.

16. Here is the really awful part - ALL OF THIS HAS WORKED BEFORE!
         - When I first stumbled upon "dlltool" I just followed the example,
and everything worked
         - I built App2, executed it, it made the functions calls, etc, etc,

17. I am now very confused and frustrated

18. Any suggestions would be greatly appreciated


Want to unsubscribe from this list?
Check out:

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