Reputation: 479
my sample code:
#include <iostream>
#include <boost/array.hpp>
#include <boost/python.hpp>
using namespace std;
int main(){
boost::array<int, 4> arr = {{1,2,3,4}};
cout << "hi" << arr[0];
return 0;
}
compile using :
g++ a.cpp -o a -I /usr/include/python2.7/ -lboost_python -lboost_system -shared -fPIC
the run ./a and it gives me:
Segmentation fault (core dumped)
I think it is something related to boost python library, if I remove
#include <boost/python.hpp>
and compile with
g++ a.cpp -o a
then ./a, everything works well. How do I solve it?
Upvotes: 2
Views: 589
Reputation: 479
g++ a.cpp -o a -I /usr/include/python2.7/ -lboost_python -lpython2.7 -lboost_system -fPIC
I added -lpython2.7 and now its working
Upvotes: 0
Reputation: 393134
Drop the -shared
flag on the executable:
http://coliru.stacked-crooked.com/a/5479166d518fb207
Upvotes: 1