delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/04/10/02:04:12

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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: Thu, 10 Apr 2003 02:03:38 -0400
From: Lester Ingber <ingber AT ingber DOT com>
To: cygwin AT cygwin DOT com
Subject: -mno-cygwin and "undefined reference to `_impure_ptr'"?
Message-ID: <20030410060338.GA344@ingber.com>
Reply-To: Lester Ingber <ingber AT ingber DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.4i
X-URL-ALT: http://www.alumni.caltech.edu/~ingber/

I've built a simple DLL as instructed in the user's guide, which
works fine using:

set module = mydll
gcc -c ${module}.c
set old_lib = ${module}.o
set dependency_libs = '-lm'
gcc -shared -o ${module}.dll \
    -Wl,--out-implib=lib${module}.dll.a \
    -Wl,--export-all-symbols \
    -Wl,--export-dynamic \
    -Wl,--add-stdcall-alias \
    -Wl,--enable-auto-import \
    -Wl,--whole-archive ${old_lib} \
    -Wl,--no-whole-archive ${dependency_libs}
echo EXPORTS > ${module}.def
nm ${module}.dll | grep ' T _' | sed 's/.* T _//' >> ${module}.def
dlltool --def ${module}.def --dllname ${module}.dll --output-lib ${module}.a
gcc -O -o run_main main.c -L./ -l${module} ${dependency_libs}
./run_main

This also works OK adding -mno-cygwin
...
gcc -shared -mno-cygwin -o ${module}.dll \
...
where printing to a file works fine, but not to stdout which I can live with.

With a more complex well-tested C code, the above script works fine
without "-mno-cygwin," but when I add this in the code bombs, likely due
to the problem being reported:
...
gcc -shared -mno-cygwin -o asadll.dll -Wl,--out-implib=libasadll.dll.a -Wl,--export-all-symbols -Wl,--export-dynamic -Wl,--add-stdcall-alias -Wl,--enable-auto-import -Wl,--whole-archive asa.o asa_usr.o asa_usr_cst.o -Wl,--no-whole-archive -lm
Creating library file: libasadll.dll.a
asa.o(.text+0xede):asa.c: undefined reference to `_impure_ptr'
...

Can anyone suggest what to do about "undefined reference to
`_impure_ptr'"?  I want to use these DLL's in another software package,
without having to register (updated) copies of cygwin1.dll, etc.

Thanks.

Lester


-- 
 Prof. Lester Ingber  ingber AT ingber DOT com  ingber AT alumni DOT caltech DOT edu
 www.ingber.com                     www.alumni.caltech.edu/~ingber

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019