LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-11-2012, 04:00 PM   #1
shahidiqbal
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Rep: Reputation: Disabled
embedd ing python in C


hello , I am trying to embedd python in C and compiling it ,and showing this result ,is there any flag will b used or something else
In function `main':
py.c.text+0x17): undefined reference to `Py_Initialize'
py.c.text+0x26): undefined reference to `PyRun_SimpleStringFlags'
py.c.text+0x2b): undefined reference to `Py_Finalize'
collect2: ld returned 1 exit status
 
Old 04-11-2012, 06:18 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

Rep: Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892
Quote:
hello , I am trying to embedd python in C and compiling it ,and showing this result ,is there any flag will b used or something else
In function `main':
py.c.text+0x17): undefined reference to `Py_Initialize'
py.c.text+0x26): undefined reference to `PyRun_SimpleStringFlags'
py.c.text+0x2b): undefined reference to `Py_Finalize'
collect2: ld returned 1 exit status
Not knowing WHICH flags you used when compiling this will be hard to answer.

From the looks of it your linker can't find the library that provides the
functions you're trying to use.


Cheers,
Tink


P.S.: Moving this to programming, as it's not actually a software question
but a coding one.

P.P.S.: Please wrap your output into CODE tags ....
 
Old 04-11-2012, 07:04 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
You need to use the various flags provided by the python-config program, e.g.
Code:
gcc `python-config --cflags` myprog.c -o myprog `python-config --ldflags`
Kevin Barry

Last edited by ta0kira; 04-11-2012 at 08:25 PM.
 
  


Reply


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
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 09:30 PM
grep'ing and sed'ing chunks in bash... need help on speeding up a log parser. elinenbe Programming 4 04-22-2009 11:17 AM
[Ruby] Tar'ing or Zip'ing with ruby script lmcilwain Programming 2 01-19-2007 07:56 PM
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 08:54 PM
need help with tar'ing and bz2'ing a file surfbass Linux - General 4 06-01-2005 06:07 PM


All times are GMT -5. The time now is 10:31 AM.

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