{"id":20697537,"url":"https://github.com/epomatti/cpp-static-dynamic-lib","last_synced_at":"2026-04-29T10:32:17.949Z","repository":{"id":162184570,"uuid":"636784070","full_name":"epomatti/cpp-static-dynamic-lib","owner":"epomatti","description":"Static and Linked/Shared libraries with C++","archived":false,"fork":false,"pushed_at":"2023-05-05T20:08:50.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-08T01:06:01.757Z","etag":null,"topics":["c","cpp","gcc"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/epomatti.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-05-05T16:26:45.000Z","updated_at":"2023-05-05T20:10:45.000Z","dependencies_parsed_at":"2023-07-03T15:15:35.764Z","dependency_job_id":null,"html_url":"https://github.com/epomatti/cpp-static-dynamic-lib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/epomatti/cpp-static-dynamic-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fcpp-static-dynamic-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fcpp-static-dynamic-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fcpp-static-dynamic-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fcpp-static-dynamic-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epomatti","download_url":"https://codeload.github.com/epomatti/cpp-static-dynamic-lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epomatti%2Fcpp-static-dynamic-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32421541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["c","cpp","gcc"],"created_at":"2024-11-17T00:18:53.431Z","updated_at":"2026-04-29T10:32:17.933Z","avatar_url":"https://github.com/epomatti.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CPP Lib compile\n\nStatic and dynamic C/C++ compilation.\n\n## Build commands\n\n### Static\n\nThis will embed the dependencies in the executable, and changes to the dependencies will require the client application to be built again.\n\n```sh\ng++ -c shared.cpp\nar -cvq shared.a shared.o\ng++ main.cpp shared.a -o main.out\n```\n\nTo run the applicatoin:\n\n```sh\n./main.out\n```\n\n### Dynamic\n\nA dynamic dependency (shared / linked library) allows the dependency to be updated without changes to the client code, giving that the interface between the programs remain compatible.\n\n```sh\ng++ -c -fPIC shared.cpp\ng++ -shared shared.o -o libshared.so\ng++ -L. main.cpp -lshared -o main.out\n```\n\nTo run the application:\n\n```sh\n./main.out\n```\n\nThis will print `Hello V1!` from the shared library.\n\nNow to demonstrate the effect of a dynamic update compile the V2:\n\n```sh\ng++ -c -fPIC sharedv2.cpp -o shared.o\ng++ -shared shared.o -o libshared.so\n```\n\nThis will update the library and running the main program will output `Hello V2!` as a result:\n\n```sh\n# Hello V2!\n./main.out\n```\n\n## References\n\n- [YoLinux](http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html)\n- [Jamie King](https://youtu.be/Jzh4ZULXsvo)\n- [C Programming](https://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html)\n- [Stackoverflow nested dependencies](https://stackoverflow.com/questions/61775728/gcc-shared-library-undefined-reference-on-nested-dependencies)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepomatti%2Fcpp-static-dynamic-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepomatti%2Fcpp-static-dynamic-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepomatti%2Fcpp-static-dynamic-lib/lists"}