X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org From: Martin Henne To: cygwin AT cygwin DOT com Subject: build DLL that can be used by MinGW Date: Mon, 8 Feb 2010 09:50:14 +0100 User-Agent: KMail/1.12.4 (Linux/2.6.31-19-generic; KDE/4.3.5; i686; ; ) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201002080950.14971.martin.henne@web.de> X-Sender: martin DOT henne AT web DOT de 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 Hello, I try to produce a DLL on cygwin, that can be linked against a MinGW compiled program. To test with a simple example I tried the following code: // dllfunc.h extern "C" { extern void sayhello(); extern int sumint(int a, int b); } // dllfunc.cpp #include extern "C" { void sayhello() { std::cout << "I am saying hello" << std::endl; } int sumint(int a, int b) { return a+b; } } // main.cpp #include #include "dllfunc.h" int main() { std::cout << "1" << std::endl; std::cout << sumint(3,39) << std::endl; std::cout << "2" << std::endl; sayhello(); std::cout << "3" << std::endl; } Then I created the dll (within cygwin): $> g++ -shared dllfunc.cpp -o dllfunc.dll Then I created the application (using MinGW) $> g++ main.cpp -L. -ldllfunc When I start this MinGW-Application, the call output is as follows: 1 42 2 Then it aborts. That means, that the call to 'sumint()' whithin the dll works, while the call to 'sayhello()' wont. The crash occurs when using 'std::cout'. If I compile and create the dll and the application within cygwin it works: 1 42 2 I am saying hello 3 If I compile both using MinGW it works, too. If I compile the DLL on MinGW and the application on cygwin, it works as well. But I need to compile the DLL on cygwin and the rest on MinGW, and this does not work. The reason is, that I need a dll that uses the cygwin-posix-layer. What can I do? Thank you in advance... Martin -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple