0
  • Currently, I'm creating a linux library by C program, using pthread_cleanup_push/pthread_cleanup_pop to register a clean-up function in case pthread is cancelled suddenly. I compiled this library source code by using g++ compiler to create ".so" file.
  • I write an application in C for using this library, and build this application by g++ and gcc compiler.
  • If apllication is compiled by g++, when thread is canceled then clean-up function is called successfully
  • If apllication is compiled by gcc, when thread is canceled then clean-up function is NOT called
  • I don't know whether g++ lib is compatible with gcc appliaction or not. Please help.
bvp147
  • 83
  • 1
  • 8
  • 3
    You need to link with `g++` when linking programs that have mixed C and C++ , this is because C++ has more startup requirements – M.M Dec 23 '15 at 04:40
  • 2
    In the latter case you are attempting to invoke C++ code from C code. Have a read of: [How to call C++ function from C?](https://stackoverflow.com/questions/2744181/how-to-call-c-function-from-c) – kaylum Dec 23 '15 at 04:42
  • Thank you for your answer. >M.M: I tried to link with libstdc++, but it's not successfull. >kaylum: I used C for lib and appl, I don't use C++. – bvp147 Dec 23 '15 at 04:45
  • 2
    @BinPhan You used `g++`. That will treat your code as C++. C and C++ are seperate languages but alot of code can be compiled as both C and C++. But the result is different. So yes, you are compiling as C++ (even though you may not have intended to) because you used `g++`. – kaylum Dec 23 '15 at 05:53

0 Answers0