{"id":20810824,"url":"https://github.com/bugdea1er/dynamic_lookup","last_synced_at":"2026-04-26T07:35:07.797Z","repository":{"id":215465838,"uuid":"738565328","full_name":"bugdea1er/dynamic_lookup","owner":"bugdea1er","description":"Example of different behaviours of cmake when building MODULEs on Linux and Mac OS","archived":false,"fork":false,"pushed_at":"2024-02-03T14:07:17.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T17:22:46.938Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bugdea1er.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-03T14:19:23.000Z","updated_at":"2024-01-21T19:36:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef54f244-17af-496d-93b4-bd294d932aba","html_url":"https://github.com/bugdea1er/dynamic_lookup","commit_stats":null,"previous_names":["bugdea1er/dynamic_lookup"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bugdea1er/dynamic_lookup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugdea1er%2Fdynamic_lookup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugdea1er%2Fdynamic_lookup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugdea1er%2Fdynamic_lookup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugdea1er%2Fdynamic_lookup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bugdea1er","download_url":"https://codeload.github.com/bugdea1er/dynamic_lookup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugdea1er%2Fdynamic_lookup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32289926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T06:26:00.361Z","status":"ssl_error","status_checked_at":"2026-04-26T06:25:58.791Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T20:28:01.051Z","updated_at":"2026-04-26T07:35:07.781Z","avatar_url":"https://github.com/bugdea1er.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"This example shows different behaviour of cmake project build when building MODULEs on Linux and Mac OS\n\nThe example consists of three parts:\n- `AbstractPlugin` OBJECT library defines a virtual class AbstractPlugin. It has one defined method `preface` and one pure virtual method `run`. The `preface` method **required** to be defined in the object library \n- `dynamic_lookup` executable links with the AbstractPlugin library and therefore contains a definition for `AbstractPlugin::preface` method\n- `ModulePlugin` MODULE library defines an implementation of AbstractPlugin. The resulting `.so` file contains the `run` definition and does not contain the `preface` method definition.\n\nThe CMakeLists.txt file describes an option DYNAMIC_LOOKUP (off by default) which adds a `-undefined dynamic_lookup` linker flag for the MODULE target.\n\n`dynamic_lookup` executable lists `preface` symbol as defined:\n```shell\n$ nm -g build/dynamic_lookup | grep AbstractPlugin.preface | grep T\n0000000100003010 T __ZN14AbstractPlugin7prefaceEv\n```\n\nand `libModulePlugin` module lists `preface` symbol as undefined:\n```shell\n$ nm -g build/libModulePlugin.so | grep AbstractPlugin.preface | grep U\n                 U __ZN14AbstractPlugin7prefaceEv\n```\n\nLinux build ([Linux Build CI](https://github.com/bugdea1er/dynamic_lookup/actions/workflows/LinuxBuild.yml)) completes just fine: no need for extra flags on top of marking the libs as OBJECT and MODULE where needed:\n```shell\n$ cmake -B build\n$ cmake --build build\n[ 20%] Building CXX object CMakeFiles/AbstractPlugin.dir/AbstractPlugin.cpp.o\n[ 20%] Built target AbstractPlugin\n[ 40%] Building CXX object CMakeFiles/ModulePlugin.dir/ModulePlugin.cpp.o\n[ 60%] Linking CXX shared module libModulePlugin.so\n[ 60%] Built target ModulePlugin\n[ 80%] Building CXX object CMakeFiles/dynamic_lookup.dir/main.cpp.o\n[100%] Linking CXX executable dynamic_lookup\n[100%] Built target dynamic_lookup\n```\n\nMac OS build ([Mac Build Without Flags CI](https://github.com/bugdea1er/dynamic_lookup/actions/workflows/MacBuildWithoutFlags.yml)) fails under the same conditions:\n```shell\n$ cmake -B build\n$ cmake --build build\n[ 20%] Building CXX object CMakeFiles/AbstractPlugin.dir/AbstractPlugin.cpp.o\n[ 20%] Built target AbstractPlugin\n[ 40%] Building CXX object CMakeFiles/ModulePlugin.dir/ModulePlugin.cpp.o\n[ 60%] Linking CXX shared module libModulePlugin.so\nUndefined symbols for architecture x86_64:\n  \"AbstractPlugin::preface()\", referenced from:\n      ModulePlugin::run() in ModulePlugin.cpp.o\nld: symbol(s) not found for architecture x86_64\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\nmake[2]: *** [libModulePlugin.so] Error 1\nmake[1]: *** [CMakeFiles/ModulePlugin.dir/all] Error 2\nmake: *** [all] Error 2\n```\n\nMac OS build needs a separate linker flag `-undefined dynamic_lookup` in order to achive the same results ([Mac Build With Flags CI](https://github.com/bugdea1er/dynamic_lookup/actions/workflows/MacBuildWithFlags.yml)):\n```shell\n$ cmake -B build -DDYNAMIC_LOOKUP=ON\n$ cmake --build build\n[ 20%] Building CXX object CMakeFiles/AbstractPlugin.dir/AbstractPlugin.cpp.o\n[ 20%] Built target AbstractPlugin\n[ 40%] Building CXX object CMakeFiles/ModulePlugin.dir/ModulePlugin.cpp.o\n[ 60%] Linking CXX shared module libModulePlugin.so\n[ 60%] Built target ModulePlugin\n[ 80%] Building CXX object CMakeFiles/dynamic_lookup.dir/main.cpp.o\n[100%] Linking CXX executable dynamic_lookup\n[100%] Built target dynamic_lookup\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugdea1er%2Fdynamic_lookup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugdea1er%2Fdynamic_lookup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugdea1er%2Fdynamic_lookup/lists"}