ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
cc -I /usr/include/python2.7 hello.c -o hello
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/tmp/cckpGD49.o: In function `__pyx_pf_11hello_world_10HelloWorld_hello':
hello.c:(.text+0x3b): undefined reference to `PyDict_Size'
hello.c:(.text+0x5a): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0xcd): undefined reference to `PyDict_GetItem'
hello.c:(.text+0xfb): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x17c): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x219): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x2fe): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x303): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x30b): undefined reference to `_Py_NoneStruct'
/tmp/cckpGD49.o: In function `__pyx_pf_11hello_world_10HelloWorld_1delete_event':
hello.c:(.text+0x35e): undefined reference to `PyDict_Size'
hello.c:(.text+0x384): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x405): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x433): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x4ae): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x52f): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x5d2): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x6dd): undefined reference to `_Py_ZeroStruct'
hello.c:(.text+0x6eb): undefined reference to `_Py_ZeroStruct'
/tmp/cckpGD49.o: In function `__pyx_pf_11hello_world_10HelloWorld_2destroy':
hello.c:(.text+0x7ba): undefined reference to `PyDict_Size'
hello.c:(.text+0x7d9): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x84c): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x87a): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x8fb): undefined reference to `PyDict_GetItem'
hello.c:(.text+0x998): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0xa8b): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0xb09): undefined reference to `PyObject_Call'
hello.c:(.text+0xb9d): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0xba2): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0xbaa): undefined reference to `_Py_NoneStruct'
/tmp/cckpGD49.o: In function `__pyx_pf_11hello_world_10HelloWorld_3__init__':
hello.c:(.text+0xca6): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0xd67): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0xdd5): undefined reference to `PyTuple_New'
hello.c:(.text+0xe33): undefined reference to `PyObject_Call'
hello.c:(.text+0xede): undefined reference to `PyObject_SetAttr'
hello.c:(.text+0xf47): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0xf8f): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1005): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1045): undefined reference to `PyTuple_New'
hello.c:(.text+0x10bb): undefined reference to `PyObject_Call'
hello.c:(.text+0x118d): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x11d5): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x124b): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x128b): undefined reference to `PyTuple_New'
hello.c:(.text+0x1301): undefined reference to `PyObject_Call'
hello.c:(.text+0x13d3): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x141b): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1499): undefined reference to `PyObject_Call'
hello.c:(.text+0x1588): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1606): undefined reference to `PyObject_Call'
hello.c:(.text+0x1683): undefined reference to `PyObject_SetAttr'
hello.c:(.text+0x16ec): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1734): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x17aa): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x17ea): undefined reference to `PyTuple_New'
hello.c:(.text+0x1844): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x184c): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x1856): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x1877): undefined reference to `PyObject_Call'
hello.c:(.text+0x1949): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1991): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1a52): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1ac8): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1b3e): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1b7e): undefined reference to `PyTuple_New'
hello.c:(.text+0x1c04): undefined reference to `PyObject_Call'
hello.c:(.text+0x1cd6): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1d1e): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1d94): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1dd4): undefined reference to `PyTuple_New'
hello.c:(.text+0x1e32): undefined reference to `PyObject_Call'
hello.c:(.text+0x1f04): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1f4c): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x1fca): undefined reference to `PyObject_Call'
hello.c:(.text+0x206e): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x20b6): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x2134): undefined reference to `PyObject_Call'
hello.c:(.text+0x21c8): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x21cd): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x21d5): undefined reference to `_Py_NoneStruct'
/tmp/cckpGD49.o: In function `__pyx_pf_11hello_world_10HelloWorld_4main':
hello.c:(.text+0x2320): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x239e): undefined reference to `PyObject_Call'
hello.c:(.text+0x2432): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x2437): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x243f): undefined reference to `_Py_NoneStruct'
/tmp/cckpGD49.o: In function `__Pyx_InitCachedConstants':
hello.c:(.text+0x24cf): undefined reference to `PyTuple_New'
hello.c:(.text+0x252e): undefined reference to `PyTuple_New'
hello.c:(.text+0x258a): undefined reference to `PyTuple_New'
/tmp/cckpGD49.o: In function `__Pyx_InitGlobals':
hello.c:(.text+0x262a): undefined reference to `PyInt_FromLong'
/tmp/cckpGD49.o: In function `inithello_world':
hello.c:(.text+0x268e): undefined reference to `PyTuple_New'
hello.c:(.text+0x26db): undefined reference to `PyString_FromStringAndSize'
hello.c:(.text+0x276c): undefined reference to `Py_InitModule4'
hello.c:(.text+0x27b5): undefined reference to `PyImport_AddModule'
hello.c:(.text+0x2805): undefined reference to `PyObject_SetAttrString'
hello.c:(.text+0x2883): undefined reference to `PyObject_SetAttrString'
hello.c:(.text+0x296f): undefined reference to `PyObject_SetAttr'
hello.c:(.text+0x2a23): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x2aa1): undefined reference to `PyObject_Call'
hello.c:(.text+0x2b98): undefined reference to `PyObject_SetAttr'
hello.c:(.text+0x2bf2): undefined reference to `PyDict_New'
hello.c:(.text+0x2c92): undefined reference to `PyObject_SetItem'
hello.c:(.text+0x2d53): undefined reference to `PyObject_SetItem'
hello.c:(.text+0x2e14): undefined reference to `PyObject_SetItem'
hello.c:(.text+0x2ed5): undefined reference to `PyObject_SetItem'
hello.c:(.text+0x2f96): undefined reference to `PyObject_SetItem'
hello.c:(.text+0x3065): undefined reference to `PyObject_SetAttr'
hello.c:(.text+0x314f): undefined reference to `PyObject_RichCompare'
hello.c:(.text+0x328b): undefined reference to `PyObject_Call'
hello.c:(.text+0x330b): undefined reference to `PyObject_SetAttr'
hello.c:(.text+0x33bf): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x343d): undefined reference to `PyObject_Call'
hello.c:(.text+0x34d3): undefined reference to `PyDict_New'
hello.c:(.text+0x3522): undefined reference to `PyObject_SetAttr'
hello.c:(.text+0x3620): undefined reference to `PyErr_Occurred'
hello.c:(.text+0x3629): undefined reference to `PyExc_ImportError'
hello.c:(.text+0x3639): undefined reference to `PyErr_SetString'
/tmp/cckpGD49.o: In function `__Pyx_RaiseArgtupleInvalid':
hello.c:(.text+0x368c): undefined reference to `PyExc_TypeError'
hello.c:(.text+0x36bf): undefined reference to `PyErr_Format'
/tmp/cckpGD49.o: In function `__Pyx_RaiseDoubleKeywordsError':
hello.c:(.text+0x36d2): undefined reference to `PyExc_TypeError'
hello.c:(.text+0x36ed): undefined reference to `PyErr_Format'
/tmp/cckpGD49.o: In function `__Pyx_ParseOptionalKeywords':
hello.c:(.text+0x3771): undefined reference to `PyString_Type'
hello.c:(.text+0x37cb): undefined reference to `_PyString_Eq'
hello.c:(.text+0x384b): undefined reference to `_PyString_Eq'
hello.c:(.text+0x387e): undefined reference to `PyDict_SetItem'
hello.c:(.text+0x38ae): undefined reference to `PyDict_Next'
hello.c:(.text+0x38de): undefined reference to `PyExc_TypeError'
hello.c:(.text+0x38f5): undefined reference to `PyErr_Format'
hello.c:(.text+0x3903): undefined reference to `PyString_AsString'
hello.c:(.text+0x3909): undefined reference to `PyExc_TypeError'
hello.c:(.text+0x3924): undefined reference to `PyErr_Format'
/tmp/cckpGD49.o: In function `__Pyx_GetName':
hello.c:(.text+0x3946): undefined reference to `PyObject_GetAttr'
hello.c:(.text+0x3954): undefined reference to `PyExc_NameError'
hello.c:(.text+0x3963): undefined reference to `PyErr_SetObject'
/tmp/cckpGD49.o: In function `__Pyx_Import':
hello.c:(.text+0x39a6): undefined reference to `PyObject_GetAttrString'
hello.c:(.text+0x39cd): undefined reference to `PyList_New'
hello.c:(.text+0x39e9): undefined reference to `PyModule_GetDict'
hello.c:(.text+0x39f7): undefined reference to `PyDict_New'
hello.c:(.text+0x3a2f): undefined reference to `PyObject_CallFunctionObjArgs'
/tmp/cckpGD49.o: In function `__Pyx_FindPy2Metaclass':
hello.c:(.text+0x3b08): undefined reference to `PyObject_GetAttrString'
hello.c:(.text+0x3b16): undefined reference to `PyErr_Clear'
hello.c:(.text+0x3b28): undefined reference to `PyClass_Type'
/tmp/cckpGD49.o: In function `__Pyx_CreateClass':
hello.c:(.text+0x3b5d): undefined reference to `PyDict_SetItemString'
hello.c:(.text+0x3b7e): undefined reference to `PyDict_GetItemString'
hello.c:(.text+0x3bcc): undefined reference to `PyObject_CallFunctionObjArgs'
/tmp/cckpGD49.o: In function `__pyx_binding_PyCFunctionType_NewEx':
hello.c:(.text+0x3c0e): undefined reference to `_PyObject_GC_New'
hello.c:(.text+0x3c6a): undefined reference to `PyObject_GC_Track'
/tmp/cckpGD49.o: In function `__pyx_binding_PyCFunctionType_dealloc':
hello.c:(.text+0x3c80): undefined reference to `PyObject_GC_UnTrack'
hello.c:(.text+0x3cf3): undefined reference to `PyObject_GC_Del'
/tmp/cckpGD49.o: In function `__pyx_binding_PyCFunctionType_descr_get':
hello.c:(.text+0x3d02): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x3d24): undefined reference to `PyMethod_New'
/tmp/cckpGD49.o: In function `__pyx_binding_PyCFunctionType_init':
hello.c:(.text+0x3d39): undefined reference to `PyCFunction_Type'
hello.c:(.text+0x3d70): undefined reference to `PyType_Ready'
/tmp/cckpGD49.o: In function `__Pyx_GetStdout':
hello.c:(.text+0x3da4): undefined reference to `PySys_GetObject'
hello.c:(.text+0x3db2): undefined reference to `PyExc_RuntimeError'
hello.c:(.text+0x3dc2): undefined reference to `PyErr_SetString'
/tmp/cckpGD49.o: In function `__Pyx_Print':
hello.c:(.text+0x3e0a): undefined reference to `PyFile_SoftSpace'
hello.c:(.text+0x3e21): undefined reference to `PyFile_WriteString'
hello.c:(.text+0x3e56): undefined reference to `PyFile_WriteObject'
hello.c:(.text+0x3e81): undefined reference to `PyString_AsString'
hello.c:(.text+0x3e8f): undefined reference to `PyString_Size'
hello.c:(.text+0x3ee4): undefined reference to `PyFile_SoftSpace'
hello.c:(.text+0x3f10): undefined reference to `PyFile_WriteString'
hello.c:(.text+0x3f2e): undefined reference to `PyFile_SoftSpace'
/tmp/cckpGD49.o: In function `__Pyx_PrintOne':
hello.c:(.text+0x3f69): undefined reference to `PyFile_SoftSpace'
hello.c:(.text+0x3f80): undefined reference to `PyFile_WriteString'
hello.c:(.text+0x3fa5): undefined reference to `PyFile_WriteObject'
hello.c:(.text+0x3fc3): undefined reference to `PyFile_WriteString'
/tmp/cckpGD49.o: In function `__Pyx_AddTraceback':
hello.c:(.text+0x400e): undefined reference to `PyString_FromString'
hello.c:(.text+0x404a): undefined reference to `PyString_FromFormat'
hello.c:(.text+0x405a): undefined reference to `PyString_FromString'
hello.c:(.text+0x4074): undefined reference to `PyModule_GetDict'
hello.c:(.text+0x410e): undefined reference to `PyCode_New'
hello.c:(.text+0x411c): undefined reference to `_PyThreadState_Current'
hello.c:(.text+0x413a): undefined reference to `PyFrame_New'
hello.c:(.text+0x415a): undefined reference to `PyTraceBack_Here'
/tmp/cckpGD49.o: In function `__Pyx_InitStrings':
hello.c:(.text+0x4264): undefined reference to `PyUnicodeUCS4_DecodeUTF8'
hello.c:(.text+0x4286): undefined reference to `PyString_InternFromString'
hello.c:(.text+0x42aa): undefined reference to `PyString_FromStringAndSize'
/tmp/cckpGD49.o: In function `__Pyx_PyObject_IsTrue':
hello.c:(.text+0x42e7): undefined reference to `_Py_TrueStruct'
hello.c:(.text+0x42f7): undefined reference to `_Py_ZeroStruct'
hello.c:(.text+0x4309): undefined reference to `_Py_NoneStruct'
hello.c:(.text+0x4325): undefined reference to `PyObject_IsTrue'
collect2: ld returned 1 exit status
make: *** [hello] Error 1
I don't know about your familiarity with C, but I will point out that any C program must have a function 'main()', and that is the default entry point for the program. The C code that you've generated doesn't have any such function, and that accounts for the error about not finding it.
I don't know anything about Cython, but I can speculate about a couple of ideas. It seems possible that you must explicitly tell Cython to generate code that includes a main() function. It is also possible that you must tell the linker to include a support library that may include the main() function and possibly also includes definitions for the other symbols listed in the error output. If the latter is the case, you could potentially build the program by adding the library to the make commandline:
Code:
make CFLAGS+='-I /usr/include/python2.7' LDFLAGS+='-L /some/path/to/cython/libs -lcythonSupport' hello
I made up the name of the library, of course. If it were a real library, its full name would actually be 'libcythonSupport.so', and make/gcc would know what the notation I used means.
I would consult the Cython documentation to see if this kind of thing is discussed.
i did as you said and then i ran the python in shell.i could import hello_world and i could run my program. but my question is how can i run the c version?
there's a hello_world.c file generated by the process you said, but i don't know how to run it !!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.