Boost C++ Libraries: Ticket #543: Embedded python won't compile https://svn.boost.org/trac10/ticket/543 <pre class="wiki">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 : '&gt;' 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 : '&gt;' 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&lt;&gt;(borrowed(PyImport_AddModule("__main__"))))); object main_namespace = main_module.attr("__dict__"); handle&lt;&gt; 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 &gt; 1000 #pragma once #endif // _MSC_VER &gt; 1000 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include &lt;stdio.h&gt; #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@gmail.com </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/543 Trac 1.4.3 david_abrahams Thu, 11 Jan 2007 00:49:40 GMT <link>https://svn.boost.org/trac10/ticket/543#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/543#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=52572 Originator: NO The tutorial has been updated several times since you posted this issue to fix omissions. If you haven't given up yet, you might try looking at it again. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Daryle Walker</dc:creator> <pubDate>Fri, 03 Aug 2007 12:00:13 GMT</pubDate> <title>component changed; severity set https://svn.boost.org/trac10/ticket/543#comment:2 https://svn.boost.org/trac10/ticket/543#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">Python</span> </li> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> Ticket Dave Abrahams Thu, 25 Oct 2007 23:10:29 GMT description changed; cc set https://svn.boost.org/trac10/ticket/543#comment:3 https://svn.boost.org/trac10/ticket/543#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">dirk@…</span> added </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/543?action=diff&amp;version=3">diff</a>) </li> </ul> <p> Dirk, if you would check this out and see if you think there's still something to address, I'd be very grateful. </p> Ticket dirk@… Fri, 26 Oct 2007 09:37:24 GMT <link>https://svn.boost.org/trac10/ticket/543#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/543#comment:4</guid> <description> <p> From a quick glance it looks like it's simply missing "using namespace boost::python" </p> <p> Anyway, I contributed that bit of tutorial some 4 years ago. I haven't touched Boost.Python much since, and I don't really have time to investigate further. Besides I have no access to VC++ 6.0, and the bug report itself is 2 years old already. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Wed, 28 Nov 2007 17:12:10 GMT</pubDate> <title>status, resolution changed https://svn.boost.org/trac10/ticket/543#comment:5 https://svn.boost.org/trac10/ticket/543#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I'll be closing this one. Seems like this is no longer relevant. </p> Ticket