I am using floaterm, which is a vim plugin. It is shown in the link. I want to set <F5> as the key to compile c file in the floaterm. And this is the setting:
noremap <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
if &filetype == 'c'
FloatermNew gcc -ansi -Wall % -o %< && time ./%<
endif
endfunc
The :FloatermNew is the one of the options to open floaterm.
When I press <F5>, it does compile in the floaterm, but the floaterm disappears a moment later. So I want to know how to let it compile and the floaterm is still there to show me the output.
Related
I have a series of tests for a school project that involves building an assembler.
The tests use popen to catch the output of "make" and "./assembler" -- this is just so the output of these commands don't crowd the output of the test suite.
The problem is that the call to popen that executes "diff" returns a string inside the automated test suite, but not when I call it manually.
Here's the test suite code:
char buf1[256];
FILE* make;
FILE* assemble;
FILE *diff;
make = popen("make", "r");
assemble = popen("./assembler input/simple.s inter.txt out.txt", "r");
diff = popen("diff inter.txt out/ref/simple_ref.int", "r");
fgets(buf1, sizeof(buf1), diff);
printf("\nafter fgets simple -- strlen(buf) is %d\t buf is %s\n", strlen(buf1), buf1);
Here's the segment of the test suite output that corresponds with the above code:
after fgets simple -- strlen(buf) is 8 buf is 1,7c1,6
Here's the series of commands when called manually:
aweeeezy ⋯ make
rm -f *.o assembler test-assembler core
gcc -g -std=gnu99 -Wall -o assembler assembler.c src/utils.c src/tables.c src/translate_utils.c src/translate.c
aweeeezy ⋯ ./assembler input/simple.s inter.txt out.txt
Running pass one: input/simple.s -> inter.txt
Running pass two: inter.txt -> out.txt
Assembly operation completed successfully.
aweeeezy ⋯ diff inter.txt out/ref/simple_ref.int
aweeeezy ⋯
When you use popen(), you're launching subprocesses which run at the same time as your program. In the code fragment you showed, the subprocesses will all be running around the same time without coordination.
To replicate the command line behavior, you want to wait until each subprocess is done; which is to say, call pclose() before moving to the next stages of your process. For examples, check something like "Pipes the easy way!" at http://www.tldp.org/LDP/lpg/node12.html
I want to change my diretory to go/pkg/darwin_amd64 but $ cd $GOPATH/pkg/${GOOS}_${GOARCH} doesn't find the folder though directory exists.
$ echo $GOPATH/pkg/${GOOS}_${GOARCH} gives /go/pkg/_ instead of /go/pkg/darwin_amd64.
$ go env prints:
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/sahilkapoor/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
We can see that GOOS and GOARCH are defined here. I am using terminal on Mac OSX 10.10.3. What am I missing?
$GOOS and $GOARCH will only be defined in your shell if you have exported them (which, unless you are doing cross compilation, is unlikely).
When you run go env, default values are shown when they have not been overwritten by your environment. You should change your command to the following to get the desired results:
cd $(go env GOPATH)/pkg/$(go env GOOS)_$(go env GOARCH)
I am using raspberry PI to run some assembler code on GPU.
It works like this: you assemble the code into binary file. Then you include it into a C code which pushes data into the GPU. This binary file is defined as
extern uint32_t arrayOfCode[];
However I can not find where is this code included(it is not in any other include files).
The whole code can be found here
Upon running makefile it works.
Where the problem comes is when I am trying to build it as MEX function in Matlab.
Matlab cannot find where is the assembler binary code defined. Thus I have a suspicion that it must be linked somehow in Makefile since that's the only difference in building it.
Does anyone has an idea how to find where is this extern value defined ?
==EDIT 1==
I posted my one solution how to build this into a Matlab library.
But the question remains more or less the same. How this makefile
CXX=g++
ASMSRCS := gemm_float.asm
ASMOBJS := $(subst .asm,.do,$(ASMSRCS))
CPPSRCS := $(shell find . -name '*.cpp' -not -name '._*')
CPPOBJS := $(subst .cpp,.o,$(CPPSRCS))
CPPFLAGS=-Ofast -DTARGET_PI -march=armv6 \
-mfloat-abi=hard \
-ftree-vectorize \
-funroll-all-loops \
-mfpu=vfp \
%.cdat: %.asm helpers.asm
m4 $< | qpu-asm -o $(basename $#).cdat -c g_$(basename $#)Code
%.do: %.cdat
$(CXX) $(CPPFLAGS) -x c -c $< -o $(basename $#).do
%.o: %.cpp
$(CXX) $(CPPFLAGS) -fPIC -c $< -o $(basename $#).o
gemm: $(CPPOBJS) $(ASMOBJS)
g++ -g -O3 -o gemm $(CPPOBJS) $(ASMOBJS) -lblas
Could include "gemm_float.asm" assembled code into the C array defined with the keyword extern. I read that these "%." rules in makefile are rules for dependencies. Okay, that would mean that "gemm" would build anew if I changed something in files that "gemm" depends on. Or I might not understand makefiles well enough.
I was able to fix the issue by separately building C code and assembler code. This is for anyone who cannot use an original makefile for some reason(mine was trying to build this into a mex Matlab library).
First, we build code.asm into binary file
m4 code.asm | ./qpu-asm -o code.bin
Now we have to adjust our C code in such a way that it loads .bin code in it's main function. I used a function from eman's tutorial which simply reads the assembler code from a bin file and saves it into an array for later use.
int loadQPUCode(const char *fname, unsigned int* buffer, int len)
{
FILE *in = fopen(fname, "r");
if (!in) {
fprintf(stderr, "Failed to open %s.\n", fname);
return -1;
}
size_t items = fread(buffer, sizeof(unsigned int), len, in);
fclose(in);
return items * sizeof(unsigned int);
}
Then it is enough to call call this before using any gpu related function.
loadQPUCode("asmCode.bin",arrayOfCode,CONSTANT_RELATIVE_TO_ASMCODE);
With this adjusted C code and binary assembler code I was able to build Matlab library using matlab mex function.
mex main.cpp include1.cpp include2.cpp
I want to stop debug optimization in eclipse cdt and I read article about this
http://husks.wordpress.com/2012/03/29/hardware-debugging-the-arduino-using-eclipse-and-the-avr-dragon/
it supposed to see tool setting in eclipse indigo but I didn't see it.
what is the problem
see this for more info
https://sourceforge.net/projects/cmusphinx/forums/forum/5471/topic/5170910
this is my make file
TOP=../../..
DIRNAME=src/programs/init_gau
BUILD_DIRS =
ALL_DIRS= $(BUILD_DIRS)
SRCS = \
accum.c \
init_gau.c \
main.c \
parse_cmd_ln.c
H = \
accum.h \
init_gau.h \
mk_sseq.h \
parse_cmd_ln.h
FILES = Makefile $(SRCS) $(H)
TARGET = init_gau
ALL = $(BINDIR)/$(TARGET)
include $(TOP)/config/common_make_rules
I found this config file
# -*- makefile -*-
#
# This file is automatically generated by configure.
# Do not hand edit.
CC = gcc
CFLAGS = -g -O0 -Wall -fPIC -DPIC
CPPFLAGS = -I/media/sda5/sphinx/tutorial/SphinxTrain/../sphinxbase/include -I/media/sda5/sphinx/tutorial/SphinxTrain/../sphinxbase/include
DEFS = -DPACKAGE_NAME=\"SphinxTrain\" -DPACKAGE_TARNAME=\"sphinxtrain\" -DPACKAGE_VERSION=\"1.0.99\" -DPACKAGE_STRING=\"SphinxTrain\ 1.0.99\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIBM=1
LIBS = -lm -lsphinxbase
LDFLAGS = -L/media/sda5/sphinx/tutorial/SphinxTrain/../sphinxbase/src/libsphinxad -L/media/sda5/sphinx/tutorial/SphinxTrain/../sphinxbase/src/libsphinxbase -L/media/sda5/sphinx/tutorial/SphinxTrain/../sphinxbase/src/libsphinxbase/.libs
AR = ar
RANLIB = ranlib
FESTIVAL = /usr/bin/festival
PERL = /usr/bin/perl
The options are under project properties as explained in first tutorial. If you are trying to build a project with existing makefile, then you need to edit the makefile.
You dont typiclly need to change project properties. Debug configuration builds without optimization by default. You just need to make sure you jave it selected. This is done using the icon (sundial? - the one next to CDT's build (hammer)).
I have successfully configure perl for cross comile by using configure options:
./Configure -des -Dusecrosscompile \
-Dtargethost=172.17.185.91 \
-Dtargetdir=/home/perl/ \
-Dtargetuser=root \
-Dtargetarch=arm-linux \
-Dcc=arm-linux-gcc \
-Dusrinc=/opt/Mozart_Toolchain/arm-eabi-uclibc/include/ \
-Dincpth=/opt/Mozart_Toolchain/arm-eabi-uclibc/include/ \
-Dlibpth=/opt/Mozart_Toolchain/arm-eabi-uclibc/lib/
And the configure script tell me "Now you must run 'make'." But I encounter such as error when I make:
`sh cflags "optimize='-O2'" miniperlmain.o` miniperlmain.c
CCCMD = arm-linux-gcc -DPERL_CORE -c -DOVR_DBL_DIG=14 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -Wall
In file included from perl.h:38,
from miniperlmain.c:40:
config.h:4425:12: error: operator '==' has no left operand
In file included from miniperlmain.c:40:
perl.h:713:14: error: operator '>=' has no left operand
... ...
In config.h, some macro is left blank, for example:
#define INTSIZE /**/
#define LONGSIZE /**/
#define SHORTSIZE /**/
... much more ...
And I think it is the undefined macro result in the make error. I have no idea how to fix it. Why the macro is blank even if successfully configure?
Are there some guides to cross compile Perl?
There is a Cross directory that features a README file that includes the following instructions for arm-linux:
1) You should be reading me (README) in perl-5.x.y/Cross
2) Make sure you are in the Cross directory.
3) Edit the file 'config' to contain your target platform information.
4) make patch ## This will patch the existing source-tree.
5) make perl ## Will make perl
(Read the whole thing.)
I got the easiest way to cross compile Perl for arm-linux.Please refer to Cross-compiling perl. It's a great work! It saved my life.
Just according to instructions that give, you can get what you want. You may encounter such error when 'make':
pp_sys.c:78: error: non-thread-local declaration of 'h_errno' follows thread-local declaration
Simply comment that line.
Enjoy it!