Opened 17 years ago
Closed 15 years ago
#543 closed Support Requests (wontfix)
Embedded python won't compile
Reported by: | nobody | Owned by: | Joel de Guzman |
---|---|---|---|
Milestone: | Component: | python USE GITHUB | |
Version: | None | Severity: | Problem |
Keywords: | Cc: | dirk@… |
Description (last modified by )
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@gmail.com
Change History (5)
comment:2 by , 15 years ago
Component: | None → Python |
---|---|
Severity: | → Problem |
comment:3 by , 15 years ago
Cc: | added |
---|---|
Description: | modified (diff) |
Dirk, if you would check this out and see if you think there's still something to address, I'd be very grateful.
comment:4 by , 15 years ago
From a quick glance it looks like it's simply missing "using namespace boost::python"
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.
comment:5 by , 15 years ago
Resolution: | None → wontfix |
---|---|
Status: | assigned → closed |
I'll be closing this one. Seems like this is no longer relevant.
Note:
See TracTickets
for help on using tickets.