Cmake install nested static library target_link_library undefined reference

Advertisements Install nested static library, and target_link_library not working File structure: HelloLib WorldLib CMakeLists.txt WorldLib.cpp WorldLib.h CMakeLists.txt HelloLib.cpp HelloLib.h CMakeLists.txt main.cpp main.cpp #include <iostream> #include "HelloLib/HelloLib.h" int main() { std::cout << hello() << std::endl; return 0; } CMakeLists.txt (root) cmake_minimum_required(VERSION 3.16.3) project(HelloWorld) add_executable(${PROJECT_NAME} main.cpp) add_subdirectory(HelloLib) target_link_libraries( ${PROJECT_NAME} HelloLib ) HelloLib.cpp #include <string> #include "WorldLib/WorldLib.h" std::string… Read More Cmake install nested static library target_link_library undefined reference

undefined reference to `Class::Function() / error: Id returned 1 exit status

Advertisements I’m trying to initialize value, I follow Bjarne Stroustrup‘s book but cannot run this code. #include <iostream> using namespace std; struct Date { int y, m, d; // year, month, day Date(int y, int m, int d); // check for valid & initialize void add_day(int n); // increase the Date by n days };… Read More undefined reference to `Class::Function() / error: Id returned 1 exit status