discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash occurs when catching std::exception in Objective-C++ code comp


From: David Chisnall
Subject: Re: Crash occurs when catching std::exception in Objective-C++ code compiled with clang on Linux and using libobjc2
Date: Fri, 17 Nov 2017 17:12:28 +0000

On 17 Nov 2017, at 15:39, Lobron, David <dlobron@akamai.com> wrote:
> 
> I tried adding this to Test/CMakeFiles/CXXExceptions.dir/link.txt and 
> Test/CMakeFiles/CXXExceptions_optimised.dir/link.txt, but the linker couldn't 
> find the shared library:
> 
> /usr/bin/ld.bfd.real: cannot find -lobjcxx
> 
> I located the .so at the root of my build tree:
> 
> (ALSI8)dlobron@bos-lps80:~/build/clangport/akamai/libobjc2$ find . -name 
> libobjcxx.so
> ./libobjc2-1.8.1/build/libobjcxx.so
> 
> I added -L.. to the linker command.  The linker was then able to find 
> libobjcxx.so, but unfortunately the exception errors came back, along with 
> some new ones from libobjcxx.so:
> 
> (ALSI8)dlobron@bos-lps80:~/build/clangport/akamai/libobjc2/libobjc2-1.8.1/build/Test$
>  /home/dlobron/build/clangport/akamai/llvm/llvm-5.0.0.install/bin/clang 
> -std=gnu99  -fexceptions  -rdynamic -lobjcxx  
> CMakeFiles/CXXExceptions_optimised.dir/CXXException.m.o 
> CMakeFiles/CXXExceptions_optimised.dir/CXXException.cc.o  -o 
> CXXExceptions_optimised 
> -Wl,-rpath,/home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/build 
> ../libobjc.so.4.6 -L..             
> CMakeFiles/CXXExceptions_optimised.dir/CXXException.cc.o: In function 
> `throw_int':
> /home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.cc:(.text+0x7):
>  undefined reference to `__cxa_allocate_exception'
> /home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.cc:(.text+0x12):
>  undefined reference to `typeinfo for int'
> /home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.cc:(.text+0x1c):
>  undefined reference to `__cxa_throw'
> CMakeFiles/CXXExceptions_optimised.dir/CXXException.cc.o: In function 
> `catchall':
> /home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.cc:(.text+0x2c):
>  undefined reference to `__cxa_begin_catch'
> /home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.cc:(.text+0x3b):
>  undefined reference to `__cxa_rethrow'
> /home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.cc:(.text+0x43):
>  undefined reference to `__cxa_end_catch'
> CMakeFiles/CXXExceptions_optimised.dir/CXXException.cc.o: In function 
> `__clang_call_terminate':
> /home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x2):
>  undefined reference to `__cxa_begin_catch'
> /home/dlobron/build/clangport/akamai/libobjc2/libobjc2-1.8.1/Test/CXXException.cc:(.text.__clang_call_terminate[__clang_call_terminate]+0x7):
>  undefined reference to `std::terminate()'
> CMakeFiles/CXXExceptions_optimised.dir/CXXException.cc.o:(.eh_frame+0x3f): 
> undefined reference to `__gxx_personality_v0'
> ../libobjcxx.so: undefined reference to `operator delete(void*)'
> ../libobjcxx.so: undefined reference to `std::type_info::__is_pointer_p() 
> const'
> ../libobjcxx.so: undefined reference to `typeinfo for std::type_info'
> ../libobjcxx.so: undefined reference to `std::type_info::__is_function_p() 
> const'
> ../libobjcxx.so: undefined reference to `__dynamic_cast'
> ../libobjcxx.so: undefined reference to 
> `std::type_info::__do_upcast(__cxxabiv1::__class_type_info const*, void**) 
> const'
> ../libobjcxx.so: undefined reference to `vtable for std::type_info'
> ../libobjcxx.so: undefined reference to `vtable for 
> __cxxabiv1::__si_class_type_info'
> ../libobjcxx.so: undefined reference to `std::type_info::~type_info()'
> clang-6.0: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> 
> Drat! :)
> 
> Do you know where I might go from here?  BTW, in case I did not note them 
> before, here is a list of the versions I am using- please let me know if I 
> should try upgrading one of these:
> 

You’ll need to also link with libstdc++.  Using g++ or clang++ instead of gcc / 
clang will do the right thing.

David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]