<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">$ make check V=s 2>&1 | grep libosmovty</p><p style="white-space: pre-wrap; word-wrap: break-word;">I see the following lines only:</p><p style="white-space: pre-wrap; word-wrap: break-word;">/bin/bash ../libtool  --tag=CC   --mode=link gcc -Wall  -g -O2<br>-DBUILDING_LIBOSMOCORE -Wall   -o vty/vty_test vty/vty_test.o<br>../src/libosmocore.la -ltalloc   ../src/vty/libosmovty.la</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Exactly, only vty_test so far linked libosmovty directly from the build tree.<br>The others apparently implicitly link it from where ever they can find it,<br>in my case from /usr/local/lib?</p><p style="white-space: pre-wrap; word-wrap: break-word;">In an effort to understand wth is going on with linking, I reproduced this issue now:</p><p style="white-space: pre-wrap; word-wrap: break-word;">Build and install libosmocore from the tip of branch neels/logging.<br>This makes logging_vty.c use loglevel_strs[], assert_loginfo(), tall_log_ctx from logging.c,<br>and adds loglevel_descriptions[] to logging.c and calls that from logging_vty.c, too.<br>So that means now logging_vty.c depends on these symbols to be public in libosmocore.a, where they were static before. With this state of linking installed, everything works fine.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Now go back to libosmocore master, where these symbols are still static.<br>Mind you, /usr/local/lib already has a libosmovty.a that depends on these symbols to be public in libosmocore.</p><p style="white-space: pre-wrap; word-wrap: break-word;">When I try to build now, I get</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  CCLD     ctrl/ctrl_test<br>  /usr/bin/ld: /usr/local/lib/libosmovty.so.4: undefined reference to `loglevel_strs'<br>  /usr/bin/ld: /usr/local/lib/libosmovty.so.4: undefined reference to `assert_loginfo'<br>  /usr/bin/ld: /usr/local/lib/libosmovty.so.4: undefined reference to `log_level_description'<br>  /usr/bin/ld: /usr/local/lib/libosmovty.so.4: undefined reference to `tall_log_ctx'<br>  collect2: error: ld returned 1 exit status</pre><p style="white-space: pre-wrap; word-wrap: break-word;">Let's see</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">  /bin/bash ../libtool  --tag=CC   --mode=link gcc -Wall  -g -O2 -fsanitize=address -fsanitize=undefined -Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -Wno-error=cpp -DBUILDING_LIBOSMOCORE -Wall   -o ctrl/ctrl_test ctrl/ctrl_test.o ../src/libosmocore.la -ltalloc  ../src/ctrl/libosmoctrl.la <br>  libtool: link: gcc -Wall -g -O2 -fsanitize=address -fsanitize=undefined -Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -Wno-error=cpp -DBUILDING_LIBOSMOCORE -Wall -o ctrl/.libs/ctrl_test ctrl/ctrl_test.o  ../src/.libs/libosmocore.so -ltalloc ../src/ctrl/.libs/libosmoctrl.so<br>  /usr/bin/ld: /usr/local/lib/libosmovty.so.4: undefined reference to `loglevel_strs'<br>  /usr/bin/ld: /usr/local/lib/libosmovty.so.4: undefined reference to `assert_loginfo'<br>  /usr/bin/ld: /usr/local/lib/libosmovty.so.4: undefined reference to `log_level_description'<br>  /usr/bin/ld: /usr/local/lib/libosmovty.so.4: undefined reference to `tall_log_ctx'<br>  collect2: error: ld returned 1 exit status</pre><p style="white-space: pre-wrap; word-wrap: break-word;">Clearly, libosmovty is not listed as linked library. But for some reason, libtool still pulls in a libosmovty.<br>That's because of libosmoctrl.so!</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">    ▶ ldd src/ctrl/.libs/libosmoctrl.so<br>    linux-vdso.so.1 (0x00007ffced03f000)<br>  libasan.so.5 => /usr/lib/x86_64-linux-gnu/libasan.so.5 (0x00007f26c291b000)<br>        libtalloc.so.2 => /usr/lib/x86_64-linux-gnu/libtalloc.so.2 (0x00007f26c2903000)<br>    libosmocore.so.11 => /usr/local/lib/libosmocore.so.11 (0x00007f26c26d4000)<br> libosmogsm.so.10 => /usr/local/lib/libosmogsm.so.10 (0x00007f26c22bb000)<br>   libosmovty.so.4 => /usr/local/lib/libosmovty.so.4 (0x00007f26c2171000)<br>     libubsan.so.1 => /usr/lib/x86_64-linux-gnu/libubsan.so.1 (0x00007f26c1650000)<br>      [...]</pre><p style="white-space: pre-wrap; word-wrap: break-word;">It does so from /usr/local/lib in my case.</p><p style="white-space: pre-wrap; word-wrap: break-word;">The solution is thus: any program built in libosmocore.git, here regression test binary, that links libosmoctrl,<br>*must* also make sure to link libosmovty and libosmogsm from the source tree, or the build works only when we're lucky.</p><p><a href="https://gerrit.osmocom.org/5844">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.osmocom.org/5844">change 5844</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/5844"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: Id084e6e6efd25cd62b1bd7a4fc7c5985c39130c6 </div>
<div style="display:none"> Gerrit-Change-Number: 5844 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Vadim Yanitskiy <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Tue, 11 Sep 2018 20:46:11 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-HasLabels: No </div>