1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

C \ Python Interface

Discussion in 'Software Development' started by -Fabez-, Oct 19, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. -Fabez-

    -Fabez- Thread Starter

    Joined:
    Jul 28, 2008
    Messages:
    1,899
    I am trying to use some Python functions from C, using Dev C++ compiler. However, everything I try does not work, as it gives me a compiler and linker error, every time I try to compile the C code. Any input or help would be much appreciated. Thanks -Fabez-
     
  2. IMM

    IMM

    Joined:
    Feb 1, 2002
    Messages:
    3,257
  3. -Fabez-

    -Fabez- Thread Starter

    Joined:
    Jul 28, 2008
    Messages:
    1,899
    Sorry, the code I am trying to compile is.

    Code:
    #include "Python.h"
    #include <stdio.h>
    int main(){
        Py_Initialize();
        PyRun_SimpleString("Test=[1,2,3,4]");
        Py_Finalize();
    }
    And the error's I am getting are.

    Code:
    [Linker error] undefined reference to `_imp__Py_Initialize' 
      [Linker error] undefined reference to `_imp__PyRun_SimpleStringFlags' 
      [Linker error] undefined reference to `_imp__Py_Finalize' 
      ld returned 1 exit status
     
  4. mt2002

    mt2002

    Joined:
    Sep 14, 2005
    Messages:
    919
    It sounds like you are not linking the correct python libraries.
     
  5. -Fabez-

    -Fabez- Thread Starter

    Joined:
    Jul 28, 2008
    Messages:
    1,899
    Thanks :D How would I link them ? The Python include directory is listed under the include options for Dev C++, but it still does not work.
     
  6. mt2002

    mt2002

    Joined:
    Sep 14, 2005
    Messages:
    919
    The linker does not use include files nor know what they are. You need to link in the library files (Usually static library files, which are *.lib) within your linker settings.

    I never used Dev-C++ though so cannot directly help with that :) I can see if I can post a link to a tutorial (or similar) later if you are still having the problems later ;)
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/760601

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice