delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <89c3ea2b0612161003t495bc89dk9473d13d00c9220e@mail.gmail.com> |
Date: | Sat, 16 Dec 2006 13:03:53 -0500 |
From: | "andy wang" <ypwangreg AT gmail DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: how to compile the .so to allow extern functions |
In-Reply-To: | <89c3ea2b0612160805w5d83e536o510f2f0a1317e77d@mail.gmail.com> |
MIME-Version: | 1.0 |
References: | <89c3ea2b0612152114u5150ecfara058c41a00a70dac AT mail DOT gmail DOT com> <45838A0F DOT 82A8B52B AT dessent DOT net> <89c3ea2b0612160805w5d83e536o510f2f0a1317e77d AT mail DOT gmail DOT com> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
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 |
Done:-), thank Brain for the help! $ cat bug1.c //this will be .so and will call an extern func1() in the main proc int func1(); int myfunc() { printf("in myfunc.so\n"); func1(); } $ cat bug1-main.c #include <dlfcn.h> int func1() { printf("in main.func1()\n"); return 0; } int main() { int (*mf)(); void *handle = dlopen("bug1.so", RTLD_LAZY); if(handle) { mf = dlsym(handle, "myfunc"); if(mf) mf(); dlclose(handle); } return 0; } $ gcc -shared -o bug1-main.so bug1-main.c -ldl -Wl,--out-implib=libmain.dll.a Creating library file: libmain.dll.a $ gcc -shared -o bug1.so bug1.c -L. -lmain $ gcc -o bug1-main bug1-main.c -ldl $ ./bug1-main.exe in myfunc.so in main.func1() Regards, Andy -- 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 |