Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8076795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:20:22+00:00 2026-06-05T15:20:22+00:00

I have a C program with embedded python code. I have compiled python 2.7.2

  • 0

I have a C program with embedded python code. I have compiled python 2.7.2 from source and linked my program against libpython2.7.a.

Now in my python code I wish to call back functions from other C libraries linked into my C program. I can write a python extension (see Extending Embedded Python in this document). However, ctypes would make this a lot easier and would allow me to use some existing code unchaged.

ctypes is geared towards loading shared libraries and I was wondering if there was a way to ‘point’ it back to my static program code.

I cannot compile the relevant code into a shared library because my target is iOS and AFAIK shared libraries are forbidden by Apple.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:20:24+00:00Added an answer on June 5, 2026 at 3:20 pm

    From Python code, you can create ctypes wrappers for static functions like this:

    restype = ctypes.c_int
    argtypes = [ctypes.c_int, ctypes.c_double]        # or whatever
    functype = ctypes.CFUNCTYPE(restype, *argtypes)
    wrapper = functype(address_of_static_function_as_an_int)
    

    You can of course call this (or similar) code from your C code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an embedded python interpreter in my program. I'd like to export a
I have a python program in an embedded system that needs to write to
I have embedded a Python interpreter in a C program. Suppose the C program
In an embedded program I have a screen object that needs to manage a
I have program that I want to test on clean Windows installation. For now
I have a program that reads approximately 2million rows from a database into a
I have an C++ program that runs on an embedded system. When the client
I have a desktop program which uses an embedded data base mechanism. For the
Here is canonical example of a program extending embedded Python 3.x in C/C++: #include
I have a C# project in which I have embedded an IronRuby program. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.