Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use Arch Linux. I want to compile a C++ file that includes <Python.h>. But I can't do it.

In Debian based systems this problem is resolved with sudo apt-get install python-dev. How I can install this package with pacman?

* EDIT *

I wan't to compile this file

C.c

#include "Python.h"
int main(int argc, char *argv[])
{
  Py_SetProgramName(argv[0]);  /* optional but recommended */
  Py_Initialize();
  PyRun_SimpleString("from time import time,ctime\n"
                     "print 'Today is',ctime(time())\n");
  Py_Finalize();
  return 0;
}

run this command:

g++ C.c

and i have this error:

call_function.c:1:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.
share|improve this question
2  
Both the python and python2 package in Arch Linux contain a Python.h file, you don't need an extra package. What's the exact error message you're getting and what is your include path? –  Wieland Dec 8 '13 at 23:11
    
I can't compile this #include<Python.h> with gcc –  2 8 Dec 9 '13 at 5:42
    
@28 just tell us what Wieland asked you to tell. –  Risto Salminen Dec 9 '13 at 6:16
    
I edit this question –  2 8 Dec 9 '13 at 10:14
add comment

1 Answer

You should compile your files with libs and cflags provided by python package:

gcc py.c $(pkg-config --cflags --libs python2) -o py

Besides, it should be #include <Python.h> instead.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.