LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-26-2010, 11:55 AM   #1
tank junior
Member
 
Registered: Apr 2010
Posts: 42

Rep: Reputation: 0
Build ONLY python interpreter


Hi,

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

Code:
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:
Code:
myapp.c:24:2: warning: no newline at end of file
Next is to produce the executable or python interpreter:
Code:
gcc -pthread -Xlinker -export-dynamic -o $@ myapp.o -L. -lpython2.6 -lpthread -ldl -lutil -lm -o myapp
This is causing an error:
Code:
/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
Code:
/* Minimal main program -- everything is loaded from the library */

#include "Python.h"

#ifdef __FreeBSD__
#include <floatingpoint.h>
#endif

int
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.
	 */
#ifdef __FreeBSD__
	fp_except_t m;

	m = fpgetmask();
	fpsetmask(m & ~FP_X_OFL);
#endif
	return Py_Main(argc, argv);
}
Cheers

Prashant
 
Old 12-02-2010, 06:09 PM   #2
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
Make sure you have build-essential installed. You may also need various -dev packages.

Generally, I'd recommend against using gcc directly on someone else's project. Usually "./configure.sh" and "make test" suffice. It sounds like you might be using a tutorial somewhere. If so, it might help if you shared it.

Virtualenv is another tool that you might find interesting. It can be used to distribute the python interpreter, along with system and site packages. This eliminates many (but not all) system dependencies. It does eliminate any dependencies on the local python installation. (I haven't used it directly, but have relied on it as part of the go-pylons.py script.)
 
  


Reply

Tags
gcc, python


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Interpreter: load latest command? raskol Programming 6 04-10-2008 12:02 PM
howto build python with sqlite support? b3rx Slackware 4 12-03-2007 07:57 PM
python limits in the interpreter avallach Programming 3 07-30-2007 08:29 AM
Where is the Python Interpreter? Chomper Programming 8 01-15-2005 09:56 PM
Does Python interpreter have weird delay? lugoteehalt Programming 4 11-12-2003 01:43 PM


All times are GMT -5. The time now is 07:16 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration