no such file or directory cocos2dx - cocos2d-x

I just import a sample cocos2dx project when build it appear no such file or directory c/c++ problem. Any idea?
my android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/CCParallaxNodeExtras.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)

Related

How make a TSV processing golang program that is as efficient as `cut`?

I have the following Go program to process a TSV input. But it is slower than awk and cut. I know cut uses string manipulate tricks to achieve a fast performance.
https://github.com/coreutils/coreutils/blob/master/src/cut.c
Is it possible to achieve the same performance as cut with Go (or at least better than awk)? What should things be used in Go to achieve a better performance?
$ ./main_.sh | indent.sh
time ./main.go 10 < "$infile" > /dev/null
real 0m1.431s
user 0m0.978s
sys 0m0.436s
time cut -f 10 < "$infile" > /dev/null
real 0m0.252s
user 0m0.225s
sys 0m0.025s
time awk -v FS='\t' -v OFS='\t' -e '{ print $10 }' < "$infile" > /dev/null
real 0m1.134s
user 0m1.108s
sys 0m0.024s
$ cat.sh main_.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
infile=$(mktemp)
seq 10000000 | paste -s -d $'\t\t\t\t\t\t\t\t\t\n' > "$infile"
set -v
time ./main.go 10 < "$infile" > /dev/null
time cut -f 10 < "$infile" > /dev/null
time awk -v FS='\t' -v OFS='\t' -e '{ print $10 }' < "$infile" > /dev/null
$ cat main.go
#!/usr/bin/env gorun
// vim: set noexpandtab tabstop=2:
package main
import (
"bufio"
"fmt"
"os"
"strings"
"strconv"
)
func main() {
idx, _ := strconv.Atoi(os.Args[1])
col := idx - 1
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := strings.TrimRight(scanner.Text(), "\n")
fields := strings.Split(line, "\t")
fmt.Printf("%s\n", fields[col])
}
}
If you profile the application, it will show most of the time is spent in
fmt.Printf("%s\n", fields[col])
The main issue there is really the 10000000 syscalls you're making to write to stdout, so making stdout buffered will significantly reduce the execution time. Removing the overhead of the fmt calls will help even further.
The next step would be to reduce allocations, which you can do by using byte slices rather than strings. Combining these would lead to something like
stdout := bufio.NewWriter(os.Stdout)
defer stdout.Flush()
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := scanner.Bytes()
fields := bytes.Split(line, []byte{'\t'})
stdout.Write(fields[col])
stdout.Write([]byte{'\n'})
}

Sending curl like request in golang

I try send request like this in golang but with no result:
curl -s -i -H "Accept: application/json" "http://192.168.1.183:8080/json.htm?type=command&c=getauth&param=udevice&idx=9&nvalue=0&svalue=10;43;2"
How to do that?
I want to send data do Domoticz Home Automation System.
Anser I got:
{
"status" : "ERR"
}
but should be:
{
"status" : "OK",
"title" : "Update Device"
}
I try this code:
b := bytes.NewBufferString("type=command&c=getauth&param=udevice&idx=9&nvalue=0&svalue=10;43;2")
res, _ := http.Post("http://192.168.1.183:8080/json.htm", "Accept: application/json", b)
Note that in your initial curl command, you missed the -X POST parameter.
The generated code would then be:
// Generated by curl-to-Go: https://mholt.github.io/curl-to-go
req, err := http.NewRequest("POST", "http://192.168.1.183:8080/json.htm?type=command&c=getauth&param=udevice&idx=9&nvalue=0&svalue=10;43;2", nil)
if err != nil {
// handle err
}
req.Header.Set("Accept", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
// handle err
}
defer resp.Body.Close()
Your curl command and Go code are almost completely unalike.
Your Go sends a POST request, and curl a GET request.
Your curl command sets an Accept header, your Go code doesn't.
Your Go command sends a body, your curl command doesn't.
Your curl command sends URL parameters, your Go code doesn't.
Your go code does the curl equivalent of:
curl -s -i -X POST -H "Accept: application/json" "http://192.168.1.183:8080/json.htm" -d "type=command&c=getauth&param=udevice&idx=9&nvalue=0&svalue=10;43;2"
The simplest way to emulate your curl command in Go is:
req, err := http.NewRequest("GET", "http://192.168.1.183:8080/json.htm?type=command&c=getauth&param=udevice&idx=9&nvalue=0&svalue=10;43;2", nil)
if err != nil {
panic(err)
}
req.Header.Add("Accept", "application/json")
resp, err := http.DefaultClient.Do(req)
This works for me:
b := bytes.NewBufferString(" ")
res, _ := http.Post("http://192.168.1.183:8080/json.htm?type=command&c=getauth&param=udevice&idx=9&nvalue=0&svalue=10;43;2", "Accept: application/json", b)
but I think it is not best way to do that.

How to insert variable in fswatch regex?

I'm trying to use a variable to identify mxf or mov file extensions. The following works where I explicitly name the file extensions with a regular expression.
${FSWATCH_PATH} -0 \
-e ".*" --include ".*\.[ mxf|mov ]" \
--event Updated --event Renamed --event MovedTo -l $LATENCY \
$LOCAL_WATCHFOLDER_PATH \
| while read -d "" event
do
<code here>
done
How can I use a variable for the file extensions, where the variable name is FileTriggerExtensions? The code below doesn't work:
FileTriggerExtensions=mov|mxf
${FSWATCH_PATH} -0 \
-e ".*" --include ".*\.[ $FileTriggerExtensions ]" \
--event Updated --event Renamed --event MovedTo -l $LATENCY \
$LOCAL_WATCHFOLDER_PATH \
| while read -d "" event
do
done
I guess you use Bash or a similar shell?
FileTriggerExtensions=mov|mxf
-bash: mxf: command not found
Use quotes or escape the pipe symbol.

exec.Command Escaping Variables with JSON Payload

Thank you in advance as I have spent 2 days on this. Here is a working curl command.
curl -ku login:pass -X POST -H 'Content-Type: application/json'-d'{"type":"page","title":"Testpage","space":{"key":"ITDept"},"body":{"storage":{"value":"<p>Blank Page.</p>","representation":"storage"}}}' https://confluence/rest/api/content
I need to get this to execute with exec.Command.
Given that now in Go I have tried escaping and all sorts of other means to get this to work. The issue is more than likely this ridiculous JSON string that is required. I have the JSON string saved into a var now to try it that way.
jsonPayload := '{"type":"page","title":"Testpage","space":{"key":"ITDept"},"body":{"storage":{"value":"<p>Blank Page.</p>","representation":"storage"}}}'
execCmd := "bash", "-c", "curl -ku login:pass -X POST -H 'Content-Type: application/json' -d" jsonPayload "https://confluence/rest/api/content"
So the jsonPayload is the argument to -d. I have tried this using the Marshal json/encoding and the net/http package and it goes through but something about how that stdlib is sending it causes the API to state it is the wrong format.
I also have tried this with this and the curl copied out of the println works but when actually ran in golang it fails with incorrect format.
env := os.Environ()
curlCmd, err := exec.LookPath("curl")
if err != nil {
fmt.Println("Path not found to binary!")
panic(err)
}
args := []string{"curl", "-ku", "login:pass", "-X", "POST", "-H", "'Content-Type: application/json'", "-d", payloadJson, "https://confluence/rest/api/content"}
execErr := syscall.Exec(curlcmd, args, env)
if execErr != nil {
panic(execErr)
}
fmt.Println(curlCmd)
When the curlCmd from that last line there prints it can be copied and pasted into the terminal and it works however when going through golang it comes with a format not supported. Any help would be greatly appreciated.
Try this:
payload := `{"type":"page","title":"Testpage","space":{"key":"ITDept"},"body":{"storage":{"value":"<p>Blank Page.</p>","representation":"storage"}}}`
cmd := exec.Command("curl", "-ku", "login:pass", "-X", "POST", "-H", "Content-Type: application/json", "-d", payload, "http://localhost:8080/confluence/rest/api/content")
p, err := cmd.CombinedOutput()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", p)
Important change from code in the question:
Run command directly instead of using bash.
Specify host name in URL.
Properly quote the string.
BTW, you can also an interpreted string literal:
payload := "{\"type\":\"page\",\"title\":\"Testpage\",\"space\":{\"key\":\"ITDept\"},\"body\":{\"storage\":{\"value\":\"<p>Blank Page.</p>\",\"representation\":\"storage\"}}}"

error: ‘blockIdx’ was not declared in this scope

I try to write a GPU program using CUDA. Below is my function:
__global__ static void
histogram_gpu(int * hist_out, unsigned char * img_in, int img_size, int nbr_bin){
int i;
const int bid = blockIdx.x;
const int tid = threadIdx.x;
// for ( i = 0; i < img_size; i ++){
// hist_out[img_in[i]] ++;
// }
for (i = bid*THREAD_NUM + tid; i < img_size; i += BLOCK_NUM*THREAD_NUM) {
hist_out[img_in[i]]++;
}
}
When I call this function in the main function, there's an error occurs:
error: ‘blockIdx’ was not declared in this scope
I use the CUDA 5.0 on my MAC machine, and below is the Makefile:
OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:])
OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:])
# Flags to detect 32-bit or 64-bit OS platform
OS_SIZE = $(shell uname -m | sed -e "s/i.86/32/" -e "s/x86_64/64/")
OS_ARCH = $(shell uname -m | sed -e "s/i386/i686/")
# These flags will override any settings
ifeq ($(i386),1)
OS_SIZE = 32
OS_ARCH = i686
endif
ifeq ($(x86_64),1)
OS_SIZE = 64
OS_ARCH = x86_64
endif
# Flags to detect either a Linux system (linux) or Mac OSX (darwin)
DARWIN = $(strip $(findstring DARWIN, $(OSUPPER)))
# Location of the CUDA Toolkit binaries and libraries
CUDA_PATH ?= /Developer/NVIDIA/CUDA-5.0
CUDA_INC_PATH ?= $(CUDA_PATH)/include
CUDA_BIN_PATH ?= $(CUDA_PATH)/bin
ifneq ($(DARWIN),)
CUDA_LIB_PATH ?= $(CUDA_PATH)/lib
else
ifeq ($(OS_SIZE),32)
CUDA_LIB_PATH ?= $(CUDA_PATH)/lib
else
CUDA_LIB_PATH ?= $(CUDA_PATH)/lib64
endif
endif
# Common binaries
NVCC ?= $(CUDA_BIN_PATH)/nvcc
GCC ?= g++
# Extra user flags
EXTRA_NVCCFLAGS ?=
EXTRA_LDFLAGS ?=
# CUDA code generation flags
GENCODE_SM10 := -gencode arch=compute_10,code=sm_10
GENCODE_SM20 := -gencode arch=compute_20,code=sm_20
GENCODE_SM30 := -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35
GENCODE_FLAGS := $(GENCODE_SM10) $(GENCODE_SM20) $(GENCODE_SM30)
GENCODE_FLAGS := $(GENCODE_SM10) $(GENCODE_SM20) $(GENCODE_SM30)
# OS-specific build flags
# ifneq ($(DARWIN),)
# LDFLAGS := -Xlinker -rpath $(CUDA_LIB_PATH) -L$(CUDA_LIB_PATH) -lcudart -lcublas -lcuda -lcufft -ltlshook
# CCFLAGS := -arch $(OS_ARCH)
# else
# ifeq ($(OS_SIZE),32)
# LDFLAGS := -L$(CUDA_LIB_PATH) -lcudart
# CCFLAGS := -m32
# else
LDFLAGS := -L$(CUDA_LIB_PATH) -lcudart -lcublas -lcuda -lcufft -ltlshook
CCFLAGS := -m64
# endif
# endif
# OS-architecture specific flags
ifeq ($(OS_SIZE),32)
NVCCFLAGS := -m32
else
NVCCFLAGS := -m64
endif
# Debug build flags
ifeq ($(dbg),1)
CCFLAGS += -g
NVCCFLAGS += -g -G
TARGET := debug
else
TARGET := release
endif
# Common includes and paths for CUDA
INCLUDES := -I$(CUDA_INC_PATH) -I. -I.. -I../../common/inc
# Add source files here
EXECUTABLE := 5kk70-assignment-gpu
# Cuda source files (compiled with cudacc)
CUFILES :=
# C/C++ source files (compiled with gcc / c++)
CCFILES := main.cpp histogram-equalization.cu contrast-enhancement.cu
################################################################################
# Rules and targets
# All Phony Targets
.PHONY : everything clean
# Default starting position
everything : $(EXECUTABLE)
# Common includes and paths for CUDA
# INCLUDES := -I$(CUDA_INC_PATH) -I. -I.. -I$(CUDA_INC_PATH)/samples/common/inc/
# Clean OBJECTS
clean :
rm -f $(EXECUTABLE) $(OBJ)
$(EXECUTABLE) : $(CCFILES)
$(NVCC) -o $# $^ $(INCLUDES) $(LDFLAGS) $(EXTRA_LDFLAGS) $(GENCODE_FLAGS)
What's the problem with my code?
This problem will occur when you are writing cuda code that is inside a file named .cpp, and you go to compile it. Rename the file to .cu, and the compiler will not complain at you.
In a bazel build rule, try putting the .cu.cc file in the hdrs rather than srcs.