Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Missing Insure++ symbols during linking?

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in Insure++
Some versions of GCC and some distributions of linux, (Ubuntu has been observed but there may be others), have added a new linking heuristic, which causes insure++ linking to fail. The symptom will be something like this:

insure gcc -g -o freenull freenull.c
** Insure messages will be written to insra **
/home/insure++/lib/libinsure.so: undefined reference to `Insure::Thread::startFunction()'
/home/insure++/lib/libinsure.so: undefined reference to `Insure::NativeThread::newThread(Insure::Lock&)'
/home/insure++/lib/libinsure.so: undefined reference to `Insure::Mutex::newMutex(Insure::ThisThread*, Insure::LibraryCall&)'
/homeinsure++//lib/libinsure.so: undefined reference to `Insure::Thread::thisThread()'
/home/insure++/lib/libinsure.so: undefined reference to `Insure::Thread::fiberStartFunction()'
collect2: ld returned 1 exit status
Driver: error executing "Run "-Zoicompiler /usr/bin/gcc" -g -o freenull freenull.c"

It's important to diagnose this problem using the supplied Insure++ examples which should compile and link on all platforms. If you can link the examples, but cannot link your own code, then you have a different problem.

The solution is to simply add: -Wl,--no-as-needed flag to your compilations with Insure++

So, instead of:

insure gcc -g -o freenull freenull.c

You would do:

insure gcc -g -o freenull freenull.c -Wl,--no-as-needed
-----------
A short description of the problem.

In these versions of GNU ld, a new heuristic has been chosen which only selects symbols based on if they appear to be needed at the time of reading the particular library. However, Insure++ libraries have interdependencies, therefore this flag causes modules to be left out of the link because they don't appear to be needed, (until the next library is loaded, and then it's too late, and you get these linker errors.) The --no-as-needed flag disables this new heuristic, and causes the entire library to load and bind to the executable image.
Tagged: