Last active
May 26, 2023 21:23
-
-
Save yeputons/ba8c1f219e3a62c7526ad8955f697f33 to your computer and use it in GitHub Desktop.
CMake dynamic library example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lib.hpp" | |
int main() { | |
talk(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.10) | |
project(dynamic-library-example CXX) | |
add_library(lib SHARED lib.cpp) | |
add_executable(app app.cpp) | |
target_link_libraries(app lib) | |
# cmake -B build-dir | |
# cmake --build build-dir | |
# cd build-dir | |
# ./app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lib.hpp" | |
#include <iostream> | |
void talk() { | |
std::cout << "Hello World\n"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef LIB_HPP_ | |
#define LIB_HPP_ | |
void talk(); | |
#endif // LIB_HPP_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment