- This project is a C language tool library.
- This project will encapsulate some commonly used tools and functions.
- This project has not been developed yet and many functions need to be added.
- CMake 3.27 or higher
- Cmocka lib for develop and test
If you use Cmocka lib, you must change
CMakeLists.txt
:if(CMAKE_SHARED_LIBRARY_SUFFIX STREQUAL ".so") # Linux # ...... # Change to your real cmocka lib path. elseif(CMAKE_SHARED_LIBRARY_SUFFIX STREQUAL ".dll") # Windows set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I\"C:/Program Files (x86)/cmocka/include\"") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L\"C:/Program Files (x86)/cmocka/lib\"") endif()
# build and test
./build.sh
./build/tests
You need to install
Cygwin
(Recommended) orMingW
to compile and run Windows programs.
If you want to use
MingW
to compile and run Windows programs, you need to changebuild.bat
file.
# build and test
.\build.bat
.\build\tests.exe
This method is not supported for Windows. Please see Include library in your project.
cd build
make install
# If Linux OS
sudo ldconfig
Create lib
directory in your project and create include
directory in lib
directory.
project_root/
├── CMakeLists.txt
└── lib/
└── include/
Copy include/tools.h
to lib/include/
directory.
Copy libraries to lib
directory:
-
MacOS:
build/libtools.dylib
andbuild/libtools.1.0.0.dylib
-
Linux:
build/libtools.so
andbuild/libtools.so.1.0
-
Windows + Cygwin:
build/libtools.dll.a
andbuild/cygtools.dll
-
Windows + MingW:
build/libtools.dll.a
andbuild/libtools.dll
project_root/
├── CMakeLists.txt
└── lib/
├── include/
│ └── tools.h
├── libtools.dll # Windows with MingW
├── cygtools.dll # Windows with Cygwin
├── libtools.dll.a # Windows
├── libtools.so # Linux
├── libtools.so.1.0 # Linux
├── libtools.dylib # macOS
└── libtools.1.0.0.dylib # macOS
CMakeLists.txt example:
# tools_example replace with your project name
cmake_minimum_required(VERSION 3.27)
project(tools_example C)
set(CMAKE_C_STANDARD 11)
add_executable(tools_example main.c)
target_include_directories(tools_example PRIVATE lib/include)
target_link_directories(tools_example PRIVATE lib)
target_link_libraries(tools_example tools)
main.c example:
#include "tools.h"
int main() {
hello();
return 0;
}
If you run ./tools_example
you will see:
Hello, World!
This means you can use this library for development.
- If you find a bug, please open an issue.
- If you want to fix a bug or add a feature, please open a pull request.
- Fork this repository.
- Make your changes.
- Commit your changes.
- Push your changes.
- Create a pull request.
- Wait for the maintainer to review your pull request.
Before submitting the code, please run the coverage check locally, and each item must be no less than
80%
../build.sh # run coverage check ./coverage.sh
This project is licensed under the MIT License - see the LICENSE.md file for details.
CLion is an IDE that maximizes developer productivity in every aspect.
Special thanks to JetBrains for providing a free CLion license for open source and educational learning.
SaaS solution for high quality code. Simple, scalable, fast.
Special thanks to SonarSource for providing a free SonarQube Cloud Free Plan for open source.
Sourcery is an AI-powered code review tool that helps developers find bugs, vulnerabilities, and security issues in their code.
Special thanks to Sourcery for providing a free plan Sourcery AI for open source.