Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello_lib

A simple C shared library (libhello) built while learning how dynamic linking and library packaging work with CMake.

Overview

Hello_lib is a minimal "hello world" style shared library. It exists as a learning project for understanding:

  • How to structure a C library (include/ + src/)
  • Building and installing a shared library with CMake
  • Linking an external program against that shared library

Project Structure

Hello_lib/
├── include/          # Public header (hello.h)
├── src/              # Library source code
├── Example/          # Sample program that links against libhello
├── CMakeLists.txt    # Build configuration
└── .gitignore

Building

1. Configure

On Termux, set the install prefix explicitly so the library installs into your environment:

cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$PREFIX

On other Linux systems, you can omit -DCMAKE_INSTALL_PREFIX to use the default prefix, or set your own.

2. Build

cmake --build build

3. Install

cmake --install build

This installs:

File Destination
hello.h $PREFIX/include
libhello.so $PREFIX/lib

Example

The Example/ folder contains a small program demonstrating how to use the library.

Build it:

cd Example
gcc main.c -lhello -o hello

Run it:

./hello Subhransu

Output:

Hello Subhransu.
Nice to meet you.

Uninstalling

To remove the installed library:

cmake --build build --target uninstall

Motivation

This project was built as a hands-on exercise in creating and consuming a C shared library — covering headers, dynamic linking, CMake install rules, and packaging a reusable component.

About

Created a simple C shared library (hello) while learning dynamic linking.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages