我对ffmpeg的libavcodec函数的未解析引用有问题,到目前为止在其他地方找不到答案(包括我的想法):)
让我来描述我的设置 - 它需要空间,但是非常基本,可能是我没有看到一些错误......
我使用ndk r5工具链构建了一个FFMPeg,我从http://bambuser.com/opensource获得了ffmpeg端口(在此处的其他问题中推荐).它构建得很好,所以我在我的项目中放了几个静态库,如下所示:
<project>/jni/bambuser_ffmpeg/libavcodec.a
<project>/jni/bambuser_ffmpeg/libavformat.a
<project>/jni/bambuser_ffmpeg/libavcore.a
<project>/jni/bambuser_ffmpeg/libavutil.a
Run Code Online (Sandbox Code Playgroud)
接下来,我在bambuser_ffmpeg文件夹中创建了一个Android.mk,将这些库列为预构建的库:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := bambuser-libavcore
LOCAL_SRC_FILES := libavcore.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := bambuser-libavformat
LOCAL_SRC_FILES := libavformat.a
include $(PREBUILT_STATIC_LIBRARY)
(same for other two libs)
Run Code Online (Sandbox Code Playgroud)
接下来,我有另一个模块在其Android.mk中引用这些库,设置包含路径等:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpegtest
LOCAL_STATIC_LIBRARIES := bambuser-libavcodec bambuser-libavcore bambuser-libavformat bambuser-libavutil
LOCAL_SRC_FILES := ffmpeg_test.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../bambuser_ffmpeg/include
LOCAL_LDLIBS := -llog -lz
include $(BUILD_SHARED_LIBRARY)
Run Code Online (Sandbox Code Playgroud)
最后我有我的ffmpeg_test.cpp这是非常基本的,像这样:
#include <jni.h>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h> …Run Code Online (Sandbox Code Playgroud) 我正在尝试编译一个Git项目,我在使用CMake时遇到了一些问题.最初,它没有找到C++编译器并提示错误:
cmake ..
Run Code Online (Sandbox Code Playgroud)
找不到CMAKE_CXX_COMPILER.
通过将环境变量"CXX"或CMake缓存条目CMAKE_CXX_COMPILER设置为编译器的完整路径,或者如果它位于PATH中的编译器名称,告诉CMake在哪里找到编译器.
所以我做了:
CXX="gcc" cmake ..
Run Code Online (Sandbox Code Playgroud)
但是提示了另一个错误:
- CXX编译器标识未知
- 检查工作CXX编译器:/ usr/bin/gcc
- 检查工作CXX编译器:/ usr/bin/gcc -
/usr/share/cmake-3.0中的CMake错误/Modules/CMakeTestCXXCompiler.cmake:54(消息):
C++编译器"/ usr/bin/gcc"无法编译简单的测试程序.
如何解决此错误并编译项目?
我使用Android Studio 2.2 cmake来构建本机代码,在本机代码中我调用了ffmpeg api,因此应该打包ffmpeg库.我CMakelists.txt的如下:
cmake_minimum_required(VERSION 3.4.1)
include_directories(libs/arm/include)
link_directories(libs/arm/lib/)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
# Associated headers in the same location as their source
# file are automatically included.
src/main/cpp/native-lib.cpp )
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to …Run Code Online (Sandbox Code Playgroud) 在使用 docker compose 构建 docker 容器之前,有没有办法执行 bash 脚本?
就像是
version: "3"
before_script: //execute my local script
services:
database: ....
Run Code Online (Sandbox Code Playgroud) 我试图在 jetson nano 的 docker 中安装 OpenCV4。它有喷气背包 4.4 s 操作系统。docker 已成功创建并且 Tensorflow 正在运行,但在使用 pip 安装 OpenCV 时,它显示 CMake 错误。
root@5abf405fb92d:~# pip3 install opencv-python
Collecting opencv-python
Downloading opencv-python-4.4.0.42.tar.gz (88.9 MB)
|????????????????????????????????| 88.9 MB 2.5 kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from opencv-python) (1.18.4)
Building wheels for collected packages: opencv-python
Building wheel for opencv-python (PEP 517) ... error
ERROR: Command errored out with exit …Run Code Online (Sandbox Code Playgroud) #include <stdio.h>
#include <stdlib.h>
struct NODE {
char* name;
int val;
struct NODE* next;
};
typedef struct NODE Node;
Node *head, *tail;
head = (Node*) malloc( sizeof( Node ) ); //line 21
Run Code Online (Sandbox Code Playgroud)
我编译如下:
cc -g -c -o file.tab.o file.tab.c
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
file.y:21:1 warning: data definition has no type or storage class [enabled by default]
Run Code Online (Sandbox Code Playgroud) 我正在内核中创建一个简单的enque/deque程序.我想在内核中打印消息,这就是我得到的:
[18594.595747] Enqueue 3
[18594.595748] queue :
[18594.595751] 2
[18594.595751] 1
[18594.595752] 3
Run Code Online (Sandbox Code Playgroud)
但我想打印这个没有换行符:
[8594.595747] Enqueue 3
[18594.595748] queue : 2 1 3
Run Code Online (Sandbox Code Playgroud)
这是我的代码的一部分:
printk(KERN_ALERT "Enqueue %d \n queue : ", a);
rear++;
for(i = front; i<rear; i++)
printk(KERN_ALERT "%d ", queue_test[i]);
Run Code Online (Sandbox Code Playgroud)
简而言之,我想在内核中打印一行消息.但如果我使用printk,它会自动更改行.如何在一行中打印消息?
在CMake中ELSE,ENDIF控制流函数将表达式作为参数.根据文档,这些是可选的.那么这些目的是什么?是仅仅IF为了维护目的使原始表达更清楚,还是它提供了一些功能?
考虑一个由一个库和一组使用该库的可执行文件组成的项目。一种简单的方法是add_library(),后接一系列对add_executable() target_link_libraries()。
这是大量的样板代码。如果能够执行类似的操作set(PROJECT_LINK_LIBS, lib1 ...)并让 CMake 删除额外的样板文件,那就太好了。
进一步思考这一点,我意识到我想要一个link_libraries行为类似于 的函数include_directories。我认为:
有这样的事吗?
我是 Cmake 和 Gtest 的新手。我在 CMake 中有问题
find_package(GMock REQUIRED)
Run Code Online (Sandbox Code Playgroud)
和
target_link_libraries(runtest ${GMOCK_BOTH_LIBRARIES} pthread).
Run Code Online (Sandbox Code Playgroud)
当我构建项目时,CMake 找不到 GMock 包。
但是当我提到库的绝对路径时,它工作正常。
例如:
set(GMOCK_INCLUDE_DIRS /usr/local/include/gmock)
set(GMOCK_BOTH_LIBRARIES /usr/local/lib/libgmock.a /usr/local/lib/libgmock_main.a /usr/local/lib/libgtest.a /usr/local/lib/libgtest_main.a)
Run Code Online (Sandbox Code Playgroud)
现在的问题是我的主管建议我找到仅使用查找包来运行代码的解决方案。在做了一些研究之后,我才知道FindGMock.cmakeCmake 模块中缺少该文件。我添加了它并使用 再次运行代码find_package(),但它仍然无法正常工作。
错误是对 Gmock 和 Gtest 功能的未定义引用。
例如 :
undefined reference to `testing::Message::Message()'.
undefined reference to testing::internal::GetBoolAssertionFailureMessage.
undefined reference totesting::internal::AssertHelper::~AssertHelper()'
Run Code Online (Sandbox Code Playgroud)
这样的错误太多了。
谁能解释一下,如何让 CMake 自动找到 GMock 包?