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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:29:26+00:00 2026-06-04T14:29:26+00:00

After successfully compiling a Python/C binding with SIP I wanted to do the same

  • 0

After successfully compiling a Python/C binding with SIP I wanted to do the same thing with Python/C++. For some reason this doesn’t work.

Here’s the files:

fib.cpp

#include "fib.h"

int fib1(int n)
{
    if (n <= 0) {
        return 0;
    } else if (n <= 2) {
        return 1;
    } else {
        return fib1(n-1) + fib1(n-2);
    }
}

fib.h

int fib1(int n);

fib.sip

%Module fib

%Include fib.h

I run the following command to build the intermediate files:
sip -c . fib.sip

So far everything works.

Now I want to build the .pyd file using distutils.

setup.py

from distutils.core import setup, Extension
import sipdistutils

setup(
  name = 'fib',
  versione = '1.0',
  ext_modules=[
    Extension("fib", ["fib.sip", "fib.cpp"]),
    ],

   cmdclass = {'build_ext': sipdistutils.build_ext}
 )

I run the following command:
python setup.py build

This fails with the following error:

build\temp.win32-2.7\Release\sipfibcmodule.cpp:29:29: error: 'fib1' was not declared in this scope
error: command 'gcc' failed with exit status 1

What could the problem be? Shouldn’t c++ be used as a compiler instead of gcc, by the way?

Any help appreciated!

Kind regards

David

  • 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-04T14:29:28+00:00Added an answer on June 4, 2026 at 2:29 pm

    I’ve found a solution that is good enough: namespaces. Next time I’ll read the documentation better. I should also mention that a solution with a Fibonacci class could solve the problem, but I didn’t find that to be satisfying.

    Below the content of the files can be found.

    fib.cpp

    #include "fib.h"
    
    namespace test
    {
        int fib1(int n)
        {
            if (n <= 0) {
                return 0;
            } else if (n <= 2) {
                return 1;
            } else {
                return fib1(n-1) + fib1(n-2);
            }
        }
    }
    

    fib.h

    namespace test
    {
        int fib1(int n);
    }
    

    fib.sip

    %Module fib
    
    namespace test {
        %TypeHeaderCode
        #include "fib.h"
        %End
    
        int fib1(int n);
    };
    

    setup.py – nothing was changed

    Exactly the same commands as mentioned before were used.

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

Sidebar

Related Questions

After successfully creating some applets, I embedded them in a webpage and discovered that
after successfully building my application the start fails because it relies on config files
I'm using NetDataContractSerializer . After successfully deserializing an object, is there a way to
I need to make a thumbnail of an image after successfully uploaded the image
I am having trouble deploying express app on nodester. After successfully running the default
I am using Struts application while running welcome page is run successfully after that
After logged in successfully, Yii does not executing any page. Showing an error: Error
I do tutorial in following link: Java RMI Tutorial After I compile successfully three
After much fiddling, I've managed to install the right ODBC driver and have successfully
Im trying to test my successfully creates a new user after login (using authlogic).

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.