Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Message-ID: <3E21C7DD.8020908@watsen.net> Date: Sun, 12 Jan 2003 11:54:05 -0800 From: Kent Watsen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: static libs imported into DSO? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi all, I have simple application that I want to link a plugin into. The intent is for the plugin the use the same libraries linked into the main app, but instead the plugin is linking in its own copy! This code works as expected using gcc on OpenBSD. What am I doing wrong? Can I tell the linker to ignore unresolved symbols and rld will be ok? $ uname -a CYGWIN_NT-5.1 1.3.10(0.51/3/2) 2002-02-25 i686 $ gcc -v gcc version 2.95.3-5 (cygwin special) staticlib.h ----------- void setVal(int val); int getVal(void); staticlib.c ----------- static int VAL = -1; void setVal(int val) { VAL = val; } int getVal(void) { return VAL; } dynamiclib.c ------------ #include "staticlib.h" void foo(void) { printf("val = %d\n", getVal()); } main.c ------ #include "staticlib.h" typedef void Func(void); int main(void) { int dl; Func* func; int result; setVal(5); printf("val = %d\n", getVal()); dl = dlopen("./dynamiclib.so"); if (dl == 0) { printf("dlopen failed\n"); return 1; } func = (Func*)dlsym(dl, "foo"); if (func == 0) { printf("dlsym failed\n"); return 1; } func(); result = dlclose(dl); if (result != 0) { printf("dlclose failed\n"); return 1; } return 0; } $ gcc -c staticlib.c $ gcc main.c staticlib.o $ gcc -shared dynamiclib.c staticlib.o -o dynamiclib.so ^^^^^^^^^^^ else undefined ref ---^ $ ./a.exe val = 5 val = -1 <---- THIS SHOULD HAVE BEEN 5! -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/