I'm trying to build a C++ program with borland C++ Builder V5.5. Everything works fine until I tryed to call a function defined in a c file. The compiler works finde but linking is not working. The linker is not able to find the function called from c++ file. The .obj file is gernerated and part of the project xml file. Do anybody now how I can solve this error. To be sure that there are no side effects, I start a new project just calling c function call in constructor. The Project structure looks the following:
Form1.h defines Constructor and includes header where the c function is defined
Form1.cpp implements Constructor and call the c function
test.h defines an void function "void abc();"
test.c includes test.h and implements an void function "void abc() {}"
Unresolved external "abc()" referenced from ...unit1.obj
Do anyone have an idea??
Here some code
#include <vcl.h>
#pragma hdrstop
#include "Multicopter_Model.h"
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
abcdefg();
return;
}
_
#ifndef RTW_HEADER_Multicopter_Model_h_
#define RTW_HEADER_Multicopter_Model_h_
void abcdefg();
#endif */
_
#include "Multicopter_Model.h"
/* Model initialize function */
void abcdefg()
{
}
See C++ FAQ Item [32.4] How can I modify my own C header files so it's easier to #include them in C++ code. (Read the whole of section 32 actually.). Use:
#ifndef RTW_HEADER_Multicopter_Model_h_
#define RTW_HEADER_Multicopter_Model_h_
#ifdef __cplusplus
extern "C" {
#endif
void abcdefg();
#ifdef __cplusplus
}
#endif
#endif */