delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Date: | Fri, 11 Mar 2005 18:33:51 -0800 (PST) |
Message-Id: | <200503120233.j2C2Xpgg019551@syrphus.ucdavis.edu> |
To: | cygwin AT cygwin DOT com |
Subject: | build an executable with .lib created by vc |
From: | "Yu-Cheng Chou" <cycchou AT ucdavis DOT edu> |
X-Errors-To: | cycchou AT magenta DOT ucdavis DOT edu |
X-User-Agent: | Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322) |
Hi, I have a test1.lib created by the microsoft visual c++ compiler. test1.lib contains only one function test1(), which prints out "Hello from test1". The other file I have is main.c, which prints out "Call Test1", call test1 () and prints out "Return Test1". --------------------------------------------------------------------------- /* test1.c */ #include <stdio.h> __declspec(dllexport) void test1(void) { printf("Hello from test1()\n"); } --------------------------------------------------------------------------- #Makefile for creating test1.lib target: test1.dll test1.dll: cl -c /MD test1.c link /out:test1.dll /DLL test1.obj clean: rm -rf test1.dll test1.obj test1.lib --------------------------------------------------------------------------- /* main.c */ #include <stdio.h> int main() { printf("Call Test1\n"); test1(); printf("Return Test1\n"); return 0; } --------------------------------------------------------------------------- #Makefile for creating main.exe in cygwin using mingw libraries and headers target: main.exe main.exe: main.o test1.lib gcc -mno-cygwin -o main.exe main.o test1.lib main.o: main.c gcc -mno-cygwin -c main.c clean: rm -rf main.exe *.o --------------------------------------------------------------------------- output: $ ./main.exe Call Test1 Return Test1 Hello from test1() --------------------------------------------------------------------------- "Hello from test1()" should be between "Call Test1" and "Return Test1". In the first makefile, I use /MD option to link with MSVCRT.LIB. But in the second makefile used in cygwin, I have no idea how to correctly link with MSVCRT.LIB using gcc -mno-cygwin. So, is that the reason why the output order is incorrect? And how to link with MSVCRT.LIB correctly in cygwin using gcc or gcc -mno- cygwin? Thanks -- 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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |