fatal error LNK1169

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2009
Posts: 8
Reputation: osan is an unknown quantity at this point 
Solved Threads: 0
osan osan is offline Offline
Newbie Poster

fatal error LNK1169

 
0
  #1
Jan 16th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: fatal error LNK1169

 
0
  #2
Jan 16th, 2009
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
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: fatal error LNK1169

 
0
  #3
Jan 16th, 2009
Seems more like a case of include "file.cpp" in multiple places (this is a bad thing to do).
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 8
Reputation: osan is an unknown quantity at this point 
Solved Threads: 0
osan osan is offline Offline
Newbie Poster

Re: fatal error LNK1169

 
0
  #4
Jan 16th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: fatal error LNK1169

 
0
  #5
Jan 16th, 2009
Um... well did you?
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 8
Reputation: osan is an unknown quantity at this point 
Solved Threads: 0
osan osan is offline Offline
Newbie Poster

Re: fatal error LNK1169

 
0
  #6
Jan 16th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,661
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1500
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: fatal error LNK1169

 
0
  #7
Jan 16th, 2009
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
  1. // header file named myheder.h (or whatever name you want to give it)
  2. extern double u_err;
  1. #include <myheader.h>
  2. // one of the *.cpp files
  3. double u_err = 0.0;
Last edited by Ancient Dragon; Jan 16th, 2009 at 7:20 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1130 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC