[odb-users] libc++abi.dylib: terminating with uncaught foreign exception

Boris Kolpackov boris at codesynthesis.com
Mon Oct 20 07:58:53 EDT 2014


Hi Adnan,

Adnan RIHAN <axel50397 at gmail.com> writes:

> I’ve even just tried to compile “hello” example by command line, using
> clang-c++:
>
> > ➜  hello  pwd
> > /Users/Max13/Downloads/odb-examples-2.3.0/hello
> > ➜  hello  c++ -v
> > Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
> > Target: x86_64-apple-darwin13.4.0
> > Thread model: posix
> > ➜  hello  odb -d sqlite --generate-query --generate-schema person.hxx
> > ➜  hello  c++ -c person-odb.cxx
> > ➜  hello  c++ -DDATABASE_SQLITE -c driver.cxx
> > ➜  hello  c++ -o driver driver.o person-odb.o -lodb-sqlite -lodb
> > Undefined symbols for architecture x86_64:
> [...]

Good. When you give me something like this I can actually go and try
to reproduce the problem. So here is what I have done:

1. Install command line tools.

   One thing I could not do is first uninstall everything (e.g.,
   get rid of /usr/bin/{clang,gcc,...} and /usr/include/*).
   Apparently there is no way to do it. In particular, running
   this did not remove those tools:

   /Developer/Library/uninstall-devtools --mode=all

   In any case, to make sure I have the latest stuff, I ran:

   xcode-select --install

   And it downloaded and installed something. After that, I got:

   $ clang --version
   Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
   Target: x86_64-apple-darwin13.4.0

   It looks like an even newer version than yours, so I am definitely
   using the latest tools.

2. Then, for general undestanding, I compiled a test program called
   sizeof_funds.cxx (attached) to see which mode (32/64) is the
   default:

$ clang++ sizeof_funds.cxx
$ ./a.out
bool             sizeof = 1 alignof = 1
wchar_t          sizeof = 4 alignof = 4
short int        sizeof = 2 alignof = 2
int              sizeof = 4 alignof = 4
long int         sizeof = 8 alignof = 8
long long int    sizeof = 8 alignof = 8
float            sizeof = 4 alignof = 4
double           sizeof = 8 alignof = 8
long double      sizeof = 16 alignof = 16
void*            sizeof = 8 alignof = 8

$ clang++ -m32 sizeof_funds.cxx
$ ./a.out
bool             sizeof = 1 alignof = 1
wchar_t          sizeof = 4 alignof = 4
short int        sizeof = 2 alignof = 2
int              sizeof = 4 alignof = 4
long int         sizeof = 4 alignof = 4
long long int    sizeof = 8 alignof = 8
float            sizeof = 4 alignof = 4
double           sizeof = 8 alignof = 8
long double      sizeof = 16 alignof = 16
void*            sizeof = 4 alignof = 4

  So, by default, clang generates 64-bit code (look at size of void*)
  but you can request 32-bit with -m32.

3. Next I downloaded and unpacked these 4 ODB packages:

libodb-2.3.0.tar.bz2
libodb-sqlite-2.3.0.tar.bz2
odb-2.3.0-i686-macosx.tar.bz2
odb-examples-2.3.0.tar.bz2

Then I built and installed libodb and libodb-sqlite:

$ cd libodb-2.3.0
$ ./configure CC=clang CXX=clang++
$ make
$ sudo make install
$ cd ..

$ cd libodb-sqlite-2.3.0
$ ./configure CC=clang CXX=clang++
$ make
$ sudo make install
$ cd ..

Then I tried to build the hello example by hand, just like you did:

$ cd odb-examples-2.3.0/hello
$ ../../odb-2.3.0-i686-macosx/bin/odb -d sqlite -q -s person.hxx
clang++ -c person-odb.cxx
clang++ -DDATABASE_SQLITE -c driver.cxx
clang++ -o driver driver.o person-odb.o -lodb-mysql -lodb
clang++ -o driver driver.o person-odb.o -lodb-sqlite -lodb
$ ./driver
Hello, John Doe!
Hello, Jane Doe!

count  : 3
min age: 31
max age: 33

So, for me, everything works pretty smoothly. Can you try these exact
steps and see if they work for you?


> While writing this email, something strange happened, the lib compiled with
> GCC and my app with clang, no more runtime errors... I don't understand,
> same code, same environment and no more libc++/glibc.

This could work as long as the code doesn't throw an exception. It is
definitely a bad idea to mix those things, even if it appear to work
right now.

Boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sizeof_funds.cxx
Type: text/x-c++src
Size: 1952 bytes
Desc: not available
Url : http://codesynthesis.com/pipermail/odb-users/attachments/20141020/f2fc666a/sizeof_funds.cxx


More information about the odb-users mailing list