By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,482 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,482 IT Pros & Developers. It's quick & easy.

Distutils on windows with mingw, messed up includes?

P: 1
Hi,

I am pretty lost here: My goal is to get an existing c++ library wrapped using distutils and swig. My C++ knowlege is very limited (so is my Python).

So I started with trying to wrap a single class from the library (I already have a simple example .cpp file packed into a .pyd correctly and it works fine with ipython) but when trying to do the same with this one:

Expand|Select|Wrap|Line Numbers
  1. #include "jcnError.h"
  2.  
  3. jcnError::jcnError(const string& message, const ErrorType& errorType)
  4. : std::runtime_error(message), mErrorMessage(message), mErrorType(errorType)
  5. {
  6. }
  7.  
  8. const char* jcnError::what(void) const throw()
  9. {
  10.     return std::runtime_error::what();
  11. }
  12.  
  13. jcnError::~jcnError(void) throw()
  14. {
  15. }
  16.  
I get an error from gcc: "iostream: no such file or directory". The includes are where they are supposed to be and with the -v option gcc tells me that it searches there as well, so what is the problem?

Here is the header:
Expand|Select|Wrap|Line Numbers
  1. #pragma once
  2.  
  3. #include <iostream>
  4. #include <string>
  5. #include <stdexcept>
  6.  
  7. using namespace std;
  8.  
  9. #define jcn_DEBUG /**< If this is defined more error messages will be thrown */
  10.  
  11. /**
  12. * Internal type of error
  13. */
  14. enum ErrorType 
  15. {
  16.     WARNING,
  17.     EXCEPTION,
  18. };
  19.  
  20. /**
  21. * @class jcnError
  22. * @author Jan C. Neddermeyer
  23. * @brief jcnError is inherited from the std error class runtime_error
  24. */
  25. class jcnError :
  26.     public runtime_error
  27. {
  28. public:
  29.     /**
  30.     * Constructor
  31.     * @param message error message, should provide detailed information where and why an error has been thrown
  32.     * @param errorType optional error type
  33.     */
  34.     jcnError(const string& message, const ErrorType& errorType = EXCEPTION);
  35.  
  36.     /**
  37.     * @return error message, corresponds to the what() method in runtime_error
  38.     */
  39.     virtual const char* what(void) const throw();
  40.  
  41.     /**
  42.     * @return error message as std::string
  43.     */
  44.     inline const string GetMessage(void) const {return mErrorMessage;};
  45.  
  46.     /**
  47.     * @return error type
  48.     */
  49.     inline const ErrorType GetErrorType(void) const {return mErrorType;};
  50.  
  51.     /**
  52.     * Destructor
  53.     */
  54.     ~jcnError(void) throw();
  55.  
  56. private:
  57.     string mErrorMessage; /**< error message */
  58.     ErrorType mErrorType; /**< error type */
  59. };
  60.  
and here my setup.py
Expand|Select|Wrap|Line Numbers
  1. import distutils
  2. from distutils.core import setup, Extension
  3.  
  4. module=Extension('_bpetest',sources=['bpe.i','jcnError.cpp'],include_dirs=['C:/users/kevin/Desktop/bpe_demo/src'])
  5.  
  6. setup(name="bpetest", version="3.2", ext_modules=[module])
  7.  
and finally the bpe.i:
Expand|Select|Wrap|Line Numbers
  1. %module bpetest
  2. %{
  3. #include "jcnError.h"
  4. %}
  5.  
all help appreciated,

thanks,

Kevin
Apr 2 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.