Skip to content

Test linking the next situation: two libraries depends on different versions third library

Notifications You must be signed in to change notification settings

alexw91/multiversion_library_test

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multiversion library test

Test linux linking the next situation: two libraries depends on different versions third library.

This code based on this stackoverflow answer. dlopen-variant is based on this stackoverflow answer.

Functions calls scheme

main_A.exe ───┮━━━> libA ━━━━> libC.v1
              │
main_AB.exe ──┤
              │
main_B.exe ───┶━━━> libB ━━━━> libC.v2

How to build and run

You can choose compiler by setting CC environment. For using GCC:

export CC=gcc

For using Clang:

export CC=clang

Build:

mkdir build && cd build
cmake ..
cmake --build .

Run tests using Linux:

for i in ./main_A.* ./main_B.* ./main_AB.*; do echo "$i:"; LD_LIBRARY_PATH=./A:./B:$LD_LIBRARY_PATH $i; done

Run tests using Mac:

for i in ./main_A.* ./main_B.* ./main_AB.*; do echo "$i:"; DYLD_LIBRARY_PATH=./A:./B:$DYLD_LIBRARY_PATH $i; done

Results

Ubuntu 16.04.02, CentOS 7.3: result the same for both GCC and Clang:

./main_A.shared:
 main_A->call_A->call_C (v1)
./main_A.static:
 main_A->call_A->call_C (v1)
./main_B.shared:
 main_B->call_B->call_C (v2)
./main_B.static:
 main_B->call_B->call_C (v2)
./main_AB.dlopen:
 main_AB->call_A->call_C (v1)    # <- correct
 main_AB->call_B->call_C (v2)    # <- correct
./main_AB.shared:
 main_AB->call_A->call_C (v1)    # <- correct
 main_AB->call_B->call_C (v1)    # <- wrong
./main_AB.static:
 main_AB->call_A->call_C (v1)    # <- correct
 main_AB->call_B->call_C (v1)    # <- wrong

MacOSX El Capitan 10.11.6, result same for both GCC and Clang:

./main_A.shared:
 main_A->call_A->call_C (v1)
./main_A.static:
 main_A->call_A->call_C (v1)
./main_B.shared:
 main_B->call_B->call_C (v2)
./main_B.static:
 main_B->call_B->call_C (v2)
./main_AB.dlopen:
 main_AB->call_A->call_C (v1)    # <- correct
 main_AB->call_B->call_C (v2)    # <- correct
./main_AB.shared:
 main_AB->call_A->call_C (v1)    # <- correct
 main_AB->call_B->call_C (v2)    # <- correct
./main_AB.static:
 main_AB->call_A->call_C (v1)    # <- correct
 main_AB->call_B->call_C (v1)    # <- wrong

About

Test linking the next situation: two libraries depends on different versions third library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 56.0%
  • CMake 31.5%
  • Shell 12.5%