c++linkerautotoolslibtool

libtool .la library file wrong path


I'm having a similar problem to this unanswered question. I'm submitting my code to a build-system to use its g++ binary. However, the build is moved to a temporary path with a randomly generated name (e.g. /temp-build/1ab3fDg/...), while g++ itself is not recompiled and the .la not refreshed (not feasible). Thus, when libtool looks for the libstdc++.so, it looks in the /temp-build/1ab3fDg/libstdc++.la file to get the path to it and sees:

libdir=/temp-build/J2213bgB/.../

which is the directory of whatever random path gcc was originally compiled in. The actual .so is in the same directory as the .la file (/temp-build/1ab3fDg), but libtool is following the incorrect libdir path.

I was wondering if there was a way to tell libtool to ignore the .la file and look for libstdc++ in a directory specified by me. Alternatively, is there any other possible solution to this problem? I'm using autoconf/automake to generate the Makefiles.


Solution

  • If you have control over it, just delete libstdc++.la. This is unfortunately a very troublesome design of libtool, to hardcode the paths you used to install software in, and it can cause problems such as this.

    But the value of .la files is very limited, and is usually related to dependency tracking for static archives, that have no other way to express them. But for libstdc++ there are no dependencies anyway, so the .la file is absolutely useless even for the static archive.

    For reference, I have written quite a bit on the topic: