Re: [Boost-bugs] [Boost C++ Libraries] #543: Embedded python won't compile

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #543: Embedded python won't compile
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-10-25 23:10:30


#543: Embedded python won't compile
-------------------------------+--------------------------------------------
  Reporter: nobody | Owner: djowel
      Type: Support Requests | Status: assigned
 Milestone: | Component: Python
   Version: None | Severity: Problem
Resolution: None | Keywords:
-------------------------------+--------------------------------------------
Changes (by dave):

 * cc: dirk_at_[hidden] (added)

Old description:

> {{{
> I followed the tutorial about embedding at
> http://www.boost.org/libs/python/doc/tutorial/doc/html/python/embedding.html#python.using_the_interpreter
> but I am now faced with some errors (VC++ 6.0, latest
> Service Pack running on Windows 2000 SP4).
>
> The errors:
>
> Compiling...
> StdAfx.cpp
> Compiling...
> pytest.cpp
> f:\pytest\pytest.cpp(10) : error C2065: 'object' :
> undeclared identifier
> f:\pytest\pytest.cpp(10) : error C2146: syntax error :
> missing ';' before identifier 'main_module'
> f:\pytest\pytest.cpp(10) : error C2065: 'main_module' :
> undeclared identifier
> f:\pytest\pytest.cpp(11) : error C2065: 'handle' :
> undeclared identifier
> f:\pytest\pytest.cpp(11) : error C2059: syntax error : '>'
> f:\pytest\pytest.cpp(13) : error C2146: syntax error :
> missing ';' before identifier 'main_namespace'
> f:\pytest\pytest.cpp(13) : error C2065:
> 'main_namespace' : undeclared identifier
> f:\pytest\pytest.cpp(13) : error C2228: left of '.attr'
> must have class/struct/union type
> f:\pytest\pytest.cpp(15) : error C2059: syntax error : '>'
> Error executing cl.exe.
>
> pytest.exe - 9 error(s), 0 warning(s)
>
> The code:
>
> pytest.cpp
> ==========
>
> // pytest.cpp : Defines the entry point for the console
> application.
> //
>
> #include "stdafx.h"
>
> int main(int argc, char* argv[])
> {
> Py_Initialize();
>
> object main_module((
> handle<>(borrowed(PyImport_AddModule("__main__")))));
>
> object main_namespace = main_module.attr("__dict__");
>
> handle<> ignored((PyRun_String(
>
> "hello = file('hello.txt', 'w')\n"
> "hello.write('Hello world!')\n"
> "hello.close()"
>
> , Py_file_input
> , main_namespace.ptr()
> , main_namespace.ptr())
> ));
>
> Py_Finalize();
>
> return 0;
> }
>
> StdAfx.cpp
> ==========
>
> // stdafx.cpp : source file that includes just the
> standard includes
> // pytest.pch will be the pre-compiled header
> // stdafx.obj will contain the pre-compiled type
> information
>
> #include "stdafx.h"
>
> // TODO: reference any additional headers you need in
> STDAFX.H
> // and not in this file
>

> StdAfx.h
> ========
>
> // stdafx.h : include file for standard system include
> files,
> // or project specific include files that are used
> frequently, but
> // are changed infrequently
> //
>
> #if
> !defined(AFX_STDAFX_H__14167E34_D56C_4B80_BB18_4CB7F7E8E058__INCLUDED_)
> #define
> AFX_STDAFX_H__14167E34_D56C_4B80_BB18_4CB7F7E8E058__INCLUDED_
>
> #if _MSC_VER > 1000
> #pragma once
> #endif // _MSC_VER > 1000
>
> #define WIN32_LEAN_AND_MEAN // Exclude rarely-used
> stuff from Windows headers
>
> #include <stdio.h>
> #include "boost\python.hpp"
> using namespace std;
>
> // TODO: reference additional headers your program
> requires here
>
> //{{AFX_INSERT_LOCATION}}
> // Microsoft Visual C++ will insert additional
> declarations immediately before the previous line.
>
> #endif //
> !defined(AFX_STDAFX_H__14167E34_D56C_4B80_BB18_4CB7F7E8E058__INCLUDED_)
>
> Libs
> ====
>
> kernel32.lib user32.lib gdi32.lib winspool.lib
> comdlg32.lib advapi32.lib shell32.lib ole32.lib
> oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
> kernel32.lib user32.lib gdi32.lib winspool.lib
> comdlg32.lib advapi32.lib shell32.lib ole32.lib
> oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
> python24.lib boost_python.lib
>
> Please help, I would VERY much appreciate it- good job
> with all the hard work on Boost.Python!
>
> My email address is jamclx_at_[hidden]
> }}}

New description:

 {{{
 I followed the tutorial about embedding at
 http://www.boost.org/libs/python/doc/tutorial/doc/html/python/embedding.html#python.using_the_interpreter
 but I am now faced with some errors (VC++ 6.0, latest
 Service Pack running on Windows 2000 SP4).

 The errors:

 Compiling...
 StdAfx.cpp
 Compiling...
 pytest.cpp
 f:\pytest\pytest.cpp(10) : error C2065: 'object' :
 undeclared identifier
 f:\pytest\pytest.cpp(10) : error C2146: syntax error :
 missing ';' before identifier 'main_module'
 f:\pytest\pytest.cpp(10) : error C2065: 'main_module' :
 undeclared identifier
 f:\pytest\pytest.cpp(11) : error C2065: 'handle' :
 undeclared identifier
 f:\pytest\pytest.cpp(11) : error C2059: syntax error : '>'
 f:\pytest\pytest.cpp(13) : error C2146: syntax error :
 missing ';' before identifier 'main_namespace'
 f:\pytest\pytest.cpp(13) : error C2065:
 'main_namespace' : undeclared identifier
 f:\pytest\pytest.cpp(13) : error C2228: left of '.attr'
 must have class/struct/union type
 f:\pytest\pytest.cpp(15) : error C2059: syntax error : '>'
 Error executing cl.exe.

 pytest.exe - 9 error(s), 0 warning(s)

 The code:

 pytest.cpp
 ==========

 // pytest.cpp : Defines the entry point for the console
 application.
 //

 #include "stdafx.h"

 int main(int argc, char* argv[])
 {
         Py_Initialize();

     object main_module((
     handle<>(borrowed(PyImport_AddModule("__main__")))));

 object main_namespace = main_module.attr("__dict__");

 handle<> ignored((PyRun_String(

     "hello = file('hello.txt', 'w')\n"
     "hello.write('Hello world!')\n"
     "hello.close()"

   , Py_file_input
   , main_namespace.ptr()
   , main_namespace.ptr())
 ));

         Py_Finalize();

         return 0;
 }

 StdAfx.cpp
 ==========

 // stdafx.cpp : source file that includes just the
 standard includes
 // pytest.pch will be the pre-compiled header
 // stdafx.obj will contain the pre-compiled type
 information

 #include "stdafx.h"

 // TODO: reference any additional headers you need in
 STDAFX.H
 // and not in this file


 StdAfx.h
 ========

 // stdafx.h : include file for standard system include
 files,
 // or project specific include files that are used
 frequently, but
 // are changed infrequently
 //

 #if
 !defined(AFX_STDAFX_H__14167E34_D56C_4B80_BB18_4CB7F7E8E058__INCLUDED_)
 #define
 AFX_STDAFX_H__14167E34_D56C_4B80_BB18_4CB7F7E8E058__INCLUDED_

 #if _MSC_VER > 1000
 #pragma once
 #endif // _MSC_VER > 1000

 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used
 stuff from Windows headers

 #include <stdio.h>
 #include "boost\python.hpp"
 using namespace std;

 // TODO: reference additional headers your program
 requires here

 //{{AFX_INSERT_LOCATION}}
 // Microsoft Visual C++ will insert additional
 declarations immediately before the previous line.

 #endif //
 !defined(AFX_STDAFX_H__14167E34_D56C_4B80_BB18_4CB7F7E8E058__INCLUDED_)

 Libs
 ====

 kernel32.lib user32.lib gdi32.lib winspool.lib
 comdlg32.lib advapi32.lib shell32.lib ole32.lib
 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
 kernel32.lib user32.lib gdi32.lib winspool.lib
 comdlg32.lib advapi32.lib shell32.lib ole32.lib
 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
 python24.lib boost_python.lib

 Please help, I would VERY much appreciate it- good job
 with all the hard work on Boost.Python!

 My email address is jamclx_at_[hidden]
 }}}

Comment:

 Dirk, if you would check this out and see if you think there's still
 something to address, I'd be very grateful.

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/543#comment:3>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:56 UTC