Skip to content

ViNN280801/lvtlibcxx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lvtlibcxx

Description

This library 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 namespaces. cmake file is just for my training in writing similar files.

Compiling

Using CMake & GNU GCC

<loveit@fedora lvtlibcxx>$ cmake .
-- The CXX compiler identification is GNU 12.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: ${YOUR_PATH}
<loveit@fedora lvtlibcxx>$ cmake --build .
[ 50%] Building CXX object CMakeFiles/lvt.dir/lvt.cpp.o
[100%] Linking CXX shared library liblvt.so
[100%] Built target lvt
<loveit@fedora lvtlibcxx>$ gcc -g -c main.cpp -lstdc++ -std=c++23 -Wall -Wpedantic -Wextra -o main.o
<loveit@fedora lvtlibcxx>$ ls
CMakeCache.txt       liblvt.so      lvt.hpp       Makefile
CMakeFiles           liblvt.so.1    lvt_impl.hpp  cmake_install.cmake
liblvt.so.1.0        main.cpp       README.md     CMakeLists.txt
lvt.cpp              main.o
<loveit@fedora lvtlibcxx>$ pwd | xclip -sel c
<loveit@fedora lvtlibcxx>$ gcc main.o -L${YOUR_PATH} -llvt -lstdc++ -std=c++23 -o main.out
<loveit@fedora lvtlibcxx>$ rm main.o
<loveit@fedora lvtlibcxx>$ LD_LIBRARY_PATH=${YOUR_PATH} ./main.out

Only commands

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

cmake .
cmake --build .
sudo mkdir -p /opt/lvt
sudo mv *.so* /opt/lvt
gcc -g -c main.cpp -lstdc++ -std=c++23 -Wall -Wpedantic -Wextra -o main.o
gcc main.o -L/opt/lvt -llvt -lstdc++ -std=c++23 -o main.out
rm main.o
LD_LIBRARY_PATH=/opt/lvt ./main.out

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

Using GNU GCC

<loveit@fedora lvtlibcxx>$ gcc -g -c lvt.cpp -lstdc++ -std=c++23 -fPIC -Wall -Wpedantic -Wextra -o lvt.o
<loveit@fedora lvtlibcxx>$ gcc -shared lvt.o -o liblvt.so
<loveit@fedora lvtlibcxx>$ ls
CMakeLists.txt  lvt.cpp  lvt_impl.hpp  main.cpp README.md
liblvt.so       lvt.hpp  lvt.o
<loveit@fedora lvtlibcxx>$ gcc -g -c main.cpp -lstdc++ -std=c++23 -Wall -Wpedantic -Wextra -o main.o
<loveit@fedora lvtlibcxx>$ pwd | xclip -sel c
<loveit@fedora lvtlibcxx>$ gcc main.o -L${COPIED_FROM_PWD_PATH} -llvt -lstdc++ -std=c++23 -o main.out
<loveit@fedora lvtlibcxx>$ rm lvt.o main.o
<loveit@fedora lvtlibcxx>$ LD_LIBRARY_PATH=${COPIED_FROM_PWD_PATH} ./main.out

Only commands

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

gcc -g -c lvt.cpp -lstdc++ -std=c++23 -fPIC -Wall -Wpedantic -Wextra -o lvt.o
gcc -shared lvt.o -o liblvt.so
sudo mkdir -p /opt/lvt
sudo mv liblvt.so /opt/lvt
gcc -g -c main.cpp -lstdc++ -std=c++23 -Wall -Wpedantic -Wextra -o main.o
gcc main.o -L/opt/lvt -llvt -lstdc++ -std=c++23 -o main.out
rm lvt.o main.o
LD_LIBRARY_PATH=/opt/lvt ./main.out
  • 1st line - compiling with "-g" (default info about debug), "-c" (means compile), "-std=c++23" (c++ 23 version of standard), "-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 liblvt.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