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 8602141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:00:36+00:00 2026-06-12T02:00:36+00:00

I have written a Python C module (just ffmpeg.c which depends on some FFmpeg

  • 0

I have written a Python C module (just ffmpeg.c which depends on some FFmpeg libs and other libs) and I am wondering how to link.

I’m compiling with:

cc -std=c99 -c ../ffmpeg.c -I /usr/include/python2.7 -g

I’m trying to link right now with:

ld -shared -o ../ffmpeg.so -L/usr/local/lib -lpython2.7 -lavutil -lavformat -lavcodec -lswresample -lportaudio -lchromaprint ffmpeg.o -lc

There is no error. However, when I try to import ffmpeg in Python, I get:

ImportError: ./ffmpeg.so: undefined symbol: avio_alloc_context


Maybe this is already correct. I checked the resulting ffmpeg.so with ldd and it partly links to a wrong FFmpeg. This is strange however because of the -L/usr/local/lib which should take precedence over the default. Maybe because my custom installed FFmpeg (in /usr/local/lib) has for some reason only installed static *.a libs and *.so files have precedence over *.a files.

  • 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-12T02:00:37+00:00Added an answer on June 12, 2026 at 2:00 am

    You should put the libraries that you’re linking to after the .o file; i.e.:

    ld -shared -o ../ffmpeg.so ffmpeg.o -L/usr/local/lib -lpython2.7 -lavutil -lavformat -lavcodec -lswresample -lportaudio -lchromaprint -lc
    

    The linker is dumb, and will not link in code from static libraries that it doesn’t think are needed until a dependency arises i.e. the use of avio_alloc_context happens in ffmpeg.o, and because it’s not listed after the use of the library, then the linker will not consider the code in the library as needed, so it doesn’t get linked in – this is the biggest reason why linking using .a files fails.

    You can also use --start-group and --end-group around all the files that you are linking – this allows you to link static libraries that have cross dependencies that just seem impossible to resolve through other means:

    ld -shared -o ../ffmpeg.so -L/usr/local/lib -lpython2.7 --start-group -lavutil -lavformat -lavcodec -lswresample -lportaudio -lchromaprint ffmpeg.o --end-group -lc
    

    using .a files is a little bit trickier than .so files, but these two items generally will work around any issues you have when linking.

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

Sidebar

Related Questions

I have written a module in python which performs some function. I then created
I have some python module, which has a class ModuleClass and I can't modify
I have written a Python module which contains functions that return arrays. I want
I have written a Python module, and I have two versions: a pure Python
I have written some Python scripts in Eclipse where at some point I have
I have written a python script which watches a directory for new subdirectories, and
I have a series of python modules written which are held in the same
I have written a python package which consists of several .py files which contain
I have written some C++ code that generates a std::vector. I also have a
I have written a python script to parse an HTML page, get some strings

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.