Originally posted by: H0W2_tomasz_lacki
Try below.
AIX> cat slib.cpp
#include <iostream>
void throw_in()
{
try {
throw 1;
} catch(int &e) {
std::cout << "catch int shlib in " << e << std::endl;
}
}
void throw_out()
{
throw 2;
}
AIX> cat catch_app.cpp
#include <iostream>
void throw_in();
void throw_out();
int main()
{
try {
throw_in();
throw_out();
} catch (int &e) {
std::cout << "catch int shlib out " << e << std::endl;
}
return 0;
}
AIX> ./a!
+ oslevel
7.2.0.0
+ g++ --version
g++ (GCC) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ g++ -O2 -c -pthread slib.cpp
+ g++ -o libslib.so -shared -Wl,-G -pthread slib.o
+ g++ -O2 -c -pthread catch_app.cpp
+ g++ -o catch_app -Wl,-brtl -pthread -L. -lslib catch_app.o
ld: 0711-224 WARNING: Duplicate symbol: .__init_aix_libgcc_cxa_atexit
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
+ chmod 700 libslib.so
+ ./catch_app
catch int shlib in 1
catch int shlib out 2
#AIX-Open-Source-Software#AIXOpenSource