I've got a CMakeList.txt
which builds a static lib:
project(SharedComponents C)
cmake_minimum_required(VERSION 3.12)
set(CMAKE_C_STANDARD 99)
include_directories(../include)
add_library(SharedComponents STATIC ATMIDIUtils.c ../include/ATMIDIUtils.h)
ATMIDIUtils.c
void splitMIDIValue(MIDILongValue value, MIDIValue * _Nonnull separated)
{
separated->MSB = (value >> 7) & ATMIDIMaxValue;
separated->LSB = value & ATMIDIMaxValue;
}
ATMIDIUtils.h
void splitMIDIValue(MIDILongValue value, MIDIValue * _Nonnull separated);
This compiles ok. I'm then attempting to build a unit test and link with it, and it says the symbol is missing:
Undefined symbols for architecture x86_64:
"splitMIDIValue(unsigned short, MIDIValue*)", referenced from:
ATMIDIUtilsTests_test_split_midi_value_Test::TestBody() in ATMIDIUtilsTests.cxx.o
nm shows the symbol is external:
0000000000000330 (__TEXT,__text) external _splitMIDIValue
Why are all the symbols missing from my library? ATMIDIUtils.c
contains the function implementation but it seems it is not getting compiled into the static lib.