Hi,
I have a code and I want to add a .cpp file that I made and use the functions that I've done in that .cpp file. So at this project I am adding the ekf.cpp file and then included....but I get this errors.
1>Linking...
1>ekf.obj : error LNK2005: "void __cdecl copymatrix(int (* const)[2],int (* const)[2],int)" (?copymatrix@@YAXQAY01H0H@Z) already defined in I90ControllerDlg.obj
1>ekf.obj : error LNK2005: _main already defined in I90ControllerDlg.obj
1>ekf.obj : error LNK2005: "double u_err" (?u_err@@3NA) already defined in I90ControllerDlg.obj
1>ekf.obj : error LNK2005: "double m_err" (?m_err@@3NA) already defined in I90ControllerDlg.obj
1>ekf.obj : error LNK2005: "double dim" (?dim@@3NA) already defined in I90ControllerDlg.obj
1>ekf.obj : error LNK2005: "double angle" (?angle@@3NA) already defined in I90ControllerDlg.obj
1>.\Debug/I90Controller.exe : fatal error LNK1169: one or more multiply defined symbols found
1>Creating browse information file...

what is the problem? If I will not add to the project the ekf.cpp file then I will receive a error that the ekf.cpp can not be opened no such file or directory.

You are including a header file more than once, if you are going to do this you need to use #ifndef #define #endif etc etc

Chris

Seems more like a case of include "file.cpp" in multiple places (this is a bad thing to do).

I did that and now
1>c:\documents and settings\ogvalent\my documents\visual studio 2005\projects\ekf\ekf\ekf.cpp(1127) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

Um... well did you?

I did and now is the same error
1>Generating Code...
1>Linking...
1>ekf.obj : error LNK2005: "double u_err" (?u_err@@3NA) already defined in I90ControllerDlg.obj
1>ekf.obj : error LNK2005: "double m_err" (?m_err@@3NA) already defined in I90ControllerDlg.obj
1>ekf.obj : error LNK2005: "double dim" (?dim@@3NA) already defined in I90ControllerDlg.obj
1>ekf.obj : error LNK2005: "double angle" (?angle@@3NA) already defined in I90ControllerDlg.obj
1>.\Debug/I90Controller.exe : fatal error LNK1169: one or more multiply defined symbols found
1>Creating browse information file...
1>Microsoft Browse Information Maintenance Utility Version 8.00.50727
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Build log was saved at "file://c:\Documents and Settings\ogvalent\Desktop\VCw\VCw\Debug\BuildLog.htm"
1>I90Controller - 5 error(s), 16 warning(s

It appear you are declaring the same object in two *.cpp files. That will happen if you declare something in a header file then include that header file in all *.cpp files. What you need to do to corect that is declare it with the extern keyword in the header file, then on only ONE of the *.cpp files declare it again without extern

// header file named myheder.h (or whatever name you want to give it)
extern double u_err;
#include <myheader.h>
// one of the *.cpp files
double u_err = 0.0;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.