Tamas Nepusz | 1 Sep 2008 22:36
Picon
Gravatar

problem with linking against MSVCR71.DLL and _ctype

Dear All,

I'm trying to compile a Python C/C++ extension in Windows using MinGW.  
For the well-known reasons (Python is built with MSVCR71.DLL), I have  
to link the extension with MSVCR71.DLL as well, so I followed the  
instructions of the following webpage to prepare MinGW to link with  
MSVCR71.DLL:

http://pygame.seul.org/wiki/PreparingMinGW

For some strange reason, the built library tries to make use of the  
_ctype symbol, which is only present in MSVCRT.DLL but not in  
MSVCR71.DLL. When browsing the archives, I found that this can be  
caused by #include-ing <iostream>, but there is no single place in the  
source code where this header is included. Can anyone tell me which  
other headers or functions can bring in the dependency on the _ctype  
symbol? Or maybe is there a tool in the MinGW/MSYS toolset that can  
tell me what causes this dependency? I'm using mingw-runtime-3.14 and  
gcc-3.2.3

Thanks in advance,
--

-- 
Tamas Nepusz <ntamas@...>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
(Continue reading)

Sergey L. Kachanuk | 10 Aug 2005 07:01
Picon

Problem with linking application's own shared library

Hi!
I'm trying to port project to mingw. It uses automake, autoconf and
libtool and already compiles with MSVC++ on Windows and gcc on Linux.
During compilation project creates it own library and then links against
it. During compiling shared library creates ok, but then i cannon link
to it :(

> /bin/sh ../libtool --tag=CXX --mode=link g++  -Wnon-virtual-dtor 
> -Wno-long-long -Wundef -Wall -W -Wp
> ointer-arith -Wwrite-strings -O2 -fno-exceptions -fno-check-new 
> -fno-common -no-undefined -mthreads
> -Wall -O2 -fexceptions -frtti  -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT 
> -DQT_NO_DEBUG -fno-strict-alia
> sing    -o sim.exe -L/c/Qt/3.3.4/lib   -L/c/Qt/3.3.4/lib 
> -D_THREAD_SAFE -pthread  sim.o libsim.la -l
> kernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 
> -loleaut32 -luuid -limm32 -lwinmm
> -lws2_32 -lwinspool
> g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith 
> -Wwrite-strings -O2 -fno-exce
> ptions -fno-check-new -fno-common -Wall -O2 -fexceptions -frtti 
> -DUNICODE -DQT_DLL -DQT_THREAD_SUPPO
> RT -DQT_NO_DEBUG -fno-strict-aliasing -o .libs/sim.exe -D_THREAD_SAFE 
> sim.o  -mthreads -L/c/Qt/3.3.4
> /lib -pthread ./.libs/libsim.dll.a -lqt-mt -L/mingw/lib 
> /mingw/lib/libxslt.dll.a /mingw/lib/libxml2.
> dll.a -lz -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 
> -lole32 -loleaut32 -luuid -lim
> m32 -lwinmm -lws2_32 -lwinspool -L/c/SIM/lib -L/mingw/lib
> g++.exe: unrecognized option `-pthread'
(Continue reading)

Michael Gerdau | 10 Aug 2005 07:48
Picon
Favicon

Re: Problem with linking application's own shared library

Hi Sergey !

Your commandlines are somewhat difficult to read but here's what
occured to me:

> > /bin/sh ../libtool --tag=CXX --mode=link g++  -Wnon-virtual-dtor 
> > -Wno-long-long -Wundef -Wall -W -Wp
> > ointer-arith -Wwrite-strings -O2 -fno-exceptions -fno-check-new 
> > -fno-common -no-undefined -mthreads
> > -Wall -O2 -fexceptions -frtti  -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT 
> > -DQT_NO_DEBUG -fno-strict-alia
> > sing    -o sim.exe -L/c/Qt/3.3.4/lib   -L/c/Qt/3.3.4/lib 
> > -D_THREAD_SAFE -pthread  sim.o libsim.la -l

Why do you have '-pthread' in there ?

> > kernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 
> > -loleaut32 -luuid -limm32 -lwinmm
> > -lws2_32 -lwinspool
> > g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith 
> > -Wwrite-strings -O2 -fno-exce
> > ptions -fno-check-new -fno-common -Wall -O2 -fexceptions -frtti 
> > -DUNICODE -DQT_DLL -DQT_THREAD_SUPPO
> > RT -DQT_NO_DEBUG -fno-strict-aliasing -o .libs/sim.exe -D_THREAD_SAFE 
> > sim.o  -mthreads -L/c/Qt/3.3.4
> > /lib -pthread ./.libs/libsim.dll.a -lqt-mt -L/mingw/lib 

What is './.libs/libsim.dll.a' ?

I assume you mean something like '-L ./.libs -lsim' (or similar).
(Continue reading)

Sergey L. Kachanuk | 10 Aug 2005 08:24
Picon

Re: Problem with linking application's own shared library

On 10.08.2005 8:48, Michael Gerdau wrote:
>>>kernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 -lole32 
>>>-loleaut32 -luuid -limm32 -lwinmm
>>>-lws2_32 -lwinspool
>>>g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith 
>>>-Wwrite-strings -O2 -fno-exce
>>>ptions -fno-check-new -fno-common -Wall -O2 -fexceptions -frtti 
>>>-DUNICODE -DQT_DLL -DQT_THREAD_SUPPO
>>>RT -DQT_NO_DEBUG -fno-strict-aliasing -o .libs/sim.exe -D_THREAD_SAFE 
>>>sim.o  -mthreads -L/c/Qt/3.3.4
>>>/lib -pthread ./.libs/libsim.dll.a -lqt-mt -L/mingw/lib 
> 
> 
> What is './.libs/libsim.dll.a' ?
> 
This is library, created during compilation of the project and against 
which failed linking. It contains all symbols, on which linking complains
> I assume you mean something like '-L ./.libs -lsim' (or similar).
> 
> 
>>>/mingw/lib/libxslt.dll.a /mingw/lib/libxml2.
>>>dll.a -lz -lkernel32 -luser32 -lgdi32 -lcomdlg32 -ladvapi32 -lshell32 
> 
> 
> Same with '/mingw/lib/libxslt.dll.a' and '/mingw/lib/libxml2.dll.a'
> 
> I assume that should be '-lxslt -lxml2'
> 
Second command produced by libtool, anyway, when i manually invoke
$ g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith 
(Continue reading)

Michael Gerdau | 10 Aug 2005 09:52
Picon
Favicon

Re: Problem with linking application's own shared library

Hi Sergey !

[cmdline snipped]
> sim.o(.text+0x87):sim.cpp: undefined reference to `SIM::logEnabled()'
> sim.o(.text+0xa9):sim.cpp: undefined reference to `SIM::log(unsigned 
[more errors snipped]

> >>All files and libraries exists.
> > 
> > Are you sure you have libraries './.libs/libsim.dll.a',
> > '/mingw/lib/libxslt.dll.a' and '/mingw/lib/libxml2.dll.a' ?
> > 
> Yeah!
> $ ls -l  /mingw/lib/libxslt*
> -rw-r--r--    1 serzh    Админист  1733452 Aug  8 04:56 /mingw/lib/libxslt.a
> -rw-r--r--    1 serzh    Админист   144588 Aug  8 04:56 
> /mingw/lib/libxslt.dll.a
> -rw-r--r--    1 serzh    Админист      816 Aug  8 04:56 
> /mingw/lib/libxslt.la
> 
> $ ls -l  /mingw/lib/libxml2*
> -rw-r--r--    1 serzh    Админист  6644018 Aug  4 12:59 /mingw/lib/libxml2.a
> -rw-r--r--    1 serzh    Админист  1017036 Aug  4 12:59 
> /mingw/lib/libxml2.dll.a
> -rw-r--r--    1 serzh    Админист      781 Aug  4 12:59 
> /mingw/lib/libxml2.la
> 
> $ ls -l  ./.libs/libsim*
> -rwxr-xr-x    1 serzh    Админист  2756281 Aug  9 09:46 ./.libs/libsim-0.dll
> -rw-r--r--    1 serzh    Админист     1998 Aug  9 09:46 ./.libs/libsim.dll.a
(Continue reading)

Brian Dessent | 10 Aug 2005 10:15
Favicon

Re: Problem with linking application's own shared library

Michael Gerdau wrote:

> When the linker (ld) sees something like '-l<somename>' it tries
> to link against lib<somename>.a
> 
> MinGW adds the special feature to check for lib<somename>.dll before.
> 
> Therefor for your above libs to link you have to add
> - '-lxslt' for libxslt.a
> - '-lxml2' for libxml2.a
> - either '-lsim-0' for libsim-0.dll
>   or '-lsim.dll' for libsim.dll.a (not sure wether this last one
>   would work).

.dll.a is fine.  ld looks for both.  This is not the problem.  

<http://sourceware.org/binutils/docs-2.16/ld/WIN32.html#index-direct-linking-to-a-dll-527>

The problem is probably related to libtool, you should post on their
mailing list.  WHich library/object contains the symbols that are not
found?  Is it being specified on the link command line?  Is it in the
right order?

Brian

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
(Continue reading)

Earnie Boyd | 10 Aug 2005 16:26
Picon

Re: Problem with linking application's own shared library

On 8:15:38 am 2005-08-10 Brian Dessent <brian@...> wrote:
> Michael Gerdau wrote:
>
> >  When the linker (ld) sees something like '-l<somename>' it tries
> >  to link against lib<somename>.a
> >
> >  MinGW adds the special feature to check for lib<somename>.dll
> >  before.
> >  Therefor for your above libs to link you have to add
> >  - '-lxslt' for libxslt.a
> >  - '-lxml2' for libxml2.a
> >  - either '-lsim-0' for libsim-0.dll
> >    or '-lsim.dll' for libsim.dll.a (not sure wether this last one
> >    would work).
>
> .dll.a is fine.  ld looks for both.  This is not the problem.
>
> <http://sourceware.org/binutils/docs-2.16/ld/WIN32.html#index-direct-l
> inking-to-a-dll-527>
>
> The problem is probably related to libtool, you should post on their
> mailing list.  WHich library/object contains the symbols that are not
> found?  Is it being specified on the link command line?  Is it in the
> right order?
>

The problem with libtool is there is not enough MinGW developers keeping
the changes monitored and tested.  Make sure that /etc/config.site doesn't
exist or is renamed before you do the configure to see if that helps.  If
not, I'll dig up some libtool script that you can replace the generated
(Continue reading)

Sergey L. Kachanuk | 11 Aug 2005 10:38
Picon

Re: Problem with linking application's own shared library

On 10.08.2005 17:26, Earnie Boyd wrote:
> The problem with libtool is there is not enough MinGW developers keeping
> the changes monitored and tested.  Make sure that /etc/config.site doesn't
> exist or is renamed before you do the configure to see if that helps.  If
> not, I'll dig up some libtool script that you can replace the generated
> script with.

Renaming this file not helped :( same thing.

-- 
Best regards,
Sergey L. Kachanuk

Jabber serzh@...
ICQ 262581267

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Sergey L. Kachanuk | 10 Aug 2005 10:54
Picon

Re: Problem with linking application's own shared library

On 10.08.2005 11:15, Brian Dessent wrote:
> The problem is probably related to libtool, you should post on their
> mailing list.  WHich library/object contains the symbols that are not
> found?  Is it being specified on the link command line?  Is it in the
> right order?
libsim contains these symbols. And they are in correct order.
When compiling with --enable-static linking against static libsim is ok 
and executable creates, but then project creates its plugins as static 
libraries and thus application not working :(
> 
> Brian
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> MinGW-users mailing list
> MinGW-users@...
> 
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
> 

--

-- 
Best regards,
Sergey L. Kachanuk

(Continue reading)

Brian Dessent | 10 Aug 2005 12:09
Favicon

Re: Problem with linking application's own shared library

"Sergey L. Kachanuk" wrote:

> libsim contains these symbols. And they are in correct order.
> When compiling with --enable-static linking against static libsim is ok
> and executable creates, but then project creates its plugins as static
> libraries and thus application not working :(

Use nm on libsim.dll.a, see if those symbols are listed.  I'm guessing
they are not being exported.  If this is the case you need to make sure
all exports are marked with __declspec((dllexport)).  Alternatively you
can use the auto-export/import feature.

Also, you might try configuring with LDFLAGS="-Wl,--no-undefined" and
see if that makes a difference.

Brian

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

(Continue reading)

Sergey L. Kachanuk | 10 Aug 2005 13:37
Picon

Re: Problem with linking application's own shared library

On 10.08.2005 13:09, Brian Dessent wrote:
> Use nm on libsim.dll.a, see if those symbols are listed.  I'm guessing
> they are not being exported.  If this is the case you need to make sure
Yes! :) Thanks a lot! You where right, nm on libsim.dll.a lists only few 
symbols...

> all exports are marked with __declspec((dllexport)).  Alternatively you
> can use the auto-export/import feature.
Could you please tell me more about this feature, what command line 
parameters should i give to g++ or libtool?

--

-- 
Best regards,
Sergey L. Kachanuk

Jabber serzh@...
ICQ 262581267

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

(Continue reading)

Michael Gerdau | 10 Aug 2005 13:54
Picon
Favicon

Re: Problem with linking application's own shared library

> > Use nm on libsim.dll.a, see if those symbols are listed.  I'm guessing
> > they are not being exported.  If this is the case you need to make sure
> Yes! :) Thanks a lot! You where right, nm on libsim.dll.a lists only few 
> symbols...
> 
> > all exports are marked with __declspec((dllexport)).  Alternatively you
> > can use the auto-export/import feature.
> Could you please tell me more about this feature, what command line 
> parameters should i give to g++ or libtool?

RTFM !

I already suggested you read this up in the MinGWiki -- I'm now
repeating this suggestion.

Point your browser to http://www.mingw.org/MinGWiki/

In the table displayed click on 'HowDoI', then item
"Use DLLs with MinGW", click on 'DLLs' and then item
"Building a small sample DLL", click on 'sample DLL'

You'll end on this page:
http://www.mingw.org/MinGWiki/index.php/sample DLL
which should give you enough information to answer this and
possibly quite a few other related questions.

HTH, best,
Michael
--

-- 
 Vote against SPAM - see http://www.politik-digital.de/spam/
(Continue reading)

Sergey L. Kachanuk | 11 Aug 2005 10:41
Picon

Re: Problem with linking application's own shared library

On 10.08.2005 14:54, Michael Gerdau wrote:
> RTFM !
> 
> I already suggested you read this up in the MinGWiki -- I'm now
> repeating this suggestion.
> 
> Point your browser to http://www.mingw.org/MinGWiki/
> 
> In the table displayed click on 'HowDoI', then item
> "Use DLLs with MinGW", click on 'DLLs' and then item
> "Building a small sample DLL", click on 'sample DLL'
> 
> You'll end on this page:
> http://www.mingw.org/MinGWiki/index.php/sample DLL
> which should give you enough information to answer this and
> possibly quite a few other related questions.
> 
Neither --enable-runtime-pseudo-reloc and --export-all-symbols options 
passed to lobtool didn't helped :(

-no-undefined I'm already using, without dynamic library not creates.

--

-- 
Best regards,
Sergey L. Kachanuk

Jabber serzh@...
ICQ 262581267

-------------------------------------------------------
(Continue reading)

Sergey L. Kachanuk | 11 Aug 2005 12:36
Picon

Re: Problem with linking application's own shared library

On 11.08.2005 11:41, Sergey L. Kachanuk wrote:
> Neither --enable-runtime-pseudo-reloc and --export-all-symbols options 
> passed to lobtool didn't helped :(
> 
> -no-undefined I'm already using, without dynamic library not creates.
> 

Ok! I've found option -export-symbols-regex in libtool and passed
-export-symbols-regex \* to it, but now I'm getting another errors:

> Cannot export R: symbol not defined
> Cannot export typeinfo for BalloonMsg: symbol not defined
> Cannot export typeinfo name for BalloonMsg: symbol not defined
> Cannot export vtable for BalloonMsg: symbol not defined
etc..

What can I do with this? :(

--

-- 
Best regards,
Sergey L. Kachanuk

Jabber serzh@...
ICQ 262581267

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
(Continue reading)

Michael Gerdau | 10 Aug 2005 10:40
Picon
Favicon

Re: Problem with linking application's own shared library

> .dll.a is fine.  ld looks for both.  This is not the problem.  
> 
> <http://sourceware.org/binutils/docs-2.16/ld/WIN32.html#index-direct-linking-to-a-dll-527>

I stand corrected (and learned something new :)

Best,
Michael
--

-- 
 Vote against SPAM - see http://www.politik-digital.de/spam/
 Michael Gerdau       email: mgd@...
 GPG-keys available on request or at public keyserver

Gmane