-1

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?

1
  • without posting the actual error there is nothing we can help you with. also: you probably don't want to add io.h (a header file!) to the list of sources. Commented Oct 9, 2014 at 12:20

1 Answer 1

2

You should provide the error. Nevertheless, it looks like you are missing to link against some libraries.

Also note this is a CMake issue, not a KDevelop's. You'll probably find more literature if you research cmake.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.