-1

Let me edit the question: The files are:

file1.h
file1.c
file3.h
file2.h
file2.c
file4.h
file5.h
main_code.cpp

file1.h

#include "file3.h"
typedef struct{} Str1;
void func1(Str1 *str1);
void func2(Str1 *str1);

file1.c

#include "file3.h"
#include "file1.h"
#include "file2.h"
#include <stdio.h>
#include <math.h>
void func1(Str1 *str1){}
void func2(Str1 *str1){}

file2.h

#include "file3.h"
#include "file1.h"

file2.c

#include "file3.h"
#include "file1.h"
#include "file2.h"
#include <stdio.h>
#include <math.h>

file3.h

Doesnt include others.

file4.h

#include "file1.h"
#include "file2.h"
#include "file5.h"

file5.h

#include "file3.h"

main_code.cpp

#include "file1.h"
#include "file2.h"
#include "file4.h"
#include "file5.h"
func1(variable)
func2(variable)

The erro "LNK2001: unresolved external symbol" happen with func1 and func2 so I didnt place what functions the others have. I already tried placing the include in the "extern C" but didnt work. And if I add to main_code.cpp

  #include "file1.c"

Then the program works...

Carlos Siestrup
  • 1,031
  • 2
  • 13
  • 33
  • You need to link all the compiled files together. – molbdnilo Sep 02 '15 at 12:43
  • The linker says that missing function has a `struct Stru1` parameter, while file.h defines functions with `struct Str1` parameter. So maybe something is missing (or miscopied) either in your code or in the question. Also, unless the compiler default language is C++, you need the extern "C" bracing C-implemented functions. – MaxP Sep 02 '15 at 12:44

1 Answers1

0

You most probably forgot to add your file1.c to project for building.

Below is something you should not do in c++:

#include "file1.h"
#include "file2.h"  
    func1(variable);
    func2(variable);
 #include "file1.c"
#include "file2.c" 

those #include "file1.c"/#include "file2.c", is whats your project is for - you add new files inside IDE.

marcinj
  • 48,511
  • 9
  • 79
  • 100