Discussion:
[cmake-developers] Shared libraries
REIX, Tony
2018-08-09 16:17:46 UTC
Permalink
Hi,


On AIX, when building MongoC 1.11, cmake 3.11.4 generates lib*.so files and lib*.a files which contain .o files.

On AIX, we should get libraries lib*.a containing the lib*.so file.

I've tried to use:

-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=OFF \
-DCMAKE_C_CREATE_SHARED_LIBRARY=ON \
-DCMAKE_CXX_CREATE_SHARED_LIBRARY=ON
and I see that, for MariaDB, someone has tried with:

-DDISABLE_SHARED=OFF


None seems to work.


Which CMake variable should I use for asking CMAKE to generate shared libraries rather than static ones: lib*.a file containing .so files rather than .o files.


Thanks


Cordialement,

Tony Reix

***@atos.net

ATOS / Bull SAS
ATOS Expert
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
www.atos.net<https://mail.ad.bull.net/owa/redir.aspx?C=PvphmPvCZkGrAgHVnWGsdMcDKgzl_dEIsM6rX0g4u4v8V81YffzBGkWrtQeAXNovd3ttkJL8JIc.&URL=http%3a%2f%2fwww.atos.net%2f>
Chuck Atkins
2018-08-21 16:02:44 UTC
Permalink
Hi Tony,

I expect what your seeing is likely the result of how MaraiaDBhas
specifically implemented their CMake build. The only builtin CMake
variable to control this is BUILD_SHARED_LIBS, which when set to "ON"
changes the behavior of add_library(foo) to be add_library(foo SHARED),
instead of the default add_library(foo STATIC). The other
BUILD_STATIC_LIBS and DISABLE_SHARED are variables are not builtin to CMake
and are part of however they have chosen to implement their build.

CMake builds are typically designed to produce a single configuration, i.e.
shared release or static debug, etc. Often, however, because to have the
flexibility to do otherwise. projects will try to instead implement a build
that produces several configurations in a single pass. It seems this is
what MariaDB has done and as such the variables to control it will be
unique and specific to that project and how they've decided to implement it.

----------
Chuck Atkins
Staff R&D Engineer, Scientific Computing
Kitware, Inc.


On Thu, Aug 9, 2018 at 12:23 PM REIX, Tony <***@atos.net> wrote:

> Hi,
>
>
> On AIX, when building MongoC 1.11, cmake 3.11.4 generates lib*.so files
> and lib*.a files which contain .o files.
>
> On AIX, we should get libraries lib*.a containing the lib*.so file.
>
> I've tried to use:
>
> -DBUILD_SHARED_LIBS=ON \
> -DBUILD_STATIC_LIBS=OFF \
> -DCMAKE_C_CREATE_SHARED_LIBRARY=ON \
> -DCMAKE_CXX_CREATE_SHARED_LIBRARY=ON
> and I see that, for MariaDB, someone has tried with:
>
> -DDISABLE_SHARED=OFF
>
>
> None seems to work.
>
>
> Which CMake variable should I use for asking CMAKE to generate shared
> libraries rather than static ones: lib*.a file containing .so files rather
> than .o files.
>
>
> Thanks
>
>
> Cordialement,
>
> Tony Reix
>
> ***@atos.net
>
> ATOS / Bull SAS
> ATOS Expert
> IBM Coop Architect & Technical Leader
> Office : +33 (0) 4 76 29 72 67
> 1 rue de Provence - 38432 Échirolles - France
> www.atos.net
> <https://mail.ad.bull.net/owa/redir.aspx?C=PvphmPvCZkGrAgHVnWGsdMcDKgzl_dEIsM6rX0g4u4v8V81YffzBGkWrtQeAXNovd3ttkJL8JIc.&URL=http%3a%2f%2fwww.atos.net%2f>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake-developers
>
REIX, Tony
2018-08-21 16:20:44 UTC
Permalink
Hi Chuck,


Thanks for the information.


We launch cmake on MariaDB code with:

-DBUILD_SHARED_LIBS=true


Moreover, here are the few places in MariaDB code where BUILD_SHARED_LIBS appears:

# grep -R BUILD_SHARED_LIBS *
CMakeCache.txt:BUILD_SHARED_LIBS:UNINITIALIZED=true
pcre/CMakeLists.txt:# IF(NOT BUILD_SHARED_LIBS)
pcre/CMakeLists.txt:# ENDIF(NOT BUILD_SHARED_LIBS)
pcre/CMakeLists.txt:# MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}")
plugin/aws_key_management/CMakeLists.txt: -DBUILD_SHARED_LIBS=OFF


What does the first line means ?


Thx/Regards,



Cordialement,

Tony Reix

***@atos.net

ATOS / Bull SAS
ATOS Expert
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
www.atos.net<https://mail.ad.bull.net/owa/redir.aspx?C=PvphmPvCZkGrAgHVnWGsdMcDKgzl_dEIsM6rX0g4u4v8V81YffzBGkWrtQeAXNovd3ttkJL8JIc.&URL=http%3a%2f%2fwww.atos.net%2f>


________________________________
De : Chuck Atkins <***@kitware.com>
Envoyé : mardi 21 août 2018 18:02
À : REIX, Tony
Cc : CMake Developers
Objet : Re: [cmake-developers] Shared libraries

Hi Tony,

I expect what your seeing is likely the result of how MaraiaDBhas specifically implemented their CMake build. The only builtin CMake variable to control this is BUILD_SHARED_LIBS, which when set to "ON" changes the behavior of add_library(foo) to be add_library(foo SHARED), instead of the default add_library(foo STATIC). The other BUILD_STATIC_LIBS and DISABLE_SHARED are variables are not builtin to CMake and are part of however they have chosen to implement their build.

CMake builds are typically designed to produce a single configuration, i.e. shared release or static debug, etc. Often, however, because to have the flexibility to do otherwise. projects will try to instead implement a build that produces several configurations in a single pass. It seems this is what MariaDB has done and as such the variables to control it will be unique and specific to that project and how they've decided to implement it.

----------
Chuck Atkins
Staff R&D Engineer, Scientific Computing
Kitware, Inc.


On Thu, Aug 9, 2018 at 12:23 PM REIX, Tony <***@atos.net<mailto:***@atos.net>> wrote:

Hi,


On AIX, when building MongoC 1.11, cmake 3.11.4 generates lib*.so files and lib*.a files which contain .o files.

On AIX, we should get libraries lib*.a containing the lib*.so file.

I've tried to use:

-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=OFF \
-DCMAKE_C_CREATE_SHARED_LIBRARY=ON \
-DCMAKE_CXX_CREATE_SHARED_LIBRARY=ON
and I see that, for MariaDB, someone has tried with:

-DDISABLE_SHARED=OFF


None seems to work.


Which CMake variable should I use for asking CMAKE to generate shared libraries rather than static ones: lib*.a file containing .so files rather than .o files.


Thanks


Cordialement,

Tony Reix

***@atos.net<mailto:***@atos.net>

ATOS / Bull SAS
ATOS Expert
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
www.atos.net<https://mail.ad.bull.net/owa/redir.aspx?C=PvphmPvCZkGrAgHVnWGsdMcDKgzl_dEIsM6rX0g4u4v8V81YffzBGkWrtQeAXNovd3ttkJL8JIc.&URL=http%3a%2f%2fwww.atos.net%2f>
--

Powered by www.kitware.com<http://www.kitware.com>

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers
Chuck Atkins
2018-08-21 16:57:59 UTC
Permalink
Hi Tony,

I believe I somewhat misunderstood what appears to be two separate issues
here: 1: how to get your build to generate the static and shared libraries
and 2: the library format doesn't seem correct. Regarding 1, it will be
project specific if the project's build designed to simultaneously produce
multiple configurations. In the context of MongoC, I've looked at the CMake
files and it seems as though shared libraries are always built and static
libraries can *also* be explicitly enabled/disabled by setting
-DENABLE_STATIC=ON or -DENABLE_STATIC=OFF.

Regarding 2,

On AIX, when building MongoC 1.11, cmake 3.11.4 generates lib*.so files and
> lib*.a files which contain .o files.
>
> On AIX, we should get libraries lib*.a containing the lib*.so file.
>
>
While with most SysV and BSD unices the concept of "shared libraries" and
"runtime linking" are one in the same and go togethor, on AIX they are two
seperate ideas orthogonal to one another. On AIX you can have shared
libraries used for runtime-linking, i.e. libfoo.so containing objects, and
archive files libfoo.a used for compile time linking. The archive file can
then in turn contain object files used for static linkling or an so used
for shared linking. CMake will produce the stand alone libfoo.so shared
lib for shared runtime linking and the libfoo.a archive with object files
for static compile-time linking, but I believe does not support generating
the libfoo.a archive with .sos for shared compile-time linking.

- Chuck
APEKE, SENA (ext)
2018-08-22 14:04:23 UTC
Permalink
Hi Chuck,

I also followed the discussions, we thank you for your answers and we shall come back to you if needed.

Regards,
Séna

From: Chuck Atkins [mailto:***@kitware.com]
Sent: Tuesday, August 21, 2018 6:58 PM
To: REIX, Tony <***@atos.net>
Cc: CMake Developers <cmake-***@cmake.org>; APEKE, SENA (ext) <***@atos.net>
Subject: Re: [cmake-developers] Shared libraries

Hi Tony,

I believe I somewhat misunderstood what appears to be two separate issues here: 1: how to get your build to generate the static and shared libraries and 2: the library format doesn't seem correct. Regarding 1, it will be project specific if the project's build designed to simultaneously produce multiple configurations. In the context of MongoC, I've looked at the CMake files and it seems as though shared libraries are always built and static libraries can *also* be explicitly enabled/disabled by setting -DENABLE_STATIC=ON or -DENABLE_STATIC=OFF.

Regarding 2,


On AIX, when building MongoC 1.11, cmake 3.11.4 generates lib*.so files and lib*.a files which contain .o files.

On AIX, we should get libraries lib*.a containing the lib*.so file.

While with most SysV and BSD unices the concept of "shared libraries" and "runtime linking" are one in the same and go togethor, on AIX they are two seperate ideas orthogonal to one another. On AIX you can have shared libraries used for runtime-linking, i.e. libfoo.so containing objects, and archive files libfoo.a used for compile time linking. The archive file can then in turn contain object files used for static linkling or an so used for shared linking. CMake will produce the stand alone libfoo.so shared lib for shared runtime linking and the libfoo.a archive with object files for static compile-time linking, but I believe does not support generating the libfoo.a archive with .sos for shared compile-time linking.

- Chuck
Loading...