Subject: Re: Problem with dlopen
From: "Frank Motta" <[email-masked]>
To: <[email-masked]>
Cc: <[email-masked]>
Date: Fri, 5 Apr 2002 14:31:50 -0800 (PST)

Thanks Larry,
    As a result of your response I made a -very- truncated version and got
past the dlopen error.

    The problem seems to be in the -creation- of the dll.

    the instructions at http://cygwin.com/cygwin-ug-net/dll.html result in
many link-time errors and the method I -was- using (see below) does not
export the symbol I need.

    Any ideas?

from makefile clip 8<-----------------------------
# This creates a dll without the exports I need - see def below
TARGET=simpletest
DLL_SUFF=.dll
LIB_SUFF=.a
DLL_EXP_LIB =$(TARGET)$(DLL_SUFF)$(LIB_SUFF)
DLL_NAME=$(TARGET)$(DLL_SUFF)
INCLUDE=

simpletest.dll: Makefile simpletest.o
        gcc -shared -Wl,--out-implib=$(DLL_EXP_LIB) -o $(DLL_NAME)
$(DLL_OBJS) $
(DLL_LDFLAGS) $(DLL_LDLIBS) -Wl,--export-all
        dlltool --def simpletest.def --dllname simpletest.dll --output-lib
simpl
etest.a

simpletest.o: simpletest.c ../../modules.h ../../global.h ../../types.h
        $(CC) $(INCLUDE) -c simpletest.c

------------------------------------- >8 clip makefile

from test.def clip 8< ----------------------------------------
EXPORTS
mod_import
------------------------------------ >8 clip test.def

from simpltest.c 8< ---------------------------------------------------

void *foo();
void *(*export_foo)() = foo;
void *mod_import(char **argv) {
   return export_foo;
}

char *hello = "hello world";
void *foo() {
        return (void *) hello;
}
------------------------------------ >8 clip test.c
from nm simpletest.dll | grep T clip 8< ------------------------------
100010f4 T _DllMain@12
100012a4 T _GetModuleHandleA@4
100012ac T __CTOR_LIST__
100012b4 T __DTOR_LIST__
100012ac T ___CTOR_LIST__
100012b4 T ___DTOR_LIST__
1000113c T __cygwin_crt0_common@8
10001024 T __cygwin_dll_entry@12
100010d4 T __cygwin_noncygwin_dll_entry@12
10001000 T __end__
1000125c T _calloc
1000110c T _cygwin_attach_dll
10001104 T _cygwin_detach_dll
1000129c T _cygwin_internal
10001294 T _cygwin_premain0
1000128c T _cygwin_premain1
10001284 T _cygwin_premain2
1000127c T _cygwin_premain3
10001254 T _dll_dllcrt0
10001000 T _end
1000126c T _free
10001274 T _malloc
10001264 T _realloc
10001000 T end
100012bc T etext
--------------------------------------------- >8 nm output

Notice the -lack- of mod_import!!!

Thanks !!!!

<Larry Hall (RFK Partners, Inc)>
> At 02:51 PM 4/5/2002, Frank Motta wrote:
>>The following code returns Win32 error 126 - this is the same error I get
if I try a file which does not exist.
>>
>>What is going wrong (operator malfunction - I'm sure!)
>>please help
>>             strncat(mod_file_name, LIB_EXT, LIB_EXT_LEN + 1);
>>             // FJM handle = dlopen(mod_file_name, (RTLD_NOW |
>>             RTLD_GLOBAL)); handle = dlopen(mod_file_name,
>>             (DLOPEN_MODE));
>>             if ((err = dlerror()) == NULL) { break; }
>
>
> $ net helpmsg 126
> The specified module could not be found.
>
> With the information you've given, one can only say mod_file_name is not
where you say it is.  If that's the issue, it's not a Cygwin problem and
would be off-topic for this list.  If that's not the problem, you'll need
to provide more information about the specifics.  Results from debugging
into Cygwin or even output from running your program under strace would be
useful to further any pertinent
> discussion.
>
>
>
> Larry Hall                              [email-masked]
> RFK Partners, Inc.                      http://www.rfk.com
> 838 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX

-- 
Frank Motta
[email-masked]

If you cannot recognize divinity in your fellow man, then you will not
realize the devine within yourself...

--
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/