Coder Social home page Coder Social logo

c-linking-libraries's Introduction

Linking Libraries in C

Examples of static and Dynamic linking of libraries in C, plus how to create such libraries.

Notes

  • The examples container here strictly use GCC as the compiler. For *NIX use the general GNU distribution of GCC, and for Windows, use MinGW-w64.
  • The -s flag is used extensively throughout the examples in this repository, but it must be noted that it is totally optional and used here only to reduce the output filesize by removing all symbol table and relocation information.

Instructions

For different types of linking, I have made:

  1. static: Static Linking.
  2. dynamic: Dynamic Linking.

Within each, I have added examples for *NIX and Windows:

  1. nix: *NIX.
  2. win: Windows.

Each of the two contains a Makefile with a simple instruction to clean all files built.

Within each of those two, I have created:

  1. library: The library source code and Makefile.
  2. usage: A simple usage of the same, with the Makefile.

The Makefiles within those two directories contain a default build instruction to compile the code, and a clean instruction to clean all files built.

Information

  • The 'link' being referred to in 'symbolic link' and the one in 'static/dynamic link' are completely unrelated.
  • The source code used for the sample library and the testing file is container inside src in the repository's root. The source files are symbolically linked into the desired places, so please ensure you have enabled symbolic links in Git before cloning.
    git config --global core.symlinks true
  • In Windows systems, this would also require you to clone via a console with administrative priviledges, because creating symbolic links would require them.
  • Git won't warn you if you clone without giving administrative privileges: It will simply create copies of files instead of symbolcally linking them, even if you have the global core.symlinks set to true. This would still allow everything to work, but if you need to edit, for example, main.c, the changes won't reflect everywhere main.c is being used.
  • To enforce symbolic links while creating the clone, use
    git clone -c core.symlinks=true https://url/to/repo
    You don't need to enforce this if you are running the command-line with administrative privileges.
  • If you have Developer Mode enabled in Windows 10, you won't need to grant administrative privileges for using symbolic links.

Made with ❤ by Param.

c-linking-libraries's People

Contributors

paramsiddharth avatar

Watchers

 avatar  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.