I am using ubuntu hardy
and python 2.6.5 (built from sources). For a custom python packager I need to rebuild python interpreter (python executable). I am new to linux and don't have much knowledge of gcc and other stuff. Here is the process:
1. Copy python.c as myapp.c. myapp.c is in the same directory (python2.6.5) in which I have all the required files.
2. Using the syntax from makefile of python sources, here is my first command to produce myapp.o
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I/home/zeno/installed/Python-2.6.5/Include -fPIC -DPy_BUILD_CORE -c myapp.c -o myapp.o
This produce myapp.o but throws a warning:
myapp.c:24:2: warning: no newline at end of file
Next is to produce the executable or python interpreter:
gcc -pthread -Xlinker -export-dynamic -o $@ myapp.o -L. -lpython2.6 -lpthread -ldl -lutil -lm -o myapp
This is causing an error:
/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
I am missing something in these two commands specially in the second one. I hope some one shed some light here:
BTW, here is myapp.c. It's a copy of python.c
/* Minimal main program -- everything is loaded from the library */
main(int argc, char **argv)
/* 754 requires that FP exceptions run in "no stop" mode by default,
* and until C vendors implement C99's ways to control FP exceptions,
* Python requires non-stop mode. Alas, some platforms enable FP
* exceptions by default. Here we disable them.
m = fpgetmask();
fpsetmask(m & ~FP_X_OFL);
return Py_Main(argc, argv);