cmake seems to not pick up my -DCMAKE_CXX_FLAGS - command-line

I have a totally simple setup. Two files in two separate directories.
mkdir a
touch a/a.h
mkdir b
echo '#include <a/a.h>' > b/b.c
Compiling works, when I specify a header path
cd b
gcc -c -I.. b.c
cd ..
OK now let's add cmake to the picture. For my purposes I need to specify the header search path via the command-line. Consider the CMakeLists.txt read only.
cat<<EOF > b/CMakeLists.txt
cmake_minimum_required (VERSION 3.0)
project (b)
add_library(b
b.c
)
EOF
mkdir b/build
cd b/build
cmake -DCMAKE_CXX_FLAGS=-I.. ..
make VERBOSE=1
But make fails and I don't see the -I.. specification in the cc command line.
[ 50%] Building C object CMakeFiles/b.dir/b.c.o
/Applications/Xcode.app/Contents/Developer/Toolchains /XcodeDefault.xctoolchain/usr/bin/cc -o CMakeFiles/b.dir/b.c.o -c /tmp/b/b.c
/tmp/b/b.c:1:10: fatal error: 'a/a.h' file not found
I tried giving an absolute path too, but it just doesn't work for me.

Your file has .c extension, you should use CMAKE_C_FLAGS for it.
And in most cases you should specify needed include search paths in CMakeLists.txt itself:
include_directories(..)

Related

make savedefconfig doesn't save BR2_EXTERNAL_XYZZY_PATH's path

As you know, Buildroot allow save current configuration without default value. It is good idea for me because full configuration is too large to be read by human.
But
make savedefconfig
doesn't save
BR2_EXTERNAL_XYZZY_PATH's path. Is it a bug?
--How to reproduce?--
mkdir BuildRootTest && cd BuildRootTest
aria2c https://bugs.busybox.net/attachment.cgi?id=9461 --out '.7z'
7z x .7z
rm .7z
git clone https://github.com/buildroot/buildroot
make BR2_EXTERNAL=${PWD}/my_external_tree -C
buildroot pc_x86_bios_defconfig
make -C buildroot savedefconfig BR2_DEFCONFIG=${PWD}/'mydefconfig01'
Compare mydefconfig01 and buildroot/.config files. mydefconfig01 contains "BR2_EXTERNAL_USERCONFIGTREE_PATH" ones but buildroot/.config twice. make savedefconfig just remove BR2_EXTERNAL_USERCONFIGTREE_PATH="/home/username/delme/my_external_tree" from mydefconfig01.

Failed to load dynamic library 'libtensorflowlite_c.so': dlopen failed: library "libtensorflowlite_c.so" not found

When I tried to call
/// runs and transforms the data 🤖
this._interpreter.run(input, output);
this._interpreter = await Interpreter.fromAsset('mobilefacenet.tflite',
options: interpreterOptions);
Got this error
Failed to load dynamic library 'libtensorflowlite_c.so': dlopen failed: library "libtensorflowlite_c.so" not found
For Windows users:
Copy all these lines on notepad:
#echo off
setlocal enableextensions
cd %~dp0
set TF_VERSION=2.5
set URL=https://github.com/am15h/tflite_flutter_plugin/releases/download/
set TAG=tf_%TF_VERSION%
set ANDROID_DIR=android\app\src\main\jniLibs\
set ANDROID_LIB=libtensorflowlite_c.so
set ARM_DELEGATE=libtensorflowlite_c_arm_delegate.so
set ARM_64_DELEGATE=libtensorflowlite_c_arm64_delegate.so
set ARM=libtensorflowlite_c_arm.so
set ARM_64=libtensorflowlite_c_arm64.so
set X86=libtensorflowlite_c_x86_delegate.so
set X86_64=libtensorflowlite_c_x86_64_delegate.so
SET /A d = 0
:GETOPT
if /I "%1"=="-d" SET /A d = 1
SETLOCAL
if %d%==1 CALL :Download %ARM_DELEGATE% armeabi-v7a
if %d%==1 CALL :Download %ARM_64_DELEGATE% arm64-v8a
if %d%==0 CALL :Download %ARM% armeabi-v7a
if %d%==0 CALL :Download %ARM_64% arm64-v8a
CALL :Download %X86% x86
CALL :Download %X86_64% x86_64
EXIT /B %ERRORLEVEL%
:Download
curl -L -o %~1 %URL%%TAG%/%~1
mkdir %ANDROID_DIR%%~2\
move /-Y %~1 %ANDROID_DIR%%~2\%ANDROID_LIB%
EXIT /B 0
Save the file as install.bat and put the file in root directory of your project.
Open in explorer and open a command window there.
Type install.bat and press Enter. Use install.bat -d (Windows) instead if you wish to use GpuDelegateV2 and NnApiDelegate.
For Linux/Mac users:
Copy all these lines on notepad
#!/usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
# Available versions
# 2.5, 2.4.1
TF_VERSION=2.5
URL="https://github.com/am15h/tflite_flutter_plugin/releases/download/"
TAG="tf_$TF_VERSION"
ANDROID_DIR="android/app/src/main/jniLibs/"
ANDROID_LIB="libtensorflowlite_c.so"
ARM_DELEGATE="libtensorflowlite_c_arm_delegate.so"
ARM_64_DELEGATE="libtensorflowlite_c_arm64_delegate.so"
ARM="libtensorflowlite_c_arm.so"
ARM_64="libtensorflowlite_c_arm64.so"
X86="libtensorflowlite_c_x86_delegate.so"
X86_64="libtensorflowlite_c_x86_64_delegate.so"
delegate=0
while getopts "d" OPTION
do
case $OPTION in
d) delegate=1;;
esac
done
download () {
wget "${URL}${TAG}/$1" -O "$1"
mkdir -p "${ANDROID_DIR}$2/"
mv $1 "${ANDROID_DIR}$2/${ANDROID_LIB}"
}
if [ ${delegate} -eq 1 ]
then
download ${ARM_DELEGATE} "armeabi-v7a"
download ${ARM_64_DELEGATE} "arm64-v8a"
else
download ${ARM} "armeabi-v7a"
download ${ARM_64} "arm64-v8a"
fi
download ${X86} "x86"
download ${X86_64} "x86_64"
Save the file as install.sh name and put the file in root directory of your project.
Open a command window there.
Type sh install.sh and press Enter. Use sh install.sh -d instead if you wish to use GpuDelegateV2 and NnApiDelegate.
You need to add a file in the root directory in the app found in
tflite_flutter package. tflite_flutter. You can also find it here.
just download the file and place it into the root directory in your app and double click to install the needed information. (For Windows)
I had the same error. Hopefully this is helpful to someone.
After using the install.sh file, that error showed (only on Android, iOS worked fine). But I had changed the wget to curl in the install file and it had downloaded a redirect html page.
The replacement that worked for me was:
# wget "${URL}${TAG}/$1" -O "$1" # Replaced with the below line
curl -L "${URL}${TAG}/$1" -o "$1"
Try to confirm that the files you have downloaded are the correct files. You can inspect these files in <projectdirectory>/android/app/src/main/jniLibs. They should be binary files that begin with ^?ELF, not html files like what I had.

Autocomplete directories in a subfolder with the Fish shell

I'm having trouble getting the 'complete' function in the fish shell to behave as I would like and I've been searching for an answer for days now.
Summary
Essentially I need to provide tab directory auto-completion as if I was in a different directory to the one I am currently in. It should behave exactly as 'cd' and 'ls' do, but with the starting point in another directory. It seems like such a trivial thing to be able to do but I can't find a way to make it work.
Explanation
Example folder structure below
- root
- foo
- a
- dir1
- subdir1
- dir2
- subdir2
- b
- dir3
- subdir3
- dir4
- subdir4
I am running these scripts whilst in the 'root' directory, but I need tab auto-complete to behave as if I was in the 'foo' directory.
testfunc -d a/dir2/subdir2
Instead of
testfunc -d foo/a/dir2/subdir2
There are a lot of directories inside 'foo' and a lot of sub-directories within them, and this auto-complete behaviour is necessary to speed our process (this script is used extensively throughout the day).
Attempted Solution
I've tried using the 'complete' builtin to get this working by specifying the directory to use, but all this managed to do was auto-complete the first level of directories with a space after the argument instead of continuing to auto-complete like 'cd' would.
complete -x -c testfunc -a "(__fish_complete_directories ./foo/)"
Working bash version
I have already got this working in Bash and I am trying to port it over to fish. See below for the Bash version.
_testfunc()
{
local cur prev words cword
_init_completion || return
compopt +o default
case $prev in
testfunc)
COMPREPLY=( $( compgen -W '-d' -- "$cur" ) )
compopt +o nospace
return
;;
-d)
curdir=$(pwd)
cd foo/ 2>/dev/null && _filedir -d
COMPREPLY=( $( compgen -d -S / -- "$cur" ) )
cd $curdir
return
;;
esac
} &&
complete -o nospace -F _testfunc testfunc
This is essentially stepping into the folder that I want, doing the autocompletion, then stepping back into the original folder that the script was run in. I was hoping this would be easier in Fish after getting it working in Bash (I need to support these two shells), but I'm just pulling my hair out.
Any help would be really appreciated!
I am not a bash completions expert, but it looks like the bash completions are implemented by changing directories, running completions, and then changing back. You can do the same in fish:
function complete_testfunc
set prevdir $PWD
cd foo
__fish_complete_directories
cd $prevdir
end
complete -x -c testfunc -a "(complete_testfunc)"
does that work for you?

Error Packaging a Shell script with Autotools

I'm trying to write a simple Autotool package that just packages a single script. This might seem like overkill, but the script is to be added into the build-system for an embedded system and the build-system is designed to play nicely with Autotools.
I have a shell-script called wifi_query.sh. To package this I've followed the following steps:
Created Makefile.am which contains the following -
bin_SCRIPTS = wifi_query.sh
CLEANFILES = $(bin_SCRIPTS)
I also created wifi_query.sh.in which contains the line exec wifi_query.sh. I'm not sure I understand the purpose of the .in file.
I then run autoscan.
Then I run:
sed -e 's/FULL-PACKAGE-NAME/wifi_query/' \
-e 's/VERSION/1/' \
-e 's|BUG-REPORT-ADDRESS|/dev/null|' \
-e '10i\
AM_INIT_AUTOMAKE' \
< configure.scan > configure.ac
Run touch NEWS README AUTHORS ChangeLog.
Run autoreconf -iv
./configure
make distcheck
When I run make distcheck I get an error saying: "* No rule to make target 'wifi_query.sh', needed by 'all-am'. Stop.".
I don't understand this error, if anyone could give me any pointers that would be good. My suspicion is that the error may be due to wifi_query.sh.in, but I have very limited autotools experience.
It seems I needed to replace the line bin_SCRIPTS = wifi_query.sh with dist_bin_SCRIPTS = wifi_query.sh in Makefile.am. Having done that everything seems to work.

Removing files with Build Phase?

Is it possible to remove a file using a build phase in xcode 4 based on if it is release or dev?
If so has anyone got an example?
I have tried :
if [ "${CONFIGURATION}" = "Debug" ]; then
find "$TARGET_BUILD_DIR" -name '*-live.*' -print0 | xargs -0 rm
fi
This prints CopyStringsFile
"build/Debug-iphonesimulator/Blue Sky.app/PortalText-live.strings" CDL/PortalText-live.strings
cd "/Users/internet/Desktop/iPhone Template/iPhonePortalTemplate/CDL.Labs"
setenv PATH "/Developer/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-copyStrings --validate --inputencoding utf-8 --outputencoding binary --outdir "/Users/internet/Desktop/iPhone Template/iPhonePortalTemplate/CDL.Labs/build/Debug-iphonesimulator/Blue Sky.app" -- CDL/PortalText-live.strings
But does actually remove the file from the bundle.
The only way I've ever had different files, is having a separate Target, and only include certain files in certain targets.
EDIT WITH AN EXAMPLE
Ok, I've done exactly the same in another project. We had a DefaultProperties.plist file, which was included in the target.
We then had 3 copies of this, NOT included in the target, ProdProperties.plist, TestProperties.plist, UatProperties.plist.
We built for environments on the command line, using xcodebuild, as it was built using an automated build server (Bamboo).
Prior to executing xcodebuild, we would run this:
cp -vf "./Properties/Environments/${environment}Properties.plist" ./Properties/shared/DefaultProperties.plist
touch Properties/shared/DefaultProperties.plist
with $(environment) being passed into the script.
You could do something like this with the RunScript phase in Xcode.