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

  • Home
  • SEARCH
  • 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 9186739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:36:20+00:00 2026-06-17T19:36:20+00:00

Here is my problem : I have to call an algo written in C

  • 0

Here is my problem : I have to call an algo written in C with python.
I use swig to do it.

So I have an example.i file which looks like this

%module example
%{
    #include "example.h"
%}
%include "example.h"

My example.h file is very simple

#ifndef EXAMPLE
#define EXAMPLE

#include <gmp.h>

// function that needs gmp library
void myFunction();

#endif

When I have to compile I run

swig -python example.i
gcc -fpic -std=c99 -c example.c example_wrap.c -I/usr/include/python2.7/    
gcc -shared example.o example_wrap.o -o -lgmp _example.so

Everything is fine so far, but then when I try to import example in python there is an error
ImportError: example.so: undefined symbol: __gmpf_cmp

So there is something wrong with the link between swig and gmp library but I have no idea where the bug comes from.

python -V
2.7.3

swig -version
SWIG Version 2.0.4

ubuntu 12.04

Any help would be greatly appreciated.

Thanks in advance,

Victor

  • 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-17T19:36:21+00:00Added an answer on June 17, 2026 at 7:36 pm

    You seem to have mis-ordered the -lgmp flag so that it sits between -o and the library name. Probably would work better if you do:

    gcc -shared example.o example_wrap.o -lgmp -o _example.so
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So here's the problem: I have written an application to call the Fedex shipping
Here is my problem : I have a list of messages which I can
Here's my problem: I have do create a menu/list of actions (which would be
Here's the problem: I have couple of pages which gets its content from a
Ok, here's the problem: I have a list of contacts, which i have created
Here is an abstract example of my problem: I have a general class (
Here is my problem: I have an n-tiers application for which I have to
Here's my problem: I have 2 projects - one 'common' projects with acts like
Here's my problem: I have two .xsd files, let's call them a.xsd and b.xsd.
Here's my problem: I have to call a web service with a secure header

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.