Re: [C++-sig] Cplusplus-sig Digest, Vol 30, Issue 6

2011-03-09 Thread Ryan Murray
Hi Austin,

Thanks for the reply. The lines you changed in my compile command were
actually how I was compiling as well. I just copied the wrong line
into the email. On my Linux box the problem was being caused by an old
set of boost libraries compiled with an older intel compiler. On OSX,
I am not certain exactly but it seems that I was linking the module
against a python2.6 library but boost_python had been built with the
2.7 library or there was a mismatch with headers or something else
strange. So I feel much better now that a program I thought should
work does.

One follow up question, if i link the library using
-Wl,-soname,libtest.so then move the file to test.so does that make a
difference when importing and using it?

Thanks for your help,

Ryan


On Tue, Mar 8, 2011 at 11:00 AM,   wrote:
> Hi Ryan,
>
> I tried out your code (g++, python2.6, boost-1.40) and it worked just
> fine. However, I had to make a few changes to your compilation command
> to get it working. The python module you're defining is called
> "testing", but your command is generating a "libclassical.so"; you
> need to output "testing.so" (no leading 'lib') for python to import
> it/associate it with the module "testing". Is it possible that you're
> actually loading a module from some old build or something?
>
> Other than that, I can't see any problems. Can you possibly post a stack 
> trace?
>
> Austin
>
> On Mon, Mar 7, 2011 at 5:03 PM, Ryan Murray  wrote:
>> Hi All,
>>
>> I am testing boost python with the following code:
>>
>>
>> #include 
>> #include 
>> #include 
>>
>> using namespace boost::python;
>>
>> int pyrun_main();
>>
>> BOOST_PYTHON_MODULE(testing)
>> {
>> ? ?def("pyrun_main",pyrun_main);
>> }
>>
>> int pyrun_main(){
>> ? ?try{
>> ? ? ? ?throw std::exception();
>> ? ?}
>> ? ?catch(std::exception &e){
>> ? ? ? ?std::cout << "fun!" << std::endl;
>> ? ?}
>>
>> ? ?return 1;
>> }
>>
>>
>> I compile it with:
>>
>> g++ boostpy.cpp -I/usr/include/python2.6/ -lpython2.6 -fPIC ? -shared
>> -Wl,-soname,libclassical.so -o libclassical.so
>>
>> and import it into python without problems. When running pyrun_main()
>> I get a Segmentation Fault. and no other useful output. I have tried
>> on python 2.6 and 2.7 on Linux and OSX. And have tried g++,clang,icpc
>> compilers. On boost 1.44,1.45 and 1.46.
>> Perhaps I am missing something very simple but I cant find any reason
>> why this won't run. I have other code that does not throw and works
>> fine.
>>
>> Thanks
>> Ryan
>> ___
>> Cplusplus-sig mailing list
>> [email protected]
>> http://mail.python.org/mailman/listinfo/cplusplus-sig
>>
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] compile-time macro errors when using Python 2.7.1 and Boost 1.45 on OSX 10.6.6

2011-03-09 Thread Athanasios Dousis
I've appended this issue to the Python bug tracker 
http://bugs.python.org/issue10910

On Mar 2, 2011, at 11:17 AM, Athanasios Dousis wrote:

> Hello all,
> 
> I'm upgrading from Python 2.6.5 to 2.7.1, and I'm getting the error below 
> when compiling my program using Boost 1.45 and gcc 4.2.1 in OSX 10.6.6.  I 
> found a thread that describes similar symptoms related to the ordering of 
> header files and macro definitions:
> http://code.google.com/p/unladen-swallow/issues/detail?id=87#c13
> 
> The suggested patch to pyport.h 
> (http://codereview.appspot.com/179049/patch/1/2) does not fix my problem, 
> presumably because I'm not using FreeBSD.  However, adding #include 
> "Python.h" to the top of each source file (e.g., bend.cc below) does fix the 
> problem.  Is there a simple way to fix this without adding Python.h to every 
> source file in my codebase?
> 
> I've installed Boost and Python from source to non-standard directories, 
> Boost 1.45 by:
> cd $(BOOST); ./bootstrap.sh --prefix=$(CURDIR)/$(BOOST) 
> --with-python-root=$(CURDIR)/$(PYTHON_DIR) --with-python-version=2.7 
> --with-libraries=mpi
> 
> and Python 2.7 by:
> cd $(PYTHON_SRCDIR) ; ./configure --enable-shared 
> --prefix=$(CURDIR)/$(PYTHON_DIR)
> cd $(PYTHON_SRCDIR) ; make -j $(NUMPROC) && make install
> 
> Any guidance will be greatly appreciated.
> 
> Kind regards,
> Nasos
> 
> ===
> ...
> darwin.compile.c++ bin/darwin-4.2.1/release/threading-multi/bend.o
> In file included from /usr/include/c++/4.2.1/ios:47,
>  from /usr/include/c++/4.2.1/ostream:45,
>  from /usr/include/c++/4.2.1/iterator:70,
>  from boost/boost/next_prior.hpp:15,
>  from boost/boost/utility.hpp:17,
>  from boost/boost/python/instance_holder.hpp:10,
>  from boost/boost/python/object/pointer_holder.hpp:14,
>  from boost/boost/python/to_python_indirect.hpp:10,
>  from boost/boost/python/converter/arg_to_python.hpp:10,
>  from boost/boost/python/call.hpp:15,
>  from boost/boost/python/object_core.hpp:14,
>  from boost/boost/python/args.hpp:25,
>  from boost/boost/python.hpp:11,
>  from bend.hh:6,
>  from bend.cc:1:
> /usr/include/c++/4.2.1/bits/localefwd.h:58:34: error: macro "isspace" passed 
> 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:70:34: error: macro "isupper" passed 
> 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:74:34: error: macro "islower" passed 
> 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:78:34: error: macro "isalpha" passed 
> 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:94:34: error: macro "isalnum" passed 
> 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:102:34: error: macro "toupper" passed 
> 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/localefwd.h:106:34: error: macro "tolower" passed 
> 2 arguments, but takes just 1
> In file included from /usr/include/c++/4.2.1/bits/basic_ios.h:44,
>  from /usr/include/c++/4.2.1/ios:50,
>  from /usr/include/c++/4.2.1/ostream:45,
>  from /usr/include/c++/4.2.1/iterator:70,
>  from boost/boost/next_prior.hpp:15,
>  from boost/boost/utility.hpp:17,
>  from boost/boost/python/instance_holder.hpp:10,
>  from boost/boost/python/object/pointer_holder.hpp:14,
>  from boost/boost/python/to_python_indirect.hpp:10,
>  from boost/boost/python/converter/arg_to_python.hpp:10,
>  from boost/boost/python/call.hpp:15,
>  from boost/boost/python/object_core.hpp:14,
>  from boost/boost/python/args.hpp:25,
>  from boost/boost/python.hpp:11,
>  from bend.hh:6,
>  from bend.cc:1:
> /usr/include/c++/4.2.1/bits/locale_facets.h:242:53: error: macro "toupper" 
> passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:271:53: error: macro "tolower" 
> passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:814:53: error: macro "toupper" 
> passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:847:53: error: macro "tolower" 
> passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4611:44: error: macro "isspace" 
> passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4629:44: error: macro "isupper" 
> passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4635:44: error: macro "islower" 
> passed 2 arguments, but takes just 1
> /usr/include/c++/4.2.1/bits/locale_facets.h:4641:44: error: macro "isalpha" 
> passed 2 arguments, but takes just 1
> /usr/include/c++/