Thread: Python Embedding Help...

  1. #1
    Registered User Rendered's Avatar
    Join Date
    Sep 2007

    Thumbs up Python Embedding Help...

    Hi I usually programme in Python. In the help files, theres an example on how to embed Python into a C command-line app.
    How ever when I try it I get many errors.
    #include <Python.h>
    main(int argc, char *argv[])
      PyRun_SimpleString("from time import time,ctime\n"
                         "print 'Today is',ctime(time())\n");
      return 0;
    I get the error "undefined referrence to imp_py_finalize"
    So I searched a lot. I finnaly found the answer. It said that the linker cant find the Python
    library file. So I copied that file to my Lib folder. Now I get this error
    "gcc: -lobjc: linker input file unused since linking not done"
    I'm using Dev-Cpp as my IDE and the GCC version that comes with Dev-Cpp.
    Please help!

  2. #2
    Registered User
    Join Date
    Aug 2005
    I don't know the Dev-Cpp IDE but it looks that you're just compiling. Try building the project.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    You get the "linker input file unused since linking not done" error when you put object files or libraries on a "gcc -c" line. You probably need to add it to your "link" command, rather than your "compile" command. And if the file is in a "unusual" directory, the right thing is to add "-L/somepath/somewhere" to your link command arguments. That will make the linker look in /somepath/somewhere as well as all the other "usual" places for the library files.

    Since I don't use Dev-Cpp myself, I don't actually know how you go about setting those settings.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. python c api
    By ralu. in forum C Programming
    Replies: 0
    Last Post: 03-01-2009, 01:19 PM
  2. Embedding Python - Link error
    By cboard_member in forum C++ Programming
    Replies: 0
    Last Post: 06-09-2006, 10:40 AM
  3. Python
    By mart_man00 in forum Tech Board
    Replies: 7
    Last Post: 10-06-2003, 07:24 AM
  4. Python
    By Xterria in forum A Brief History of
    Replies: 10
    Last Post: 05-05-2002, 04:08 PM