I know there are huge amount of posts, but going through lots of them i found nothing that worked.
I want to include some .h and .c files into my C++ file.
Clicking into the method in CLion it redirects me to that foo.h file, but in the end it's not working with following message:
Undefined symbols for architecture x86_64: "_fooFct", referenced from: _main in main.cpp.o ld: symbol(s) not found for architecture x86_64
foo.h
void fooFct();
foo.c
void fooFct(){
/* do some stuff here */
}
main.cpp
#include <iostream>
extern "C"
{
#include "clibraryFolder/header/foo.h"
}
int main() {
fooFct();
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(newcsample)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(newcsample ${SOURCE_FILES})
But I don't want to include the C files in the CMakeFiles.txt. Is there another way doing this than by editing the CMakeFiles?
CMakeLists.txt
file look like? Does it listfoo.c
in the source list? – Some programmer dudegcc -c Cfile.c
,gcc -shared -o libCfile.so cFile.o
,c++ -L/somehwere -Wall main.cpp -o main -lCfile
? Nope, I wanted to fully get it done by CLion. Or isn't it possible? – flyOWX