link error in debug mode

View: New views
4 Messages — Rating Filter:   Alert me  

link error in debug mode

by Themistoklis Bourdenas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi I export some C++ classes with swig to python and then try to compile
the module. However I get linking errors in debug mode. However when
compiling in release mode (VS2005) everything compiles smoothly and my
module is working properly. Any idea why does this happens?

The linking errors I get in debug mode are following:
pyMage_wrap.obj : error LNK2019: unresolved external symbol
__imp___Py_Dealloc referenced in function _PySwigObject_format
pyMage_wrap.obj : error LNK2019: unresolved external symbol
__imp___Py_NegativeRefcount referenced in function _PySwigObject_format
pyMage_wrap.obj : error LNK2001: unresolved external symbol
__imp___Py_RefTotal
pyMage_wrap.obj : error LNK2019: unresolved external symbol
__imp___PyObject_DebugFree referenced in function _PySwigObject_dealloc
pyMage_wrap.obj : error LNK2019: unresolved external symbol
__imp___PyObject_DebugMalloc referenced in function _PySwigObject_New
pyMage_wrap.obj : error LNK2019: unresolved external symbol
__imp__Py_InitModule4TraceRefs referenced in function _init_pyMage

It seems that python library is missing but how does it work in release
mode?

Thanks in advance.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: link error in debug mode

by Marcelo Matus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

When using the debug mode, probably you are using a Py_DEBUG/Py_TRACE_REFS
macros or so that  enable the python debug mode, but you are still
linking against the
plain python library.

Hence, you need to have two python installation, one with debug mode
(configure using --with-pydebug or so) and one plain or release python
version.
You can install the debug version using a directory like

   ./confiigure --prefix=/usr/local/python-2.4.1-dbg  --with-pydebug
..(or so)

When compiling the debug version of your module, be sure you link against
the proper debug python library, ie, add something like

  -L/usr/local/python-2.4.1-dbg/lib/python2.4/config/ -lpython2.4

Or, just be sure you don't use any macro that enables the python debug mode.
Marcelo

Themistoklis Bourdenas wrote:

> Hi I export some C++ classes with swig to python and then try to
> compile the module. However I get linking errors in debug mode.
> However when compiling in release mode (VS2005) everything compiles
> smoothly and my module is working properly. Any idea why does this
> happens?
>
> The linking errors I get in debug mode are following:
> pyMage_wrap.obj : error LNK2019: unresolved external symbol
> __imp___Py_Dealloc referenced in function _PySwigObject_format
> pyMage_wrap.obj : error LNK2019: unresolved external symbol
> __imp___Py_NegativeRefcount referenced in function _PySwigObject_format
> pyMage_wrap.obj : error LNK2001: unresolved external symbol
> __imp___Py_RefTotal
> pyMage_wrap.obj : error LNK2019: unresolved external symbol
> __imp___PyObject_DebugFree referenced in function _PySwigObject_dealloc
> pyMage_wrap.obj : error LNK2019: unresolved external symbol
> __imp___PyObject_DebugMalloc referenced in function _PySwigObject_New
> pyMage_wrap.obj : error LNK2019: unresolved external symbol
> __imp__Py_InitModule4TraceRefs referenced in function _init_pyMage
>
> It seems that python library is missing but how does it work in
> release mode?
>
> Thanks in advance.
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Swig-user mailing list
> Swig-user@...
> https://lists.sourceforge.net/lists/listinfo/swig-user




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: link error in debug mode

by Themistoklis Bourdenas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well having a windows system I've downloaded the python source and build
with VS a debug version of python24_d.lib instead of what you've
described below. I linked my module with this lib but I still get the
linking errors.

 >>> Or, just be sure you don't use any macro that enables the python
debug mode.
I can't say that I've understood what I am supposed to do? Where do I
use these macros?

Marcelo Matus wrote:

> When using the debug mode, probably you are using a
> Py_DEBUG/Py_TRACE_REFS
> macros or so that  enable the python debug mode, but you are still
> linking against the
> plain python library.
>
> Hence, you need to have two python installation, one with debug mode
> (configure using --with-pydebug or so) and one plain or release python
> version.
> You can install the debug version using a directory like
>
>   ./confiigure --prefix=/usr/local/python-2.4.1-dbg  --with-pydebug
> ..(or so)
>
> When compiling the debug version of your module, be sure you link against
> the proper debug python library, ie, add something like
>
>  -L/usr/local/python-2.4.1-dbg/lib/python2.4/config/ -lpython2.4
>
> Or, just be sure you don't use any macro that enables the python debug
> mode.
> Marcelo
>
> Themistoklis Bourdenas wrote:
>
>> Hi I export some C++ classes with swig to python and then try to
>> compile the module. However I get linking errors in debug mode.
>> However when compiling in release mode (VS2005) everything compiles
>> smoothly and my module is working properly. Any idea why does this
>> happens?
>>
>> The linking errors I get in debug mode are following:
>> pyMage_wrap.obj : error LNK2019: unresolved external symbol
>> __imp___Py_Dealloc referenced in function _PySwigObject_format
>> pyMage_wrap.obj : error LNK2019: unresolved external symbol
>> __imp___Py_NegativeRefcount referenced in function _PySwigObject_format
>> pyMage_wrap.obj : error LNK2001: unresolved external symbol
>> __imp___Py_RefTotal
>> pyMage_wrap.obj : error LNK2019: unresolved external symbol
>> __imp___PyObject_DebugFree referenced in function _PySwigObject_dealloc
>> pyMage_wrap.obj : error LNK2019: unresolved external symbol
>> __imp___PyObject_DebugMalloc referenced in function _PySwigObject_New
>> pyMage_wrap.obj : error LNK2019: unresolved external symbol
>> __imp__Py_InitModule4TraceRefs referenced in function _init_pyMage
>>
>> It seems that python library is missing but how does it work in
>> release mode?
>>
>> Thanks in advance.
>>
>>
>> -------------------------------------------------------
>> This SF.Net email is sponsored by xPML, a groundbreaking scripting
>> language
>> that extends applications into web and mobile media. Attend the live
>> webcast
>> and join the prime developer group breaking into this new coding
>> territory!
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>> _______________________________________________
>> Swig-user mailing list
>> Swig-user@...
>> https://lists.sourceforge.net/lists/listinfo/swig-user
>
>
>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: link error in debug mode

by nitro-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>  >>> Or, just be sure you don't use any macro that enables the python  
> debug mode.
> I can't say that I've understood what I am supposed to do? Where do I  
> use these macros?

  From our wiki:

Modification to Python for building Debug libs

There are basically two options if you use VC 2005. Either you build
yourself a version of the python debug libs or do what I will describe
next. I am using the second way and never tried the first. Go into your
python/include folder. Open the pyconfig.h with an editor and change

#ifdef _DEBUG
#       define Py_DEBUG
#endif

to

#ifdef _DEBUG
//#     define Py_DEBUG
#endif

Second, change

#                       ifdef _DEBUG
#                               pragma comment(lib,"python24_d.lib")
#                       else
#                               pragma comment(lib,"python24.lib")
#                       endif /* _DEBUG */

to

#                       ifdef _DEBUG
#                               pragma comment(lib,"python24.lib")
#                       else
#                               pragma comment(lib,"python24.lib")
#                       endif /* _DEBUG */

This will ensure you don't get problems with errors about "some headers
are included with DEBUG defined, some without" and linking problems. If
you are on MSVS 2003, you won't get any problems at all.


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user