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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:36:01+00:00 2026-06-18T12:36:01+00:00

I am trying to compile a C++ extension using Swig for Mac OS X.

  • 0

I am trying to compile a C++ extension using Swig for Mac OS X. I have run into a few linker errors though. The basic tutorial for Python Swig also seems to fail on Mac:

http://www.swig.org/Doc1.3/Python.html#Python_nn10

swig -c++ -python example.i
g++ -O2 -fPIC -c example.cxx
g++ -O2 -fPIC -c example_wrap.cxx -I/usr/include/python2.6
g++ -shared example.o example_wrap.o -o _example.so

The first three lines work fine. The last line fails with a linker error. I tried the last line on OS X with this, and got the same error:

g++ -dynamiclib example.o example_wrap.o -o _example.so

The error from the last line is:

Undefined symbols for architecture x86_64:
  "_PyArg_ParseTuple", referenced from:
      __wrap_fact in example_wrap.o
  "_PyArg_UnpackTuple", referenced from:
      _SwigPyObject_own in example_wrap.o
  "_PyBool_FromLong", referenced from:
      _SwigPyObject_richcompare in example_wrap.o
      _SwigPyObject_own in example_wrap.o
...
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

Thanks.

  • 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-18T12:36:03+00:00Added an answer on June 18, 2026 at 12:36 pm

    For completeness — thanks Petesh.

    swig -c++ -python example.i
    g++ -O2 -fPIC -c example.cxx
    g++ -O2 -fPIC -c example_wrap.cxx -I/usr/include/python2.6
    g++ -lpython -dynamiclib example.o example_wrap.o -o _example.so
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a C++ extension for python using swig. I've followed the
I have been having a terrible time trying to compile a python extension -
I am trying to get the basic Cython tutorial to work. So I have
I'm using the Razor Single File Generator VS extension to pre-compile my views into
I'm trying to compile a program to run on an AT90CAN128 using the ATMEL
I'm trying to compile a Python project (using Python 2.7 on Windows XP) into
I am trying to load a PHP extension made using SWIG, but I am
When trying to compile this code: #include <iostream> #include <vector> using namespace std; class
While trying to compile a 64 bit linux kernel using gcc, I see the
I'm trying to create an extension method using CodeDOM. There doesn't seem to be

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.