0

我正在做一个需要连接到 AR.Drone 2.0 的项目。我在 Java 中有一个功能性 GUI,但要控制无人机,我必须使用它的 SDK,它是一个 C 库。我编写了通过 JNI 组合 Java 和 C 的必要函数,但由于我对随 SDK 提供的示例进行了修改,它不再构建。它被认为是使用运行 make 命令的 makefile(我也尝试过更改但没有成功)构建的。问题是我对 C 和 makefile 非常陌生,我在网上搜索了很多但没有找到任何解决方案。所以这是图书馆的样子:

.: Folder root
|
+ src: Sources
|
+ ARDroneLib: The AR.Drone Library
| |
| + Soft: Containing the "interesting" part of the whole lib
| | |
| | + More subdirs... (Build: contains a makefile, Common: c and h files, Lib: stuff)
| |
| + Many other subdirectories (FFMPEG, ITTIAM, VLIB, VP_SDK)
|
+ DroneControl: My own code
     |
     + Source:The source files
     | |
     | + Navdata: Code to retrieve the navigation data
     | | |
     | | + navdata.c
     | | + navdata.h
     | |
     | + Video: Code to retrieve the drone's video stream
     | | |
     | | + video_stage.c
     | | + video_stage.h
     | |
     | + ardrone_testing_tool.c: Main file, containing the main function, etc.
     | + ardrone_testing_tool.h: Its header
     | + dronecontrol_ARDrone: My own file, containing JNI methods (also has an init() function which calls main() in ardrone_testing_tool.c)
     | + dronecontrol_ARDrone: Its header
     | + vars.h:     Some shared variables
     |
     + Build:Contains the makefile
         |
         + makefile: The makefile

这是 ./src/DroneControl/Build/ 中的生成文件:

SDK_PATH:=$(shell pwd)/../../ARDroneLib
PC_TARGET=yes
USE_LINUX=yes
ifdef MYKONOS
include $(ARDRONE_CUSTOM_CONFIG)
include $(ARDRONE_BUILD_CONFIG)
else
include $(SDK_PATH)/Soft/Build/custom.makefile
include $(SDK_PATH)/Soft/Build/config.makefile
endif
ifeq "$(RELEASE_BUILD)" "yes"
ARDRONE_TARGET_DIR=$(shell pwd)/../../../
else
ARDRONE_TARGET_DIR=$(shell pwd)/../../../Debug
endif
TARGET=linux_sdk_demo
SRC_DIR:=$(shell pwd)/../Sources
# Define application source files
GENERIC_BINARIES_SOURCE_DIR:=$(SRC_DIR)
GENERIC_BINARIES_COMMON_SOURCE_FILES+= \
Navdata/navdata.c \
Video/video_stage.c
GENERIC_INCLUDES+=     \
$(SRC_DIR) \
$(LIB_DIR) \
$(SDK_PATH)/Soft/Common \
$(SDK_PATH)/Soft/Lib
GENERIC_TARGET_BINARIES_PREFIX=
GENERIC_TARGET_BINARIES_DIR=$(ARDRONE_TARGET_DIR)
GENERIC_BINARIES_SOURCE_ENTRYPOINTS+= \
ardrone_testing_tool.c
GENERIC_INCLUDES:=$(addprefix -I,$(GENERIC_INCLUDES))
GENERIC_LIB_PATHS=-L$(GENERIC_TARGET_BINARIES_DIR)
GENERIC_LIBS=-lpc_ardrone -lgtk-x11-2.0 -lrt
SDK_FLAGS+="USE_APP=yes"
SDK_FLAGS+="APP_ID=linux_sdk_demo"
export GENERIC_CFLAGS
export GENERIC_LIBS
export GENERIC_LIB_PATHS
export GENERIC_INCLUDES
export GENERIC_BINARIES_SOURCE_DIR
export GENERIC_BINARIES_COMMON_SOURCE_FILES
export GENERIC_TARGET_BINARIES_PREFIX
export GENERIC_TARGET_BINARIES_DIR
export GENERIC_BINARIES_SOURCE_ENTRYPOINTS
export GENERIC_LIBRARY_SOURCE_DIR=$(GENERIC_BINARIES_SOURCE_DIR)

.PHONY: $(TARGET) build_libs
all: build_libs $(TARGET)
$(TARGET):
@$(MAKE) -C $(SDK_PATH)/VP_SDK/Build $(TMP_SDK_FLAGS) $(SDK_FLAGS) $(MAKECMDGOALS) USE_LINUX=yes
mv $(ARDRONE_TARGET_DIR)/ardrone_testing_tool $(TARGET)
mv $(TARGET) $(ARDRONE_TARGET_DIR)/
$(MAKECMDGOALS): build_libs
@$(MAKE) -C $(SDK_PATH)/VP_SDK/Build $(TMP_SDK_FLAGS) $(SDK_FLAGS) $(MAKECMDGOALS) USE_LINUX=yes
build_libs:
@$(MAKE) -C $(SDK_PATH)/Soft/Build $(TMP_SDK_FLAGS) $(SDK_FLAGS) $(MAKECMDGOALS) USE_LINUX=yes

但是当我尝试做这个时,make命令给了我以下错误:

Libs already extracted
Building target static
/bin/sh: 1: ./autoConf.bash: Permission denied
make[2]: *** [build] Error 126
Checking required Ubuntu packages ...
ok.
Building ARDroneTool/Lib
Building ARDroneTool/Lib
ld ardrone_testing_tool
/usr/bin/ld: cannot find -lswscale
/usr/bin/ld: cannot find -lavformat
/usr/bin/ld: cannot find -lavcodec
/usr/bin/ld: cannot find -lavutil
collect2: ld returned 1 exit status
make[3]: *** [/home/user/workspace/AutoFlight/lib/native/DroneControl/src/DroneControl/Build/../../..//ardrone_testing_tool] Error 1
make[2]: *** [all] Error 2
make[1]: *** [build_app] Error 2
make: *** [linux_sdk_demo] Error 2

我无法弄清楚 -lwscale、-lavformat 等是什么。我也尝试过将 make 命令设置为 su (主要是因为“权限被拒绝”错误),希望这是问这个问题的正确地方。那么有人对如何将其编译成动态链接库(.so 文件)有建议吗?任何帮助将不胜感激!

更新 1:权限被拒绝错误现已解决(感谢@eyalm)

更新 2:它现在可以工作了。我已经重写了makefile,但我不知道现在有什么不同可能会影响ld's path。

4

2 回答 2

1

autoConf.bash 可能无法执行。使用 su 运行将无济于事。尝试:

# chmod a+x autoConf.bash
于 2012-08-04T10:22:32.327 回答
0
> /usr/bin/ld: cannot find -lswscale
> /usr/bin/ld: cannot find -lavformat
> /usr/bin/ld: cannot find -lavcodec
> /usr/bin/ld: cannot find -lavutil
> collect2: ld returned 1 exit status

这些依赖项(即 、libswscalelibavformatlibavcodeclibavutil可能不存在于您的系统上,或者存在于不属于ld标准搜索路径的目录中。

如果依赖项不存在,那么您需要安装它们。在 Debian 衍生系统上,您可以使用apt-file命令来查找您需要安装的软件包。例如:

% apt-file -l find libswscale.a
libswscale-dev
% apt-file -l find libavutil.a
libavutil-dev
...etc...

如果这些库已经存在于您的系统上,但位于非标准位置,则可以使用ld-L选项将相关目录添加到其搜索路径中。例如:

% ld ..other-options... -L SEARCHDIR1 -L SEARCHDIR2 ... -lswscale -lavutil ...etc...

请注意,选项-L SEARCHDIR需要出现-l LIB选项之前。

于 2012-08-05T02:16:00.670 回答