X-Spam-Check-By: sourceware.org Message-ID: <507150040705021415r750600a6oc6e24b339bf57143@mail.gmail.com> Date: Wed, 2 May 2007 14:15:49 -0700 From: "kalasad mailu" To: cygwin AT cygwin DOT com Subject: Please Help!! Calling Socket function in a dll file (that is created using cygwin library), by a Microsoft Visual C++ program resulting in infinite loop MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com I am trying hard to get this stuff working!!!!!! Could you please help me. I created a dll file (test.dll), which contains the function that creates a socket and return the success/failure status. This file uses the socket.h provided by cygwin. I compiled this dll using gcc on cygwin. I also created a library file(testdll.lib) from this dll(test.dll). When I tried to call the function defined in the test.dll in a program (written in Microsoft Visual C++), this enters (that is created using cygwin library), by a Microsoft Visual C++ program rean infinite loop. The same program works fine if I call getuid or random function instead of socket. And the stack is as below. I would really appreciate if I can get some suggestions on how to get this working. Call Stack (from my MSVC++ program): ntdll.dll!7c90eb94() ntdll.dll!7c90ea53() kernel32.dll!7c832998() cygwin1.dll!61058235() cygwin1.dll!61092daf() new3.exe!main() Line 6 + 0x8 C++ new3.exe!mainCRTStartup() Line 259 + 0x19 C kernel32.dll!7c816fd7() ntdll.dll!7c915b4f() test.cpp (uses the socket.h from cygwin and compiled using gcc) #include #include #define SOCKETTEST_BUILD_DLL #include "test.h" DLL_IMPORT_EXPORT int createSocket() { int s; s= socket(PF_INET, SOCK_DGRAM,17 ); return s; } test.h #ifdef SOCKETTEST_BUILD_DLL #define DLL_IMPORT_EXPORT __declspec(dllexport) #else #define DLL_IMPORT_EXPORT __declspec(dllimport) #endif extern "C" { DLL_IMPORT_EXPORT int createSocket(); } My MSVC++ program calling this dll: #include #include "test.h" #include void main(){ int s=createSocket(); printf("the value returned is %d", s); Sleep(5000); } The command I used to create the dll file in cygwin: gcc -shared -I ../../cygwin/usr/include/cygwin -o testdll.dll test.cpp -Wl,--output-def,testdll.def,--out-implib,libtestdll.a Command used to create the library file: "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\lib" /machine:i386 /DEF:testdll.def -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/