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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:29:46+00:00 2026-05-19T02:29:46+00:00

Why does the program listed below run on mac osx and linux but not

  • 0

Why does the program listed below run on mac osx and linux but not on freebsd?

The freebsd core dumps after the exception is thrown with the following message:

terminate called after throwing an instance of 'ObjectException'
  what():  error not allowed
[1]    28946 abort (core dumped)  ./bin/main

On all three platforms I use gnu compilers

freebsd g++ –version : g++ (GCC) 4.2.1 20070719

mac os x g++ –version: i686-apple-darwin10-g++-4.2.1

linux g++ –version: g++ (Gentoo 4.3.3 p1.0, pie-10.1.5)

freebsd uname -a: 8.1-RELEASE FreeBSD 8.1-RELEASE

I use cmake to create the Makefile, so these are also similar on each platform

Here is the listing:

Header

#ifndef GUARD_Object_h
#define GUARD_Object_h

#include "boost/scoped_ptr.hpp"
#include "string"
#include "exception"

using std::string;

class Object
{
private:
    boost::scoped_ptr<string> _name;
public:
    Object(const string&);
    string getName();
};

class ObjectException:public std::exception
{
    virtual const char* what() const throw()
    {
        return "error not allowed";
    }
};

#endif

Main

#include "Object.h"

Object::Object(const string &name):_name (new string)
{
    *_name = name;
   if(*_name == "error") 
   {  
        throw ObjectException();
   }  
}

string Object::getName() 
{
    return *_name;
}

Main

#include <iostream>
#include "Object.h"

int main() 
{
    try
    {
        new Object("error");
    } catch(ObjectException& ) {
        std::cout << "error found" << std::endl;
    }
}
  • 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-05-19T02:29:47+00:00Added an answer on May 19, 2026 at 2:29 am

    Works for me on FreeBSD 8.1-RELEASE-p2 and OSX 10.6.6.

    You could have a bad version of libstdc++ in your search path. When I link on FreeBSD 8.1, I get the following output from ldd:

    janm@midgard: test3 $ ldd a.out
    a.out:
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x800649000)
        libm.so.5 => /lib/libm.so.5 (0x800854000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x800973000)
        libc.so.7 => /lib/libc.so.7 (0x800a80000)
    

    If yours looks significantly different you might have a runtime library mismatch. If you have a problem, you can try linking with “g++ -static” to statically link the runtime library at link time. If that works, you need to fix your machine.

    Update:

    It looks like your compiler and runtime library don’t match, and that is probably caused by cmake configuration problem. You probably have installed a version of gcc into /usr/local, probably using a port.

    If you compile with system gcc, you need to link with the runtime libraries in /usr/lib. If you compile with a gcc in /usr/local, you need to link with the libraries in /usr/local. If you’re planning on shipping the binaries around, you should probably use system gcc or statically link.

    Another option is to just uninstall the gcc port and try again, assuming you don’t really care about the gcc port.

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

Sidebar

Related Questions

The program listed below outputs 0 on the screen. Why? Does it mean that
I'm using Eclipse + ADT, and my physical device (listed below) is unlisted on
I'm having some problems with my program in VS .NET 2003. I initially wrote
Recently, I made a post about the developers I'm working with not using try
Im trying to obfuscate a Java MIDlet with proguard. It runs ok on the
I'm learning C++ using Vim as an editor on Windows XP, however I found
I've been working with some event handling in Javascript and recently decided to migrate
I am setting up a project using Hibernate 3.3.1 GA and PostgreSQL 8.3 .
I'm using a JTabbedPane in my application and I listen to its changes with
Getting this error on ALL ClickOnce application launches for a certain user. This started

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.