- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试将程序从 Linux 桌面移植到 Android。它使用 libzmq
在 C++ 中。
我想使用 zmq.hpp
(ZeroMQ 的 Cpp 绑定(bind))在没有 jerozmq
的应用程序的 native 代码中或 jzmq
.
我已经建立 libzmq
使用此脚本的 4 拱门:
export PATH=/home/hmi/Android/arm-26-toolchain-clang:$PATH
rm -r /tmp/zeromq-android
cd /tmp/
#git clone https://github.com/zeromq/libzmq.git
cd libzmq/
############################################################################
# arm-linux-androideabi
export OUTPUT_DIR=/tmp/zeromq-android/arm-linux-androideabi
./autogen.sh
./configure --enable-static \
--disable-shared \
--host=arm-linux-androideabi \
--prefix=$OUTPUT_DIR \
LDFLAGS="-L$OUTPUT_DIR/lib" \
CPPFLAGS="-fPIC -I$OUTPUT_DIR/include" \
LIBS="-lgcc"
make -j4
make install
############################################################################
# armv7a-linux-androideabi
export OUTPUT_DIR=/tmp/zeromq-android/armeabi-v7a
./autogen.sh
./configure --enable-static \
--disable-shared \
--host=armv7a-linux-androideabi \
--prefix=$OUTPUT_DIR \
LDFLAGS="-L$OUTPUT_DIR/lib" \
CPPFLAGS="-fPIC -I$OUTPUT_DIR/include" \
LIBS="-lgcc"
make -j4
make install
############################################################################
# aarch64-linux-android
export OUTPUT_DIR=/tmp/zeromq-android/arm64-v8a
./autogen.sh
./configure --enable-static \
--disable-shared \
--host=aarch64-linux-android \
--prefix=$OUTPUT_DIR \
LDFLAGS="-L$OUTPUT_DIR/lib" \
CPPFLAGS="-fPIC -I$OUTPUT_DIR/include" \
LIBS="-lgcc"
make -j4
make install
############################################################################
# i686-linux-android
export OUTPUT_DIR=/tmp/zeromq-android/x86
./autogen.sh
./configure --enable-static \
--disable-shared \
--host=i686-linux-android \
--prefix=$OUTPUT_DIR \
LDFLAGS="-L$OUTPUT_DIR/lib" \
CPPFLAGS="-fPIC -I$OUTPUT_DIR/include" \
LIBS="-lgcc"
make -j4
make install
############################################################################
# x86_64-linux-android
export OUTPUT_DIR=/tmp/zeromq-android/x86_64
./autogen.sh
./configure --enable-static \
--disable-shared \
--host=x86_64-linux-android \
--prefix=$OUTPUT_DIR \
LDFLAGS="-L$OUTPUT_DIR/lib" \
CPPFLAGS="-fPIC -I$OUTPUT_DIR/include" \
LIBS="-lgcc"
make -j4
make install
cd /tmp/zeromq-android/
mkdir all
cd all
for i in \
"armeabi-v7a" \
"arm64-v8a" \
"x86" \
"x86_64"
do
mkdir ${i}
cp -r /tmp/zeromq-android/$i/lib/* ./$i/
done
############################################################################
## jzmq
#export OUTPUT_DIR=/tmp/zeromq-android-arm-linux-androideabi
#
#cd /tmp/
#git clone https://github.com/zeromq/jzmq.git
#cd jzmq/jzmq-jni/
#./autogen.sh
#./configure --host=arm-linux-androideabi \
# --prefix=$OUTPUT_DIR \
# --with-zeromq=$OUTPUT_DIR \
# CPPFLAGS="-fPIC -I$OUTPUT_DIR/include" \
# LDFLAGS="-L$OUTPUT_DIR/lib" \
# --disable-version \
# LIBS="-lpthread -lrt"
#make
#make install}
Runtime.error.loadingLib(native-lib)
/home/hmi/barepo/AndroidCppZmq/app/src/main/cpp/include/zmq.hpp:766: error: undefined reference to 'zmq_ctx_destroy'
libzmq
在
CMakeList.txt
与
add_library(zmq STATIC .../libzmq.a)
最佳答案
谢谢你的回复。因此,现在我想使用 Android 虚拟设备(Pixel C API 28)进行测试,并在 Android-Studio 中使用 c++ 代码创建了一个新项目。
摆脱cppzmq
我只使用 libzmq
现在。
我已经建立 libzmq
使用以下脚本:
#!/bin/bash
OLDPATH=$PATH
rm -r /tmp/zeromq-android
cd /tmp/
git clone https://github.com/zeromq/libzmq.git
cd libzmq/
export NDK=$HOME/initEnvV0.0/AndroidSdk/ndk/21.0.6113669
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
# Only choose one of these, depending on your device...
#export TARGET=aarch64-linux-android
#export TARGET=armv7a-linux-androideabi
#export TARGET=i686-linux-android
export TARGET=x86_64-linux-android
# Set this to your minSdkVersion.
export API=28
# Configure and build.
export AR=$TOOLCHAIN/bin/$TARGET-ar
export AS=$TOOLCHAIN/bin/$TARGET-as
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/$TARGET-ld
export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib
export STRIP=$TOOLCHAIN/bin/$TARGET-strip
export OUTPUT_DIR=/tmp/zeromq-android/$TARGET
./autogen.sh
#./configure --host $TARGET
./configure --enable-static \
--disable-shared \
--host=$TARGET \
--prefix=$OUTPUT_DIR LDFLAGS="-L$OUTPUT_DIR/lib" \
CPPFLAGS="-fPIC -I$OUTPUT_DIR/include" \
LIBS="-lgcc" # ^ was missing
make
make install
jniFolder
后,我的目录如下所示:
src/main/jniLibs/
└── x86_64
├── bin
│ └── curve_keygen
├── include
│ ├── zmq.h
│ └── zmq_utils.h
└── lib
├── libzmq.a
├── libzmq.la
├── libzmq.so
└── pkgconfig
└── libzmq.pc
native-lib.cpp
:
// libzmq
#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
int testlibzmq (void)
{
// Socket to talk to clients
void *context = zmq_ctx_new ();
void *responder = zmq_socket (context, ZMQ_REP);
int rc = zmq_bind (responder, "tcp://*:5555");
assert (rc == 0);
char buffer [10];
zmq_recv (responder, buffer, 10, 0);
printf ("Received Hello\n");
sleep (1); // Do some 'work'
zmq_send (responder, "World", 5, 0);
return 0;
}
CMakelist.txt
看起来像这样:
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.
include_directories(
/home/hmi/barepo/AndroidCppZmq/app/src/main/jniLibs/x86_64/include
)
add_library( zmq STATIC IMPORTED )
set_target_properties( zmq PROPERTIES IMPORTED_LOCATION /home/hmi/barepo/AndroidCppZmq/app/src/main/jniLibs/x86_64/lib/libzmq.a )
set_target_properties( zmq PROPERTIES INCLUDE_DIRECTORIES /home/hmi/barepo/AndroidCppZmq/app/src/main/jniLibs/x86_64/include )
add_library( native-lib # Sets the name of the library.
SHARED # Sets the library as a shared library.
native-lib.cpp # Provides a relative path to your source file(s).
)
# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
find_library( log-lib # Sets the name of the path variable.
log # Specifies the name of the NDK library that
) # you want CMake to locate.
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
target_link_libraries( native-lib # Specifies the target library.
zmq # Links the target library to the log library
${log-lib} # included in the NDK.
)
Android.mk
和
Application.mk
我的
jniLibs-Folder
旁边的文件?有没有人尝试使用
libzmq
在没有
jzmq
的 native 代码中或
Jeromq
?
native-lib
时构建卡顿:
Entering directory `/home/hmi/barepo/AndroidCppZmq/app/.cxx/cmake/debug/x86_64'
[1/1] Linking CXX shared library /home/hmi/barepo/AndroidCppZmq/app/build/intermediates/cmake/debug/obj/x86_64/libnative-lib.so
FAILED: /home/hmi/barepo/AndroidCppZmq/app/build/intermediates/cmake/debug/obj/x86_64/libnative-lib.so
关于android - 如何让 Android 使用 ZeroMQ libzmq?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61598918/
我正在尝试使用 ZeroMQ C# 绑定(bind) ( http://www.zeromq.org/bindings:clr ) 与我在 Unity 中创建的游戏的服务器进行通信(我使用的是 Mac
tl;dr 问:“我们如何成功部署 [非托管库] libzmq 以动态加载以支持在 C# 程序中使用的‘ZeroMQ CLR 命名空间’?” 安装了 NuGet pkg ZeroMQ 4.1.0.17
我有一个在 .NET Framework 4.0 x64 上运行的 x64 C# 应用程序,该应用程序对 clrzmq 使用 ZeroMQ -x64 2.2.2(来自 NuGet)。 当我调试它(
从 ZMQ 4.1 版开始编辑:Configure 会自动查找 libsodium,因此不再需要。如果出于某种原因你希望在没有 libsodium 的情况下构建它并且你已经构建并安装了它,请使用“--
在为rails应用程序运行rake期间,我收到以下错误“在[libzmq.so]中找不到函数'zmq_getsockopt'” 有人知道如何解决这个问题吗?谢谢 我使用 Ubuntu 10.10。 最
我尝试将程序从 Linux 桌面移植到 Android。它使用 libzmq在 C++ 中。 我想使用 zmq.hpp (ZeroMQ 的 Cpp 绑定(bind))在没有 jerozmq 的应用程序
在 py2exe 构建过程中出现以下错误: creating python loader for extension 'win32clipboard' (C:\Python27\lib\site-pa
不确定我是否在正确的 Stack Exchange 论坛上发帖。如果需要,请将我重定向到正确的位置。 在设置 Ratchet 时,我需要安装 ZeroMQ 并且卡在 libzmq 安装上: 我已按照说
我在 Mac 上使用 Xamarin Studio,通过 NuGet 包含 clrzmq。 clrzmq 对 libzmq.dll 的引用。我的应用程序编译正常,但当我尝试运行它时,我得到了这个: U
我正在尝试将 zeroMQ 嵌入到我的应用程序中,我遵循了 this guideline安装 ZMQ,所以到这里一切正常。我的应用程序中有这行代码: ZMQ.Context m_context = Z
在Linux-Ubuntu上安装ZeroMQ,一个网站 https://tuananh.org/2015/06/16/how-to-install-zeromq-on-ubuntu/ 说要运行以下命令
我是一名优秀的程序员,十分优秀!