Python Embedding Help...

This is a discussion on Python Embedding Help... within the C Programming forums, part of the General Programming Boards category; Hi I usually programme in Python. In the help files, theres an example on how to embed Python into a ...

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

    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.
    Code:
    #include <Python.h>
    
    int
    main(int argc, char *argv[])
    {
      Py_Initialize();
      PyRun_SimpleString("from time import time,ctime\n"
                         "print 'Today is',ctime(time())\n");
      Py_Finalize();
      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
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    I don't know the Dev-Cpp IDE but it looks that you're just compiling. Try building the project.
    Kurt

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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.

    --
    Mats
    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, 11:40 AM
  3. Python
    By mart_man00 in forum Tech Board
    Replies: 7
    Last Post: 10-06-2003, 08:24 AM
  4. Python
    By Xterria in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 05-05-2002, 05:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21