Skip to content

ViNN280801/lvtlibc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lvtlibc

it does not represent a specific library, (yes, I know, the name of the repository does not correspond to the content). This repository was created in order to access it using its functions in your projects. The functions are separated by preprocessor directives #ifndef. cmake file just for my training in writing similar files.

Compiling

Using CMake & GNU GCC

Attention. These commands creating new subdirectory with shared library in your "/opt" directory.

cmake .
cmake --build .
sudo mkdir -p /opt/lvtc
sudo mv *.so* /opt/lvtc
gcc -g -c main.c -lm -std=c2x -Wall -Wpedantic -Wextra -o main.o
gcc main.o -L/opt/lvtc -llvt -lm -std=c2x -o a.out
rm main.o
LD_LIBRARY_PATH=/opt/lvtc ./a.out

Command cmake --build . can be replaced with make File main.c presented your source file with the "main()" function

Using GNU GCC

Attention. These commands creating new subdirectory with shared library in your "/opt" directory.

gcc -g -c lvt.c -lm -std=c2x -fPIC -Wall -Wpedantic -Wextra -o lvt.o
gcc -shared lvt.o -o liblvtc.so
sudo mkdir -p /opt/lvtc
sudo mv liblvtc.so /opt/lvtc
gcc -g -c main.c -lm -std=c2x -Wall -Wpedantic -Wextra -o main.o
gcc main.o -L/opt/lvtc -llvt -lm -std=c2x -o a.out
rm lvt.o main.o
LD_LIBRARY_PATH=/opt/lvtc ./a.out
  • 1st line - compiling with "-g" (default info about debug), "-c" (means compile), "-std=c2x" (A further version of the C standard, known as C2X, is under development), "-fPIC" (position independent code. It's nead to compile shared library), "-Wall -Wpedantic -Wextra" (connects all kinds of warnings), "-o" (output file)
  • 2nd line - "-shared" - compiling shared library with ".so" extension - UNIX/Linux dynamic library
  • 3rd line - ("ls" doesn't counts) compiling source code with "main()" function to an object file
  • 4th line - copying path of working directory (pwd) to the
  • 5th line - Linking object files with shared library ("-L"), "-llvt" means that compiler GNU GCC have to search such kinds of files (on UNIX/Linux OS): liblvt.a (static library) or liblvtc.so (dynamic library)
  • 6th line - Adding new path to environment variable "LD_LIBRARY_PATH" and running executive file, at the same time it is not necessary that executive file must have ".out" extension.

About

My library for c with some usefull solutions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages