[CMake] Static Linking C++ Library
Mike Melanson
mike at multimedia.cx
Tue Sep 19 14:02:49 EDT 2006
Brad King wrote:
> This is not really a problem that a build system can solve directly.
> The native build tools need to be configured to support it. In order to
> link statically to the C++ runtime but dynamically to the C runtime and
> other libraries you need to configure the host system properly.
Would things be different (easier) if we were to link both the C and C++
runtimes? We are evaluating that option as well.
> For example, in order to use GCC to link statically its own libstdc++
> there are two approaches:
>
> 1.) Build GCC itself with the --disable-shared option to avoid building
> the shared libstdc++ in the first place.
>
> 2.) Convince the linker to choose the static libstdc++ by creating a
> symlink to it in a directory that does not have the shared version and
> then listing that directory first on the link line:
>
> ln -s /usr/lib/gcc/i486-linux-gnu/4.0.4/libstdc++.a /path/to/empty/dir
> g++ -L/path/to/empty/dir ...
>
> Are you trying to link statically to the compiler's C++ library or some
> alternative library?
The compiler's C++ library; seems reasonable since the rest of the code
is compiled with this particular compiler (which, in this case, is a
separate compiler than the main system compiler).
Thanks...
--
-Mike Melanson
More information about the CMake
mailing list