By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,412 Members | 1,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,412 IT Pros & Developers. It's quick & easy.

VC++ linking problem

P: n/a
J
Hi everyone,

I started embedding python into a 3D graphics App and I came
across this linking problem.
SO.lib(ScnGlobal.obj) : error LNK2001: unresolved external symbol
__imp__Py_InitModule4TraceRefs
SO.lib(ScnNode.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal
SO.lib(ScnLight.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal

I am linking against python24.lib using VC++ 6.0. Before I got to this
point it couldn't find python24_d.lib. After searching around
for a while I came across a solution that included changing
python24_d.lib to python24.lib in one of the header files. I hope that
didn't have a negative effect. I would really appreciate
some help....
Thanks
Jochen

Jul 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Thu, Jul 07, 2005 at 04:52:11AM -0700, J wrote:
Hi everyone,

I started embedding python into a 3D graphics App and I came
across this linking problem.


SO.lib(ScnGlobal.obj) : error LNK2001: unresolved external symbol
__imp__Py_InitModule4TraceRefs
SO.lib(ScnNode.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal
SO.lib(ScnLight.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal

I am linking against python24.lib using VC++ 6.0. Before I got to this
point it couldn't find python24_d.lib. After searching around
for a while I came across a solution that included changing
python24_d.lib to python24.lib in one of the header files. I hope that
didn't have a negative effect. I would really appreciate
some help....


It *does* have a negative effect. Python debug and non-debug libraries
are not binary compatible, even when otherwise compiled with the same
settings. I think that's the reason for the _d suffixes for Python debug
binaries on Windows.

The solution for you is to compile yourself a debug version of Python
for testing your whole app in debug mode.

AFAIR in python-dev Python 2.4 can still be compiled with MSVC6, even
though the official binaries are built with MSVC 7.1.

-- Gerhard
--
Gerhard Häring - gh@ghaering.de - Python, web & database development

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCzRoldIO4ozGCH14RAk6PAJ9x7CUuPnFAp82Sg2NRbe 2OVT6SRgCfT18w
D+T5F3cskmSEJlmxRMUBBzY=
=cZoG
-----END PGP SIGNATURE-----

Jul 21 '05 #2

P: n/a
Hello Jochen,
I started embedding python into a 3D graphics App and I came
across this linking problem.


SO.lib(ScnGlobal.obj) : error LNK2001: unresolved external symbol
__imp__Py_InitModule4TraceRefs
SO.lib(ScnNode.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal
SO.lib(ScnLight.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal

I am linking against python24.lib using VC++ 6.0. Before I got to this
point it couldn't find python24_d.lib. After searching around
for a while I came across a solution that included changing
python24_d.lib to python24.lib in one of the header files. I hope that
didn't have a negative effect. I would really appreciate
some help....

This is since Python header file is in debug mode and you link with the
regular library.

Just do:
#undef _DEBUG /* Link with python24.lib and not python24_d.lib */
#include <Python.h>

and you'll be fine.

IMO python should try and link with python24.lib when compiling in debug
mode since we want to debug our program and not Python.

Bye.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)

iD8DBQFCzRzM8jAdENsUuJsRAnNaAJ0TF6E3kNkPoug/oa4R1Om/7Ge1egCcCYqV
IiW/ZADXqQ3cQTP/fjD0Fbk=
=W+3M
-----END PGP SIGNATURE-----

Jul 21 '05 #3

P: n/a
Hello Jochen,
I started embedding python into a 3D graphics App and I came
across this linking problem.
SO.lib(ScnGlobal.obj) : error LNK2001: unresolved external symbol
__imp__Py_InitModule4TraceRefs
SO.lib(ScnNode.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal
SO.lib(ScnLight.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal

I am linking against python24.lib using VC++ 6.0. Before I got to this
point it couldn't find python24_d.lib. After searching around
for a while I came across a solution that included changing
python24_d.lib to python24.lib in one of the header files. I hope that
didn't have a negative effect. I would really appreciate
some help....


Be careful, python 2.4 is build with VC++ 7.1.
Mixing this in your application which is build with
VC++ 6.0 can lead to trouble.

python24_d.lib is the debug version of the python library.
It's possible to build your application in debug against a
release Python Version. But I don't know what switches are needed.

This unresolved external symbols are a result of your linkage.
This symbols are only present in the debug version of the library.
If you start python_d.exe (debug executable of python) you get
the total ref count after every statement.

To fix this, build debug version of your App against debug version
of python or set all switches to build a debug version against release
python.
The boost python library does this, see:
http://www.boost.org/libs/python/doc/index.html
bye by Wolfgang
Jul 21 '05 #4

P: n/a
J
Thank you very much Miki!

That was an easy solution. It links... I will put a hold on compiling
the latest version until I really have to. I will probably switch to VC
7 before that.

Cheers
Jochen
Miki Tebeka wrote:
Hello Jochen,
I started embedding python into a 3D graphics App and I came
across this linking problem.
SO.lib(ScnGlobal.obj) : error LNK2001: unresolved external symbol
__imp__Py_InitModule4TraceRefs
SO.lib(ScnNode.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal
SO.lib(ScnLight.obj) : error LNK2001: unresolved external symbol
__imp___Py_RefTotal

I am linking against python24.lib using VC++ 6.0. Before I got to this
point it couldn't find python24_d.lib. After searching around
for a while I came across a solution that included changing
python24_d.lib to python24.lib in one of the header files. I hope that
didn't have a negative effect. I would really appreciate
some help....

This is since Python header file is in debug mode and you link with the
regular library.

Just do:
#undef _DEBUG /* Link with python24.lib and not python24_d.lib */
#include <Python.h>

and you'll be fine.

IMO python should try and link with python24.lib when compiling in debug
mode since we want to debug our program and not Python.

Bye.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys


Jul 21 '05 #5

P: n/a
Hello J,
I will put a hold on compiling the latest version until I really have to.
I will probably switch to VC 7 before that.

You can use the (free) MinGW compiler (www.mingw.org). It can build
extension that link to Python 2.4.
Just use distutils setup.py and run 'python setup.py build_ext -c mingw32'

HTH.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)

iD8DBQFCzrGa8jAdENsUuJsRAjWhAJ0dYX9XbA6T3VqZ4rUiO/0QNfp/aACgqx7s
q/K0ssAVLYK3PdYUlRtbJis=
=7dJX
-----END PGP SIGNATURE-----

Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.