1

我在项目外部的目录(Ardrone SDK 目录)中开发了一个示例(Ardrone SDK 版本 1.8)并自己制作了 Makefile。但是,出现了这个错误:

teste_ardrone.cpp:68:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
teste_ardrone.cpp:68:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
/tmp/ccKmZ6Wp.o:(.data+0x34): undefined reference to `thread_ardrone_control(void*)'
/tmp/ccKmZ6Wp.o:(.data+0x54): undefined reference to `thread_navdata_update(void*)'
collect2: ld returned 1 exit status
make: *** [all] Error 1

我的制作文件:

SDK_PATH:=$(shell pwd)/../ARDrone_SDK_Version_1_8_20110726/ARDroneLib
PC_TARGET=yes
USE_LINUX=yes

CC =gcc

CFLAGS =-Wall -DGNU_LINUX

LDFLAGS =-static

SRC = teste_ardrone.cpp

INCLUDES = -I$(SDK_PATH)/ \
           -I$(SDK_PATH)/Soft/Lib/ \
           -I$(SDK_PATH)/Soft/Lib/ardrone_tool/ \
           -I$(SDK_PATH)/Soft/Common/ \
           -I$(SDK_PATH)/VP_SDK/ \
              -I$(SDK_PATH)/VP_SDK/VP_Os/linux/ \

LIB_PATHS = -L/. \
            -L$(SDK_PATH)/Soft/Build/targets_versions/ardrone_lib_PROD_MODE_vlib_Linux_3.2.0-41-generic-pae_GNU_Linux_gcc_4.6.3 \
            -L$(SDK_PATH)/Soft/Build/targets_versions/vlib_PROD_MODE_Linux_3.2.0-41-generic-pae_GNU_Linux_gcc_4.6.3 \
            -L$(SDK_PATH)/Soft/Build/targets_versions/sdk_PROD_MODE_vlib_Linux_3.2.0-41-generic-pae_GNU_Linux_gcc_4.6.3

LIBS = -lpc_ardrone \
       -lsdk \
       -lpthread \
       -lgtk-x11-2.0 \
       -lrt \
       -lvlib \

BIN = teste_ardrone

all:
    $(CC) -o $(BIN) $(SRC) $(INCLUDES) $(LIB_PATHS) $(LIBS) $(LDFLAGS)

我的代码(cpp):

/**
 * @file main.cpp
 * @author renanprata@ieee.org
 * @date 2013/05/14
 */

//ARDroneLib
#include <ardrone_tool/ardrone_time.h>
#include <ardrone_tool/Navdata/ardrone_navdata_client.h>
#include <ardrone_tool/Control/ardrone_control.h>
#include <ardrone_tool/UI/ardrone_input.h>

//Common
#include <config.h>
#include <ardrone_api.h>

//VP_SDK
#include <ATcodec/ATcodec_api.h>
#include <VP_Os/vp_os_print.h>
#include <VP_Os/vp_os_types.h>
#include <VP_Api/vp_api_thread_helper.h>
#include <VP_Os/vp_os_signal.h>

static int32_t exit_ihm_program = 1;
/* Implementing Custom methods for the main function of an ARDrone application */
/* The delegate object calls this method during initialization of an ARDrone application */
C_RESULT ardrone_tool_init_custom(int argc, char **argv)
{
  /* Registering for a new device of game controller */
  //ardrone_tool_input_add( &gamepad );

  /* Start all threads of your application */
  START_THREAD( ardrone_control, NULL );

  return C_OK;
}

/* The delegate object calls this method when the event loop exit */
C_RESULT ardrone_tool_shutdown_custom()
{
  /* Relinquish all threads of your application */
  JOIN_THREAD( ardrone_control );

  /* Unregistering for the current device */
  //ardrone_tool_input_remove( &gamepad );

  return C_OK;
}

/* The event loop calls this method for the exit condition */
bool_t ardrone_tool_exit()
{
  return exit_ihm_program == 0;
}

C_RESULT signal_exit()
{
  exit_ihm_program = 0;

  return C_OK;
}

/* Implementing thread table in which you add routines of your application and those provided by the SDK */
BEGIN_THREAD_TABLE
  THREAD_TABLE_ENTRY( ardrone_control, 20 )
  THREAD_TABLE_ENTRY( navdata_update, 20 )
//  THREAD_TABLE_ENTRY( video_stage, 20 )
END_THREAD_TABLE
4

1 回答 1

1

我在我的 C 代码中使用'extern "C"' 和一个新的 make 文件解决了我的问题。

在这种情况下,我的 C 代码:

 /**
 * @file main.c
 * @author renancprata@ieee.org
 * @date 2013/06/08
 */
#ifdef __cplusplus
extern "C"
{
#endif

//#include <ardrone_testing_tool.h>

//ARDroneLib
#include <ardrone_tool/ardrone_time.h>
#include <ardrone_tool/Navdata/ardrone_navdata_client.h>
#include <ardrone_tool/Control/ardrone_control.h>
#include <ardrone_tool/UI/ardrone_input.h>

//Common
#include <config.h>
#include <ardrone_api.h>

//VP_SDK
#include <ATcodec/ATcodec_api.h>
#include <VP_Os/vp_os_print.h>
#include <VP_Api/vp_api_thread_helper.h>
#include <VP_Os/vp_os_signal.h>

#include <control.h>
//#include <Client_vicon.h>

//Local project
//#include <UI/gamepad.h>
//#include <Video/video_stage.h>

static int32_t exit_ihm_program = 1;

/* Implementing Custom methods for the main function of an ARDrone application */

/* The delegate object calls this method during initialization of an ARDrone application */
C_RESULT ardrone_tool_init_custom(int argc, char **argv)
{

  /* Start all threads of your application */
  START_THREAD( ardrone_control, NULL );

  return C_OK;
}

/* The delegate object calls this method when the event loop exit */
C_RESULT ardrone_tool_shutdown_custom()
{
  ardrone_tool_set_ui_pad_start(0); 

  /* Relinquish all threads of your application */
  JOIN_THREAD( control );

  return C_OK;
}

/* The event loop calls this method for the exit condition */
bool_t ardrone_tool_exit()
{
  return exit_ihm_program == 0;
}

C_RESULT signal_exit()
{
  exit_ihm_program = 0;

  return C_OK;
}

/* Implementing thread table in which you add routines of your application and those provided by the SDK */
BEGIN_THREAD_TABLE
  THREAD_TABLE_ENTRY( ardrone_control, 20 )
  THREAD_TABLE_ENTRY( navdata_update, 20 )
  THREAD_TABLE_ENTRY( control, 20 )
END_THREAD_TABLE

#ifdef __cplusplus
}
#endif

还有我的 Makefile:

SDK_PATH:=$(shell pwd)/../ARDrone_SDK_Version_1_8_20110726/ARDroneLib
PC_TARGET=yes
USE_LINUX=yes

CPP =g++

CFLAGS =-Wall -O3 -DCOMPIL_MODE_PROD -DNDEBUG -D__linux__ -D__LINUX__ -DTARGET_CPU_ARM=0 -DTARGET_CPU_X86=1 -DUSE_WIFI -DUSE_VLIB -DUSE_LINUX

LDFLAGS =-static

SRC =ardrone_testing_tool.cpp control.cpp

INCLUDES =-I./ \
          -I$(SDK_PATH)/ \
          -I$(SDK_PATH)/Soft/Lib/ \
          -I$(SDK_PATH)/Soft/Lib/ardrone_tool/ \
          -I$(SDK_PATH)/Soft/Common/ \
          -I$(SDK_PATH)/VP_SDK/ \
          -I$(SDK_PATH)/VP_SDK/VP_Os/linux/ \

LIB_PATHS =-L$(SDK_PATH)/Soft/Build/targets_versions/ardrone_lib_PROD_MODE_vlib_Linux_3.2.0-43-generic-pae_GNU_Linux_gcc_4.6.3 \
           -L$(SDK_PATH)/Soft/Build/targets_versions/sdk_PROD_MODE_vlib_Linux_3.2.0-43-generic-pae_GNU_Linux_gcc_4.6.3 \
           -L$(SDK_PATH)/Soft/Build/targets_versions/vlib_PROD_MODE_Linux_3.2.0-43-generic-pae_GNU_Linux_gcc_4.6.3 \

GENERIC_LIBS:=$(shell pkg-config --cflags gtk+-2.0)

LIBS =$(GENERIC_LIBS) \
      -lpc_ardrone \
      -lsdk \
      -lvlib \


BIN =teste_ardrone

all:
    $(CPP) $(CFLAGS) $(LDFLAGS) $(LIB_PATHS) $(INCLUDES) $(LIBS) $(SRC) -o $(BIN)

谢谢大家,

于 2013-12-30T12:37:08.283 回答