473,382 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

VC++ linking problem

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
5 6740
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sb | last post by:
Hello. I have three files in a VC++6 project - a header file called Schedule.h, an implementation class called Schedule.cpp and a test class with main called TestSchedule1.cpp. It compiles fine in...
1
by: yanwan | last post by:
Hello I met some problems in linking a project, and hope someone can give me some advice. -----------Configuration: lighting - Win32 Release-------------------- Linking... LINK : warning...
2
by: Cris Ding | last post by:
Hi, everyone, Suppose the following simple program: #include "engine.h" int main() { Engine *ep;
4
by: Rookie | last post by:
Hi, I needed some information on linking a C# application to a VC++ dll. How can this be done? It would be great if someone could give links to tutorials/articles on this subject. Thanks.
0
by: ngnuser | last post by:
I am developing an app (console) in vc++ 6 that link with a library developed using vc++ 7. Getting lots of linker error (undefined reference). Any suggestion/solution for this problem. Runtime...
0
by: zhangrusi | last post by:
I have a static library that is compiled using the latest version of VC 6. It uses the multithreaded DLL versions of the run-time library, and it uses STL classes. I would like to make use of this...
4
by: Sanjay Kumar | last post by:
Folks ! I am working with VC++ after a long time and having problem linking latest xerces 2.7 in VC++ 2005 Express Edition. I have done following: 1. downloaded and unpacked the the...
0
by: parekh | last post by:
Hi All , I am facing a problem wherein my VB project is not recognizing a change in the argument list of a method ( the method itself being declared and defined in another VC++ project and it...
0
by: JohnIdol | last post by:
VC++6 to VC++2003 - linking troubles -------------------------------------------------------------------------------- Hi All, I successfully ported an application from VC++6 to VS2003. Solved...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.