Giter Site home page Giter Site logo

alexw91 / multiversion_library_test Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anton-sergeev/multiversion_library_test

1.0 0.0 0.0 25 KB

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

C 56.02% CMake 31.51% Shell 12.47%

multiversion_library_test's Introduction

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

multiversion_library_test's People

Contributors

anton-sergeev avatar alexw91 avatar wawiesel avatar

Stargazers

Doug Chapman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.