2014-09-22 2 views
0

저는 arduino 보드 용 Visual micro plugin과 함께 Visual Studio 2013을 사용하고 있습니다.Visual micro에서 XXXXX의 다중 정의

'아두 이노 메가 2560 또는 메가 ADK' testMotor.cpp.o에 대한 'AeroQuad'을 컴파일 : 기능 writeMotors()' Motors_PWM_Timer.h:multiple definition of writeMotors에서 (I 아래 오류 목록에서처럼 .cpp 파일을 만들 때 나는 오류를 얻었다) ' AeroQuad.cpp.o : C : 사용자 \ \ 안녕 \ 문서는 드론 \ AeroQuad_v3.2 \ 라이브러리 \ AQ_Motors \ Motors_PWM_Timer.h \ : 127 : 처음으로 여기에 정의 된 ld.exe : 비활성화 휴식 : 그것은 작동하지 않습니다 함수 writeMotors()' Motors_PWM_Timer.h:multiple definition of motorCommand ' AeroQuad.cpp.o :(에서 bss.motorCommand이 0x0 +) : 여러 정의는 testMotor.cpp.o. 제 testMotor.cpp.o :(여기서 정의 data.numberOfMotors이 0x0 +). 배수로의 정의 617,451,515,numberOfMotors' AeroQuad.cpp.o:(.data.numberOfMotors+0x0): first defined here testMotor.cpp.o:In function commandAllMotors (INT) ' Motors_PWM_Timer.h : commandAllMotors(int)' AeroQuad.cpp.o:C:\Users\Adi\Documents\Drone\AeroQuad_v3.2\libraries\AQ_Motors\Motors_PWM_Timer.h:149: first defined here testMotor.cpp.o:In function initializeMotors (NB_Motors)의 다수의 정의'Motors_PWM_Timer.h : 복수의 정의 initializeMotors(NB_Motors)' AeroQuad.cpp.o:C:\Users\Adi\Documents\Drone\AeroQuad_v3.2\libraries\AQ_Motors\Motors_PWM_Timer.h:68: first defined here testMotor.cpp.o:In function initMotors (NB_Motors) ' testMotor.h : initMotors(NB_Motors)' AeroQuad.cpp.o:\testMotor.h:22: first defined here testMotor.cpp.o:In function pulseMotors 여러 정의 (서명 숯불)' Motors.h : 다중 정의 pulseMotors (부호없는 문자) AeroQuad.cpp.o : C : \ Users \ Adi \ Documents \ Drone \ AeroQuad_v3.2 \ libraries \ AQ_Motors \ Motors.h : 51 : 가 처음 정의 됨 여기에 오류가 .elf가

내가 왜 이해가 안 만들어?

내 헤더 파일은 같다 다음 testMotor.h 파일을 포함하여 내 testMotor.cpp 파일 I'am에서

// testMotor.h 

#ifndef _TESTMOTOR_h 
#define _TESTMOTOR_h 

/*Adi*/ 
//#define MOTOR_PWM 
#define MOTOR_PWM_Timer 
//#define MOTOR_APM 
//#define MOTOR_I2C 

#define NB_MOTOR_4 
//#define NB_MOTOR_6 
//#define NB_MOTOR_8 



#if defined MOTOR_PWM_Timer 
#include <Motors_PWM_Timer.h> 


#endif 

#if defined (NB_MOTOR_4) 
#define NB_MOTOR 4 
#define NB_MOTOR_CONFIG FOUR_Motors 
#endif 

void testMotor(int motor); 
void initMotors(NB_Motors motorConfig); 
#endif 

. 아래 코드와 같습니다 :

나는 또한 .testMotor.h 파일을 내 .ino 프로젝트에 포함시키고 있습니다. 아래의 코드처럼 :

#include "testMotor.h" 
#include "Motors.h" 
#include <EEPROM.h> 
#include <Wire.h> 
#include <GlobalDefined.h> 
#include "AeroQuad.h" 
#include "PID.h" 
#include <AQMath.h> 
#include <FourtOrderFilter.h> 

내 솔루션 프로젝트는 아래 이미지에 표시됩니다 : 나는 그것이 오류없이 실행하는 프로젝트에서 testMotor.cpp를 제외하면

enter image description here

사실입니다.

는 이유는 시각적 인 마이크로 C++ 컴파일러,하지만 C 컴파일러를 사용하지 않았다가 될 수 있을까? 내가 컴파일러를 C로 바꾸는 것보다?

누군가가 나 문제를 해결하는 데 도움이 수 있습니까?

이 Motors_PWM_Timer.h라는 라이브러리처럼 보이는
+0

* .cpp 파일의 헤더 파일과 * 정의에 * 선언 *을 유지하십시오. – Biffen

+0

헤더 파일에는 * init * init.motors가 정의되어 있으므로 각 소스 파일 ([* translation unit *] (http://en.wikipedia.org/wiki/Translation_unit_%28programming%29))에 헤더 파일이 정의됩니다. –

+0

이제는'initMotors'를'inline'으로 선언하여이 문제를 해결할 수 있습니다.하지만 일반적으로 다른 사람들이 말했듯이 .c/.cpp 파일에 함수 정의를 넣어야합니다. –

답변

0

당신은 또한 당신의 testMotor.h에서 정의되는 함수를 정의하려고

추가 정보

비주얼 마이크로는 무엇을해야 컴파일 무엇 아두 이노 IDE 않습니다. 즉, Visual Studio 프로젝트가 사용되지 않습니다. Arduino IDE는 디스크의 실제 소스 파일만을 볼 수 있으므로 Arduino와 Visual Micro 모두에서 컴파일됩니다.

카메라 마이크로 아두 이노 IDE 사용 동일한 툴 체인을 사용한다.

Visual Studio 프로젝트는 사용하기 쉽고 인텔리 센스를위한 것입니다.

Visual Micro 도움말의 가장 적합한 장소는 forum입니다.

감사합니다.