I'm trying to use SKIA lib in my WASM solution. first I Compiled Skia to wasm bitcode using bellow config:
/bin/gn gen ./out/Build-wasm-Release/Release --args="cc=\"emcc\" extra_cflags_cc=[\"-frtti\",\"-s\",\"USE_FREETYPE=1\"] cxx=\"em++\" extra_cflags=[\"-Wno-unknown-warning-option\",\"-s\",\"USE_FREETYPE=1\",\"-s\",\"USE_LIBPNG=1\"] \
is_debug=false \
is_official_build=true \
is_component_build=false \
target_cpu=\"wasm\" \
\
skia_use_egl=false \
skia_use_vulkan=false \
skia_use_libwebp=false \
skia_use_libpng=true \
skia_use_lua=false \
skia_use_dng_sdk=false \
skia_use_fontconfig=false \
skia_use_libjpeg_turbo=false \
skia_use_libheif=false \
skia_use_expat=false \
skia_use_vulkan=false \
skia_use_freetype=false \
skia_use_icu=false \
skia_use_expat=false \
skia_use_piex=false \
skia_use_zlib=true \
skia_enable_gpu=true \
skia_enable_pdf=false"
it successfully compiled, when I try to compile my own code using:
em++ multiply.cpp -o multiply.js -s EXPORTED_FUNCTIONS="['_float_multiply','_float_multiply_array','_sample_array_rtn','_sample_array_float_rtn','_msd_main']"-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -s ALLOW_MEMORY_GROWTH=1 -s USE_WEBGL2=1 -s NO_EXIT_RUNTIME=1 -s USE_LIBPNG=1 -s WASM=1 -s MODULARIZE=1 -s FORCE_FILESYSTEM=0 -I$SKIAPATH/include/ -I$SKIAPATH/include/gpu -I$SKIAPATH/include/core -I$SKIAPATH/include/config -I$SKIAPATH/include/c -L$SKIAPATH/out/Build-wasm-Release/Release -I$SKIAPATH -lskia
I got bellow this error:
LLVM ERROR: Invalid SIMD cast between items of different bit sizes!
I am trying to write a softphone using qt. And many forums and resources, including stackoverflow, suggest to use pjsip libraries. So I decided to follow this advice and use it.
First, to be clear about my post here, my OS is linux (KUbuntu to be percise), and I am using Qt 5.4.1 and Qt Creator 3.3.2.
Also, I built pjsip static libraries using instructions on their website here: http://trac.pjsip.org/repos/wiki/Getting-Started/Autoconf.
And I have some troubles linking pjsip static libraries using qt. I've searched about this problem and didn't find the answer neither on this site nor anywhere. There are some topics on the forums but no one gives an answer to it.
Here is my qt .pro file:
TEMPLATE = app
QT += qml quick widgets
SOURCES += main.cpp
RESOURCES += qml.qrc
INCLUDEPATH += $$_PRO_FILE_PWD_/pjsip_headers
LIBS += -L$$_PRO_FILE_PWD_/pjsip_libs
linux-g++-64:LIBS += -lpjsua-x86_64-unknown-linux.gnu \
-lpjsip-ua-x86_64-unknown-linux.gnu\
-lpjsip-simple-x86_64-unknown-linux.gnu \
-lpjsip-x86_64-unknown-linux.gnu \
-lpjmedia-codec-x86_64-unknown-linux.gnu \
-lpjmedia-x86_64-unknown-linux.gnu \
-lpjmedia-codec-x86_64-unknown-linux.gnu \
-lpjmedia-audiodev-x86_64-unknown-linux.gnu \
-lpjmedia-videodev-x86_64-unknown-linux.gnu \
-lpjnath-x86_64-unknown-linux.gnu \
-lpjlib-util-x86_64-unknown-linux.gnu \
-lpj-x86_64-unknown-linux.gnu \
-lportaudio-x86_64-unknown-linux.gnu \
-lgsmcodec-x86_64-unknown-linux.gnu \
-lilbccodec-x86_64-unknown-linux.gnu \
-lspeex-x86_64-unknown-linux.gnu \
-lresample-x86_64-unknown-linux.gnu \
-lsrtp-x86_64-unknown-linux.gnu \
-lg7221codec-x86_64-unknown-linux.gnu \
-lopenh264 \
-lpjsua2-x86_64-unknown-linux.gnu
QML_IMPORT_PATH =
include(deployment.pri)
And here is the problem: when I try to build my project with this .pro file above, everything is OK until i try to use some function or an object of any class in this library. And if I do so, I get many undefined reference errors.
Pjsip manual says only about how to build your own application with this library by using GNU tools here: http://trac.pjsip.org/repos/wiki/Getting_Started_Using. But it involves editing Makefile, which is autogenerated by qmake in qt.
I just stuck with this problem and I don't know what else I can do about it. I read about linking order of this library while including it in your qt .pro file, but I tried many combinations and it didn't help.
Also, I read that it might be necessary to use QMAKE variables to set CFLAGS and LDFLAGS in qt .pro file according to pjsip instructions of how to build your own application using GNU tools.
And I even downloaded qt projects, which use pjsip libraries, for example, QjSimple, but I didn't find anything new in their qt .pro file settings.
Here is their qt .pro file:
DEFINES -= UNICODE
TEMPLATE = app
TARGET = QjSimple
QT += core \
gui \
xml \
network
HEADERS += buddy.h \
PjCallback.h \
accountdialog.h \
debugdialog.h \
addbuddydialog.h \
imwidget.h \
qjsimple.h
SOURCES += buddy.cpp \
PjCallback.cpp \
accountdialog.cpp \
debugdialog.cpp \
addbuddydialog.cpp \
imwidget.cpp \
main.cpp \
qjsimple.cpp
FORMS += accountdialog.ui \
debugdialog.ui \
addbuddydialog.ui \
imwidget.ui \
qjsimple.ui
RESOURCES += icons.qrc
win32-g++:RC_FILE = appicon.rc
INCLUDEPATH += ../pjproject-1.8.10/pjlib/include \
../pjproject-1.8.10/pjlib-util/include \
../pjproject-1.8.10/pjnath/include \
../pjproject-1.8.10/pjmedia/include \
../pjproject-1.8.10/pjsip/include
LIBS += -L../pjproject-1.8.10/pjlib/lib \
-L../pjproject-1.8.10/pjlib-util/lib \
-L../pjproject-1.8.10/pjnath/lib \
-L../pjproject-1.8.10/pjmedia/lib \
-L../pjproject-1.8.10/pjsip/lib \
-L../pjproject-1.8.10/third_party/lib
# INCLUDEPATH += ../pjproject-1.5.5/pjlib/include \
# ../pjproject-1.5.5/pjlib-util/include \
# ../pjproject-1.5.5/pjnath/include \
# ../pjproject-1.5.5/pjmedia/include \
# ../pjproject-1.5.5/pjsip/include
# LIBS += -L../pjproject-1.5.5/pjlib/lib \
# -L../pjproject-1.5.5/pjlib-util/lib \
# -L../pjproject-1.5.5/pjnath/lib \
# -L../pjproject-1.5.5/pjmedia/lib \
# -L../pjproject-1.5.5/pjsip/lib \
# -L../pjproject-1.5.5/third_party/lib
# INCLUDEPATH += ../pjproject-1.4/pjlib/include \
# ../pjproject-1.4/pjlib-util/include \
# ../pjproject-1.4/pjnath/include \
# ../pjproject-1.4/pjmedia/include \
# ../pjproject-1.4/pjsip/include
# LIBS += -L../pjproject-1.4/pjlib/lib \
# -L../pjproject-1.4/pjlib-util/lib \
# -L../pjproject-1.4/pjnath/lib \
# -L../pjproject-1.4/pjmedia/lib \
# -L../pjproject-1.4/pjsip/lib \
# -L../pjproject-1.4/third_party/lib
# win32-g++:LIBS += -L../openssl-0.9.8g
win32-g++:LIBS += -L../OpenSSL/lib/mingw
win32-g++:LIBS += -lpjsua-i686-pc-mingw32 \
-lpjsip-ua-i686-pc-mingw32 \
-lpjsip-simple-i686-pc-mingw32 \
-lpjsip-i686-pc-mingw32 \
-lpjmedia-codec-i686-pc-mingw32 \
-lpjmedia-i686-pc-mingw32 \
-lpjmedia-codec-i686-pc-mingw32 \
-lpjmedia-audiodev-i686-pc-mingw32 \
-lpjnath-i686-pc-mingw32 \
-lpjlib-util-i686-pc-mingw32 \
-lpj-i686-pc-mingw32 \
-lportaudio-i686-pc-mingw32 \
-lgsmcodec-i686-pc-mingw32 \
-lilbccodec-i686-pc-mingw32 \
-lspeex-i686-pc-mingw32 \
-lresample-i686-pc-mingw32 \
-lmilenage-i686-pc-mingw32 \
-lsrtp-i686-pc-mingw32 \
-lm \
-lwinmm \
-lole32 \
-lws2_32 \
-lwsock32 \
-lssl \
-lcrypto \
-lgdi32
linux-g++:LIBS += -lpjsua-i686-pc-linux-gnu \
-lpjsip-ua-i686-pc-linux-gnu \
-lpjsip-simple-i686-pc-linux-gnu \
-lpjsip-i686-pc-linux-gnu \
-lpjmedia-codec-i686-pc-linux-gnu \
-lpjmedia-i686-pc-linux-gnu \
-lpjmedia-codec-i686-pc-linux-gnu \
-lpjmedia-audiodev-i686-pc-linux-gnu \
-lpjnath-i686-pc-linux-gnu \
-lpjlib-util-i686-pc-linux-gnu \
-lpj-i686-pc-linux-gnu \
-lportaudio-i686-pc-linux-gnu \
-lgsmcodec-i686-pc-linux-gnu \
-lilbccodec-i686-pc-linux-gnu \
-lspeex-i686-pc-linux-gnu \
-lresample-i686-pc-linux-gnu \
-lmilenage-i686-pc-linux-gnu \
-lsrtp-i686-pc-linux-gnu \
-lm \
-lpthread \
-lssl \
-lasound \
-luuid
linux-g++-64:LIBS += -lpjsua-x86_64-unknown-linux-gnu \
-lpjsip-ua-x86_64-unknown-linux-gnu \
-lpjsip-simple-x86_64-unknown-linux-gnu \
-lpjsip-x86_64-unknown-linux-gnu \
-lpjmedia-codec-x86_64-unknown-linux-gnu \
-lpjmedia-x86_64-unknown-linux-gnu \
-lpjmedia-codec-x86_64-unknown-linux-gnu \
-lpjmedia-audiodev-x86_64-unknown-linux-gnu \
-lpjnath-x86_64-unknown-linux-gnu \
-lpjlib-util-x86_64-unknown-linux-gnu \
-lpj-x86_64-unknown-linux-gnu \
-lportaudio-x86_64-unknown-linux-gnu \
-lgsmcodec-x86_64-unknown-linux-gnu \
-lilbccodec-x86_64-unknown-linux-gnu \
-lspeex-x86_64-unknown-linux-gnu \
-lresample-x86_64-unknown-linux-gnu \
-lmilenage-x86_64-unknown-linux-gnu \
-lsrtp-x86_64-unknown-linux-gnu \
-lm \
-lpthread \
-lssl \
-lasound \
-luuid
macx-g++:LIBS += -lpjsua-i386-apple-darwin9.7.1 \
-lpjsip-ua-i386-apple-darwin9.7.1 \
-lpjsip-simple-i386-apple-darwin9.7.1 \
-lpjsip-i386-apple-darwin9.7.1 \
-lpjmedia-i386-apple-darwin9.7.1 \
-lpjmedia-i386-apple-darwin9.7.1 \
-lpjmedia-codec-i386-apple-darwin9.7.1 \
-lpjmedia-audiodev-i386-apple-darwin9.7.1 \
-lpjnath-i386-apple-darwin9.7.1 \
-lpjlib-util-i386-apple-darwin9.7.1 \
-lpj-i386-apple-darwin9.7.1 \
-lportaudio-i386-apple-darwin9.7.1 \
-lgsmcodec-i386-apple-darwin9.7.1 \
-lilbccodec-i386-apple-darwin9.7.1 \
-lspeex-i386-apple-darwin9.7.1 \
-lresample-i386-apple-darwin9.7.1 \
-lmilenage-i386-apple-darwin9.7.1 \
-lsrtp-i386-apple-darwin9.7.1 \
-lm \
-lpthread \
-lssl \
-lcrypto \
-framework \
CoreAudio \
-framework \
AudioToolbox \
-framework \
AudioUnit
OTHER_FILES += Changelog
There is nothing new in their .pro file.
So I just don't know where to find the solution. I hope I gave enough information. And as I mentioned above, I didn't find anyting useful about this problem.
Maybe there is another way to build a softphone by using qt, but as I found out pjsip library is one of the best decisions to do that. Any information would be appreciated.
I'm trying to link ffmpeg as static libraries with android NDK but I'm getting 'multiple definition' error' errors as below. I've also included my build script which runs through everything just fine but when I come to using the libraries in Eclipse with the ADT plugin, I can't get anywhere.
From this it looks like it wants something to do with VLC. I don't want anything to do with VLC, just ffmpeg for video streaming. Everything works fine with shared libraries, but I'm after a very tiny player because I'm restricted to space on the device.
EDIT: Also 'log2_tab_tab.o' has multiple definitions.
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_golomb_vlc_len' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_dirac_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_golomb_vlc_len' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_se_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_interleaved_ue_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_se_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_ue_golomb_len' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(golomb.o): multiple definition of 'ff_ue_golomb_vlc_code' Ffplayer C/C++ Problem
error: jni/libs\libavcodec.a(log2_tab.o): multiple definition of 'ff_log2_tab' Ffplayer C/C++ Problem
error: jni/libs\libavformat.a(log2_tab.o): multiple definition of 'ff_log2_tab' Ffplayer C/C++ Problem
jni/libs\libavformat.a(golomb_tab.o): previous definition here Ffplayer C/C++ Problem
jni/libs\libavutil.a(log2_tab.o): previous definition here Ffplayer C/C++ Problem
make.exe: *** [obj/local/armeabi-v7a-hard/libffplayer.so] Error 1 Ffplayer C/C++ Problem
Using the latest branch of ffmpeg (2.4.3) my build script for Android (using toolchain 8 because it's old hardware I'm working with) and wanting the NEON hardware support:
export ANDROID_NDK=/home/carl/dev/ndk
export TOOLCHAIN=/home/carl/temp/ffmpeg
export SYSROOT=$TOOLCHAIN/sysroot/
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh \
--platform=android-8 --install-dir=$TOOLCHAIN
export PATH=$TOOLCHAIN/bin:$PATH
export CC=arm-linux-androideabi-gcc
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar
CFLAGS="-O3 -Wall -mthumb -pipe -fpic -fasm \
-finline-limit=300 -ffast-math \
-fstrict-aliasing -Werror=strict-aliasing \
-fmodulo-sched -fmodulo-sched-allow-regmoves \
-Werror=implicit-function-declaration \
-Wno-psabi -Wa,--noexecstack"
# -D__ARM_ARCH_5__ -D__ARM_ARCH_5E__ \
# -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ \
# -DANDROID -DNDEBUG"
EXTRA_CFLAGS="-march=armv7-a -mfpu=neon \
-mfloat-abi=softfp -mvectorize-with-neon-quad \
-DHAVE_ISNAN -DHAVE_ISINF
-std=c99"
EXTRA_LDFLAGS="-Wl,--fix-cortex-a8"
FFMPEG_FLAGS="--prefix=/home/dev/ffmpeg/build \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--cross-prefix=arm-linux-androideabi- \
--enable-shared \
--enable-static \
--enable-small \
--disable-symver \
--disable-doc \
--disable-ffplay \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-encoders \
--disable-muxers \
--disable-demuxers \
--disable-filters \
--disable-devices \
--disable-decoders \
--enable-decoder=mjpeg \
--enable-decoder=mp1 \
--enable-decoder=mp2 \
--enable-decoder=mp3 \
--enable-decoder=mpeg1_vdpau \
--enable-decoder=mpeg1video \
--enable-decoder=mpeg2video \
--enable-decoder=mpeg4 \
--enable-decoder=mpeg4_vdpau \
--enable-decoder=mpegvideo \
--enable-decoder=mpeg_xvmc \
--enable-decoder=h261 \
--enable-decoder=h263 \
--enable-decoder=h263i \
--enable-decoder=h263p \
--enable-hwaccel=h263_vaapi \
--enable-hwaccel=h263_vdpau \
--enable-hwaccel=mpeg1_vdpau \
--enable-hwaccel=mpeg1_xvmc \
--enable-hwaccel=mpeg2_dxva2 \
--enable-hwaccel=mpeg2_vaapi \
--enable-hwaccel=mpeg2_vdpau \
--enable-hwaccel=mpeg2_xvmc \
--enable-hwaccel=mpeg4_vaapi \
--enable-hwaccel=mpeg4_vdpau \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=h261 \
--enable-demuxer=h263 \
--enable-demuxer=pcm_s16be \
--enable-demuxer=pcm_s16le \
--enable-demuxer=pcm_s8 \
--enable-demuxer=mpegps \
--enable-demuxer=mpegts \
--enable-demuxer=mpegtsraw \
--enable-demuxer=mpegvideo \
--enable-demuxer=rtp \
--enable-demuxer=rtsp \
--enable-parser=aac \
--enable-parser=mpegvideo \
--enable-parser=ac3 \
--enable-parser=h261 \
--enable-parser=h263 \
--enable-parser=mjpeg \
--enable-parser=mpeg4video \
--enable-parser=mpegaudio \
--enable-protocol=rtp \
--enable-protocol=file \
--enable-protocol=ftp \
--enable-protocol=tcp \
--enable-protocol=http \
--enable-protocol=udp \
--enable-protocol=pipe \
--enable-protocol=unix \
--enable-network \
--disable-swscale \
--enable-asm \
--enable-memalign-hack \
--disable-golomb \
--enable-stripping \
--enable-pthreads \
--disable-symver \
--enable-version3"
./configure $FFMPEG_FLAGS --extra-cflags="$CFLAGS $EXTRA_CFLAGS" \
--extra-ldflags="$EXTRA_LDFLAGS"
make clean
echo "Project now cleaned"
make -j4
echo "Stripping multiple references from libraries"
arm-linux-androideabi-ar d libavcodec.a log2_tab.o
arm-linux-androideabi-ar d libavutil.a log2_tab.o
echo "Done..."
And this is the Android.mk file which works fine.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := avutil
LOCAL_SRC_FILES := libs\libavutil.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := avformat
LOCAL_SRC_FILES := libs\libavformat.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := avcodec
LOCAL_SRC_FILES := libs\libavcodec.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ffplayer
LOCAL_SRC_FILES := ffplayer.cpp
LOCAL_C_INCLUDES := C:\DEV\ffmpeg\
LOCAL_LDLIBS += -llog -ljnigraphics -lGLESv2 -ldl
LOCAL_LDLIBS += -lstdc++ -lc
LOCAL_LDLIBS += -lz -lm
LOCAL_WHOLE_STATIC_LIBRARIES += libavutil libavformat libavcodec
include $(BUILD_SHARED_LIBRARY)
If anybody can spot what's wrong with this it would be so appreciated.
I figured it out by using a similar build method someone else used and just added my own options. This one also copies the folders "bin", "lib", "include" and the "share". All I needed then was to add the "lib" and "include" folders to my project. Phew!
#!/bin/bash
NDK=/home/carl/dev/ndk
PLATFORM=$NDK/platforms/android-9/arch-arm
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/
PREFIX=/home/carl/temp/ffmpeg/
function build_one
{
./configure --target-os=linux --prefix=$PREFIX \
--enable-cross-compile \
--enable-runtime-cpudetect \
--enable-asm \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--disable-stripping \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--enable-nonfree \
--enable-small \
--disable-symver \
--disable-doc \
--disable-ffplay \
--disable-ffmpeg \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-avfilter \
--disable-encoders \
--disable-muxers \
--disable-demuxers \
--disable-filters \
--disable-devices \
--disable-decoders \
--enable-decoder=mjpeg \
--enable-decoder=mp1 \
--enable-decoder=mp2 \
--enable-decoder=mp3 \
--enable-decoder=mpeg1_vdpau \
--enable-decoder=mpeg1video \
--enable-decoder=mpeg2video \
--enable-decoder=mpeg4 \
--enable-decoder=mpeg4_vdpau \
--enable-decoder=mpegvideo \
--enable-decoder=mpeg_xvmc \
--enable-decoder=h261 \
--enable-decoder=h263 \
--enable-decoder=h263i \
--enable-decoder=h263p \
--enable-hwaccel=h263_vaapi \
--enable-hwaccel=h263_vdpau \
--enable-hwaccel=mpeg1_vdpau \
--enable-hwaccel=mpeg1_xvmc \
--enable-hwaccel=mpeg2_dxva2 \
--enable-hwaccel=mpeg2_vaapi \
--enable-hwaccel=mpeg2_vdpau \
--enable-hwaccel=mpeg2_xvmc \
--enable-hwaccel=mpeg4_vaapi \
--enable-hwaccel=mpeg4_vdpau \
--enable-demuxer=aac \
--enable-demuxer=ac3 \
--enable-demuxer=h261 \
--enable-demuxer=h263 \
--enable-demuxer=pcm_s16be \
--enable-demuxer=pcm_s16le \
--enable-demuxer=pcm_s8 \
--enable-demuxer=mpegps \
--enable-demuxer=mpegts \
--enable-demuxer=mpegtsraw \
--enable-demuxer=mpegvideo \
--enable-demuxer=rtp \
--enable-demuxer=rtsp \
--enable-parser=aac \
--enable-parser=mpegvideo \
--enable-parser=ac3 \
--enable-parser=h261 \
--enable-parser=h263 \
--enable-parser=mjpeg \
--enable-parser=mpeg4video \
--enable-parser=mpegaudio \
--enable-protocol=rtp \
--enable-protocol=file \
--enable-protocol=ftp \
--enable-protocol=tcp \
--enable-protocol=http \
--enable-protocol=udp \
--enable-protocol=pipe \
--enable-protocol=unix \
--enable-network \
--disable-swscale \
--enable-asm \
--enable-memalign-hack \
--enable-stripping \
--enable-pthreads \
--disable-symver \
--enable-version3 \
--extra-cflags="-I/home/android-ffmpeg/include -fPIC -DANDROID \
-D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated \
-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \
--extra-ldflags="-L/home/android-ffmpeg/lib"
make -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -L$PREFIX/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavresample/libavresample.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}
build_one
I am trying to build a shared library by editing Wireshark's Makefile.am to create a "libtshark" ... to do this, I am trying to build a tshark_lib.c which is the same as tshark.c with main() stripped out of it.
So I have edited Makefile.am to include include the following in an attempt to build the shared libtshark library:
lib_LTLIBRARIES = libtshark.la
libtshark_la_LDFLAGS = -version-info 0:1:0 -export-symbols libtshark.sym #LDFLAGS_SHAREDLIB#
libtshark_la_SOURCES = \
$(WIRESHARK_COMMON_SRC) \
$(SHARK_COMMON_CAPTURE_SRC) \
$(TSHARK_TAP_SRC) \
capture_opts.c \
capture_sync.c \
tempfile.c \
tshark-tap-register.c \
tshark_lib.c
# Libraries and plugin flags with which to link tshark.
libtshark_la_LIBADD = \
wiretap/libwiretap.la \
epan/libwireshark.la \
wsutil/libwsutil.la \
#SSL_LIBS# \
$(plugin_ldadd) \
#PCRE_LIBS# \
#GLIB_LIBS# -lm \
#PCAP_LIBS# \
#SOCKET_LIBS# \
#NSL_LIBS# \
#C_ARES_LIBS# \
#ADNS_LIBS# \
#KRB5_LIBS# \
#CORESERVICES_FRAMEWORKS# \
#LIBGCRYPT_LIBS# \
#LIBGNUTLS_LIBS# \
#LIBSMI_LDFLAGS#
#tshark_CFLAGS = $(AM_CLEAN_CFLAGS) $(py_dissectors_dir)
libtshark_la_DEPENDENCIES = \
${top_builddir}/epan/libwireshark.la \
${top_builddir}/wsutil/libwsutil.la \
${top_builddir}/wiretap/libwiretap.la \
libtshark.sym
However, when I try to build the code now, I get the following error:
make[2]: *** No rule to make target `libtshark.sym', needed by `libtshark.la'. Stop.
For some reason, it is not using my 'libtshark_la_LDFLAGS' which contains '-export-symbols libtshark.sym' ... does anyone know what I might be missing?
Here is the entire Makefile.am, which is too long for stackoverflow: Makefile.am
it turns out that the .sym file is pre-generated by wireshark scripts to determine which symbols to export.
I've been heavily refactoring my makefiles, with help from Beta, Paul R, and Sjoerd (thanks guys!).
Below is my STARTING product:
#Nice, wonderful makefile written by Jason
CC=g++
CFLAGS=-c -Wall
BASE_DIR:=.
SOURCE_DIR:=$(BASE_DIR)/source
BUILD_DIR:=$(BASE_DIR)/build
TEST_DIR:=$(BASE_DIR)/build/tests
MAKEFILE_DIR:=$(BASE_DIR)/makefiles
DATA_DIR:=$(BASE_DIR)/data
DATA_DIR_TESTS:=$(DATA_DIR)/tests
MOLECULE_UT_SOURCES := $(SOURCE_DIR)/molecule_test/main.cc \
$(SOURCE_DIR)/molecule_manager.h \
$(SOURCE_DIR)/molecule_manager.cpp \
$(SOURCE_DIR)/molecule_manager_main.h \
$(SOURCE_DIR)/molecule_manager_main.cpp \
$(SOURCE_DIR)/molecule_reader.h \
$(SOURCE_DIR)/molecule_reader.cpp \
$(SOURCE_DIR)/molecule_reader_psf_pdb.h \
$(SOURCE_DIR)/molecule_reader_psf_pdb.cpp \
$(SOURCE_DIR)/parameter_manager_lj_molecule.h \
$(SOURCE_DIR)/parameter_manager_lj_molecule.cpp \
$(SOURCE_DIR)/parameter_manager.h \
$(SOURCE_DIR)/parameter_manager.cpp \
$(SOURCE_DIR)/parser.h \
$(SOURCE_DIR)/parser.cpp \
$(SOURCE_DIR)/common.h
MOLECULE_UT_DATA := \
$(DATA_DIR_TESTS)/molecule_test/par_oxalate_and_friends.inp \
$(DATA_DIR_TESTS)/molecule_test/dicarboxy-octane_4.pdb \
$(DATA_DIR_TESTS)/molecule_test/dicarboxy-octane_4.psf
PARAM_UT_SOURCES := $(SOURCE_DIR)/parameter_test/main.cc \
$(SOURCE_DIR)/parameter_manager_lj_molecule.h \
$(SOURCE_DIR)/parameter_manager_lj_molecule.cpp \
$(SOURCE_DIR)/parameter_manager.h \
$(SOURCE_DIR)/parameter_manager.cpp \
$(SOURCE_DIR)/parser.h \
$(SOURCE_DIR)/parser.cpp \
$(SOURCE_DIR)/common.h
PARAM_UT_DATA := $(DATA_DIR_TESTS)/molecule_test/par_oxalate_and_friends.inp
molecule_test : molecule_test_prepare_sources molecule_test_prepare_makefiles \
molecule_test_prepare_data_files
#$(shell cd $(TEST_DIR)/molecule_unit_test/; \
make ./bin/molecule_test)
molecule_test_prepare_sources: molecule_test_dir
#echo Copying sources...
#cp --preserve $(MOLECULE_UT_SOURCES) \
$(TEST_DIR)/molecule_unit_test/source
molecule_test_prepare_makefiles: $(MAKEFILE_DIR)/Makefile.molecule_test
#cp --preserve $(MAKEFILE_DIR)/Makefile.molecule_test \
$(TEST_DIR)/molecule_unit_test/Makefile
molecule_test_prepare_data_files:
cp --preserve $(MOLECULE_UT_DATA) $(TEST_DIR)/molecule_unit_test/bin/
molecule_test_dir:
#if test -d $(BUILD_DIR); then \
echo Build exists...; \
else \
echo Build directory does not exist, making build dir...; \
mkdir $(BUILD_DIR); \
fi
#if test -d $(TEST_DIR); then \
echo Tests exists...; \
else \
echo Tests directory does not exist, making tests dir...; \
mkdir $(TEST_DIR); \
fi
#if test -d $(TEST_DIR)/molecule_unit_test; then \
echo Molecule unit test directory exists...; \
else \
echo Molecule unit test directory does \
not exist, making build dir...; \
mkdir $(TEST_DIR)/molecule_unit_test; \
fi
#if test -d $(TEST_DIR)/molecule_unit_test/source; then \
echo Molecule unit test source directory exists...; \
else \
echo Molecule unit test source directory does \
not exist, making build dir...; \
mkdir $(TEST_DIR)/molecule_unit_test/source; \
fi
#if test -d $(TEST_DIR)/molecule_unit_test/obj; then \
echo Molecule unit test object directory exists...; \
else \
echo Molecule unit test object directory does \
not exist, making object dir...; \
mkdir $(TEST_DIR)/molecule_unit_test/obj; \
fi
#if test -d $(TEST_DIR)/molecule_unit_test/bin; then \
echo Molecule unit test executable directory exists...; \
else \
echo Molecule unit test executable directory does \
not exist, making executable dir...; \
mkdir $(TEST_DIR)/molecule_unit_test/bin; \
fi
param_test : param_test_prepare_sources param_test_prepare_makefiles \
param_test_prepare_data_files
#$(shell cd $(TEST_DIR)/param_unit_test/; \
make ./bin/param_test)
param_test_prepare_sources: param_test_dir
#echo Copying sources...
#cp --preserve $(PARAM_UT_SOURCES) $(TEST_DIR)/param_unit_test/source
param_test_prepare_makefiles: $(MAKEFILE_DIR)/Makefile.param_test
#cp --preserve $(MAKEFILE_DIR)/Makefile.param_test \
$(TEST_DIR)/param_unit_test/Makefile
param_test_prepare_data_files:
cp --preserve $(PARAM_UT_DATA) $(TEST_DIR)/param_unit_test/bin/
param_test_dir:
#if test -d $(BUILD_DIR); then \
echo Build exists...; \
else \
echo Build directory does not exist, making build dir...; \
mkdir $(BUILD_DIR); \
fi
#if test -d $(TEST_DIR); then \
echo Tests exists...; \
else \
echo Tests directory does not exist, making tests dir...; \
mkdir $(TEST_DIR); \
fi
#if test -d $(TEST_DIR)/param_unit_test; then \
echo Param unit test directory exists...; \
else \
echo Param unit test directory does \
not exist, making build dir...; \
mkdir $(TEST_DIR)/param_unit_test; \
fi
#if test -d $(TEST_DIR)/param_unit_test/source; then \
echo Param unit test source directory exists...; \
else \
echo Param unit test source directory does \
not exist, making build dir...; \
mkdir $(TEST_DIR)/param_unit_test/source; \
fi
#if test -d $(TEST_DIR)/param_unit_test/obj; then \
echo Param unit test object directory exists...; \
else \
echo Param unit test object directory does \
not exist, making object dir...; \
mkdir $(TEST_DIR)/param_unit_test/obj; \
fi
#if test -d $(TEST_DIR)/param_unit_test/bin; then \
echo Param unit test executable directory exists...; \
else \
echo Param unit test executable directory does \
not exist, making executable dir...; \
mkdir $(TEST_DIR)/param_unit_test/bin; \
fi
...and the sub makefile:
#Nice, wonderful makefile written by Jason
CC=g++
CFLAGS=-c -Wall
SOURCE_DIR:=./source
OBJ_DIR:=./obj
EXE_DIR:=./bin
$(EXE_DIR)/molecule_test : $(OBJ_DIR)/main.o \
$(OBJ_DIR)/parameter_manager_lj_molecule.o \
$(OBJ_DIR)/parameter_manager.o $(OBJ_DIR)/parser.o \
$(OBJ_DIR)/molecule_manager.o $(OBJ_DIR)/molecule_manager_main.o \
$(OBJ_DIR)/molecule_reader.o \
$(OBJ_DIR)/molecule_reader_psf_pdb.o
#$(CC) $(OBJ_DIR)/main.o $(OBJ_DIR)/parameter_manager.o \
$(OBJ_DIR)/parser.o $(OBJ_DIR)/parameter_manager_lj_molecule.o \
$(OBJ_DIR)/molecule_manager.o $(OBJ_DIR)/molecule_manager_main.o \
$(OBJ_DIR)/molecule_reader.o \
$(OBJ_DIR)/molecule_reader_psf_pdb.o \
-o molecule_test
#mv molecule_test $(EXE_DIR)/
$(OBJ_DIR)/main.o: $(SOURCE_DIR)/parameter_manager.h \
$(SOURCE_DIR)/parameter_manager_lj_molecule.h \
$(SOURCE_DIR)/molecule_manager.h \
$(SOURCE_DIR)/molecule_manager_main.h \
$(SOURCE_DIR)/molecule_reader.h \
$(SOURCE_DIR)/molecule_reader_psf_pdb.h \
$(SOURCE_DIR)/common.h $(SOURCE_DIR)/main.cc
$(CC) $(CFLAGS) $(SOURCE_DIR)/main.cc
#mv main.o $(OBJ_DIR)/
$(OBJ_DIR)/molecule_reader.o: $(SOURCE_DIR)/parameter_manager.h \
$(SOURCE_DIR)/parameter_manager_lj_molecule.h \
$(SOURCE_DIR)/molecule_manager.h \
$(SOURCE_DIR)/molecule_manager_main.h \
$(SOURCE_DIR)/molecule_reader.h \
$(SOURCE_DIR)/common.h
$(CC) $(CFLAGS) $(SOURCE_DIR)/molecule_reader.cpp
#mv molecule_reader.o $(OBJ_DIR)/
$(OBJ_DIR)/molecule_reader_psf_pdb.o: $(SOURCE_DIR)/parameter_manager.h \
$(SOURCE_DIR)/parameter_manager_lj_molecule.h \
$(SOURCE_DIR)/molecule_manager.h \
$(SOURCE_DIR)/molecule_manager_main.h \
$(SOURCE_DIR)/molecule_reader.h \
$(SOURCE_DIR)/molecule_reader_psf_pdb.h \
$(SOURCE_DIR)/common.h
$(CC) $(CFLAGS) $(SOURCE_DIR)/molecule_reader_psf_pdb.cpp
#mv molecule_reader_psf_pdb.o $(OBJ_DIR)/
$(OBJ_DIR)/molecule_manager.o: $(SOURCE_DIR)/molecule_manager.h \
$(SOURCE_DIR)/common.h
$(CC) $(CFLAGS) $(SOURCE_DIR)/molecule_manager.cpp
#mv molecule_manager.o $(OBJ_DIR)/
$(OBJ_DIR)/molecule_manager_main.o: $(SOURCE_DIR)/molecule_manager.h \
$(SOURCE_DIR)/molecule_manager_main.h \
$(SOURCE_DIR)/common.h
$(CC) $(CFLAGS) $(SOURCE_DIR)/molecule_manager_main.cpp
#mv molecule_manager_main.o $(OBJ_DIR)/
$(OBJ_DIR)/parameter_manager_lj_molecule.o: $(SOURCE_DIR)/common.h \
$(SOURCE_DIR)/parameter_manager.h \
$(SOURCE_DIR)/parser.h
$(CC) $(CFLAGS) $(SOURCE_DIR)/parameter_manager_lj_molecule.cpp
#mv parameter_manager_lj_molecule.o $(OBJ_DIR)/
$(OBJ_DIR)/parameter_manager.o: $(SOURCE_DIR)/common.h
$(CC) $(CFLAGS) $(SOURCE_DIR)/parameter_manager.cpp
#mv parameter_manager.o $(OBJ_DIR)/
$(OBJ_DIR)/parser.o: $(SOURCE_DIR)/parser.h
#$(CC) $(CFLAGS) $(SOURCE_DIR)/parser.cpp
#mv parser.o $(OBJ_DIR)/
$(OBJ_DIR)/common.o: $(SOURCE_DIR)/common.h
$(CC) $(CFLAGS) $(SOURCE_DIR)/common.h
mv common.h.gch $(OBJ_DIR)/
With some help from the above users and figuring out a few nifty tricks on my own as well (like use of wildcards), I've refactored the makefiles heavily, plus added comments for posterity.
Here's the top level result:
####################################################
## -------------------------------
## - Monte Carlo Source Makefile -
## -------------------------------
##
## Author: Jason R. Mick
## Date: July 7, 2010
## Company: Wayne State University
##
## CHANGE LOG
## Author Date Description
##
##
##
####################################################
#################################
# These lines set up some basic vars
# such as compiler, flags, and dirs.
#################################
CC=g++
CFLAGS=-c -Wall
BASE_DIR:=.
SOURCE_DIR:=$(BASE_DIR)/source
BUILD_DIR:=$(BASE_DIR)/build
TEST_DIR:=$(BASE_DIR)/build/tests
MAKEFILE_DIR:=$(BASE_DIR)/makefiles
DATA_DIR:=$(BASE_DIR)/data
DATA_DIR_TESTS:=$(DATA_DIR)/tests
#################################
# Note use of wildcards to catch *.h and *.cpp files and all the sub_classes
# ... for future unit tests/classes, follow this approach, please
#################################
MOLECULE_UT_SOURCES := $(SOURCE_DIR)/molecule_test/main.cc \
$(SOURCE_DIR)/molecule_manager* \
$(SOURCE_DIR)/molecule_reader* \
$(SOURCE_DIR)/parameter_manager* \
$(SOURCE_DIR)/parser* \
$(SOURCE_DIR)/common.h
MOLECULE_UT_DATA := \
$(DATA_DIR_TESTS)/molecule_test/par_oxalate_and_friends.inp \
$(DATA_DIR_TESTS)/molecule_test/dicarboxy-octane_4.*
PARAM_UT_SOURCES := $(SOURCE_DIR)/parameter_test/main.cc \
$(SOURCE_DIR)/parameter_manager* \
$(SOURCE_DIR)/parser* \
$(SOURCE_DIR)/common.h
PARAM_UT_DATA := $(DATA_DIR_TESTS)/molecule_test/par_oxalate_and_friends.inp
#################################
# Use sub-make inside subdirectory on test target
# NOTE: # silences output of this call...
#################################
molecule_test : molecule_test_prepare_sources molecule_test_prepare_makefiles \
molecule_test_prepare_data_files
#$(MAKE) -C $(TEST_DIR)/molecule_unit_test/ ./bin/molecule_test
#################################
# NOTE: this target uses --preserve to keep base source modification date
# to prevent unnecessary rebuilds
#################################
molecule_test_prepare_sources: molecule_test_dir
#echo Copying sources...
#cp --preserve $(MOLECULE_UT_SOURCES) \
$(TEST_DIR)/molecule_unit_test/source
molecule_test_prepare_makefiles: $(MAKEFILE_DIR)/Makefile.molecule_test
#cp --preserve $(MAKEFILE_DIR)/Makefile.molecule_test \
$(TEST_DIR)/molecule_unit_test/Makefile
molecule_test_prepare_data_files:
#cp --preserve $(MOLECULE_UT_DATA) $(TEST_DIR)/molecule_unit_test/bin/
#################################
# NOTE: This mkdir command uses -p flag to create any missing parent dirs.
# If all dirs already exist, it also returns no error...
#################################
molecule_test_dir:
mkdir -p $(TEST_DIR)/molecule_unit_test/source
mkdir -p $(TEST_DIR)/molecule_unit_test/obj
mkdir -p $(TEST_DIR)/molecule_unit_test/bin
param_test : param_test_prepare_sources param_test_prepare_makefiles \
param_test_prepare_data_files
#$(MAKE) -C $(TEST_DIR)/param_unit_test/ ./bin/param_test
param_test_prepare_sources: param_test_dir
#echo Copying sources...
#cp --preserve $(PARAM_UT_SOURCES) $(TEST_DIR)/param_unit_test/source
param_test_prepare_makefiles: $(MAKEFILE_DIR)/Makefile.param_test
#cp --preserve $(MAKEFILE_DIR)/Makefile.param_test \
$(TEST_DIR)/param_unit_test/Makefile
param_test_prepare_data_files:
#cp --preserve $(PARAM_UT_DATA) $(TEST_DIR)/param_unit_test/bin/
param_test_dir:
mkdir -p $(TEST_DIR)/param_unit_test/source
mkdir -p $(TEST_DIR)/param_unit_test/obj
mkdir -p $(TEST_DIR)/param_unit_test/bin
Here's the sub-makefile result:
####################################################
## -------------------------------
## - Monte Carlo Source Submake -
## -------------------------------
##
## Author: Jason R. Mick
## Date: July 7, 2010
## Company: Wayne State University
##
## CHANGE LOG
## Author Date Description
##
##
##
####################################################
################################
# These lines set up some basic vars
# such as compiler, flags, and dirs.
################################
CC=g++
CFLAGS=-c -Wall
SOURCE_DIR:=./source
INCDIRS := -I$(SOURCE_DIR)
OBJ_DIR:=./obj
EXE_DIR:=./bin
################################
#This line tells make what directories to search in for rules...
################################
VPATH = $(SOURCE_DIR)
################################
# INFO on the "magic" here:
#$^ is all the prerequisite (.o files), $# is target, and % is wildcard
################################
$(EXE_DIR)/molecule_test : $(OBJ_DIR)/main.o \
$(OBJ_DIR)/parameter_manager_lj_molecule.o \
$(OBJ_DIR)/parameter_manager.o $(OBJ_DIR)/parser.o \
$(OBJ_DIR)/molecule_manager.o $(OBJ_DIR)/molecule_manager_main.o \
$(OBJ_DIR)/molecule_reader.o \
$(OBJ_DIR)/molecule_reader_psf_pdb.o
$(CC) $^ -o $#
################################
# These are extra includes for the general
# rule at the end....
################################
$(OBJ_DIR)/main.o $(OBJ_DIR)/molecule_reader.o \
$(OBJ_DIR)/molecule_reader_psf_pdb.o: \
molecule_manager.h \
molecule_manager_main.h \
parameter_manager.h \
parameter_manager_lj_molecule.h
$(OBJ_DIR)/molecule_manager_main.o: molecule_manager.h
$(OBJ_DIR)/parameter_manager_lj_molecule.o: parser.h
$(OBJ_DIR)/molecule_reader_psf_pdb.o: molecule_reader.h
################################
# Special rule for main object
################################
$(OBJ_DIR)/main.o: $(SOURCE_DIR)/main.cc \
molecule_reader.h \
molecule_reader_psf_pdb.h common.h
$(CC) $(CFLAGS) $(INCDIRS) $< -o $#
################################
# The GENERAL RULE for objects...
# INFO on the "magic" here:
#$< is the first prerequisite (.cpp file), $# is target, and % is wildcard
################################
$(OBJ_DIR)/%.o: $(SOURCE_DIR)/%.cpp $(SOURCE_DIR)/%.h $(SOURCE_DIR)/common.h
$(CC) $(CFLAGS) $(INCDIRS) $< -o $#
... basically I'm pretty satisfied, everything is working, clean, and well documented, but I wanted to see if anyone else has suggestions of things I should change for "best practice" etc. I'm trying to learn as much as I can!! Thanks in advance!!
Cheers,
Jason
I would rethink calling make recursively, and instead #include the submakefiles in the main makefile. It is much easier to get the dependancies to work right, and it allows you to utilize multiple cores for building (using -j). Take a look at Recursive Make Considered Harmful for all the gory details.
Also, take a look at these questions:
What is your experience with non recursive make?
Recursive make friend or foe
(I won't enter into the recursive/non-recursive debate again. 'Nuff said.)
Why copy all of these files around? I understand that you don't want to hardcode a map of your directory structure in the submake, but you can save a lot of time and trouble by giving the submake access to the original files, either by symbolic link:
molecule_test_prepare_sources: molecule_test_dir
#echo linking to sources...
#ln -s $(SOURCE_DIR) $(TEST_DIR)/molecule_unit_test/source
molecule_test_prepare_makefiles: $(MAKEFILE_DIR)/Makefile.molecule_test
#ln -s $< $(TEST_DIR)/molecule_unit_test/Makefile
Or by passing a parameter to the submake:
param_test : param_test_prepare_sources param_test_prepare_makefiles \
param_test_prepare_data_files
#$(MAKE) -C $(TEST_DIR)/param_unit_test/ SOURCE_DIR=$(SOURCE_DIR) \
./bin/param_test # and then use SOURCE_DIR in the submake
The same goes for param_test. I think this actually lets you do away with MOLECULE_UT_SOURCES and PARAM_UT_SOURCES, and good riddance.
(I left out the data directories, because I don't know what this code actually does-- maybe it needs a restriced diet, or modifies its input files or something.)
Finally as a matter of style, almost anywhere you see redundancy you can remove it and make the makefile easier to read. For instance,
$(EXE_DIR)/molecule_test : $(OBJ_DIR)/main.o \
$(OBJ_DIR)/parameter_manager_lj_molecule.o \
$(OBJ_DIR)/parameter_manager.o $(OBJ_DIR)/parser.o \
$(OBJ_DIR)/molecule_manager.o $(OBJ_DIR)/molecule_manager_main.o \
$(OBJ_DIR)/molecule_reader.o \
$(OBJ_DIR)/molecule_reader_psf_pdb.o
$(CC) $^ -o $#
can become
OBJECTS := main \
parameter_manager_lj_molecule \
parameter_manager parser \
molecule_manager molecule_manager_main \
molecule_reader \
molecule_reader_psf_pdb
OBJECTS := $(patsubst %,$(OBJ_DIR)/%.o, $(OBJECTS)
$(EXE_DIR)/molecule_test : $(OBJECTS)
$(CC) $^ -o $#
This isn't the answer you're looking for but have you considered using the "autotools" suite (automake, autoconf, etc.)?
Once you get the hang of it it's quite wonderful to work with. And it has a lot more functionality than pure Make. Functionality such as checking for libraries needed to build, cross-compiling, etc.