Function Linkage difference between binary and library

I’m seeing that when I compile an executable with a large library, and I check the function definitions via nm I see that the functions in the binary is defined i.e

nm program
....... T funcnameFromLibrary

and the CMakeList.txt file is along the lines of

some_setup
...
add_executable(${PROJECT_NAME} program.cpp ...)
target_link_libraries(${PROJECT_NAME} ${SOMELIBRARY_LINK_LIBRARIES})

However when I do the same thing but make it a library (i.e. use add_library instead of add_executable) I see the following when I run nm

nm program.a
......... U funcnameFromLibrary

Am I missing something else when I’m linking the function for library compilation? my CMakeList.txt is the exact same except for the fact that I use add_library instead of add_executable

Static libraries do not copy symbols from anywhere other than the objects passed in. I suspect that funcnameFromLibrary comes from a static library. Building a shared library or executable against a static library will copy any object files which provide symbols into the resulting binary. This causes it to be defined in those but “undefined” in a static library.

There is an issue for a new library type which is a static library that copies in any used objects from linked static libraries: https://gitlab.kitware.com/cmake/cmake/-/issues/22679

Ye, I added SHARED in my add_library build, and that seemed to fix the exporting of the functions with what I need, running into a whole new weird issue now.