I have main.cpp, linking test function from io.c
#include <iostream>
#include "io.h"
int main(int argc, char **argv) {
test();
return 0;
}
io.c:
#include <stdio.h>
#include "io.h"
void test() {
printf("hee");
}
and I configure CMakeLists.txt as following:
project(test)
set(MyProjectSources io.c io.h main.cpp )
add_executable(test ${MyProjectSources})
However, when I build a project, the error of undefined reference appears. Please help me.
PS: If main.cpp references to 2 libraries such as l1.h and l2.h. How to link these to main.cpp?