Glib GIOChannel - glib

I'm trying a tutorial on glib which uses GIOChannel. I'm using Ubuntu 11.04 (Natty Narwhal) with glib-2.30.2 (gtk+-3.2.3) and C code.
The code is from here:
http://library.developer.nokia.com/index.jsp?topic=/GUID-E35887BB-7E58-438C-AA27-97B2CDE7E069/GUID-817C43E8-9169-4750-818B-B431D138D71A.html
The program runs but I the contents of my source test file is not copied to the destination file. I'm not receiving any error or warning messages. The program just does nothing. What's wrong here?

Works now, I changed the line:
g_print("usage:<cp SOURCE> <DESTINATION>\n");
To:
g_print("usage: %s <SOURCE> <DESTINATION>\n", argv[0]);
Then compiled it using:
gcc -Wall $(pkg-config --cflags gio-2.0) -c io.c
gcc -Wall $(pkg-config --libs gio-20) -o io io.o
Run the program using: ./io io.c new_io.c

Related

How to use coverage analysis with Cython

I'm trying to run coverage analysis on some Cython code using pytest-cov and coveralls.io. I've got as far as building the extension modules with tracing enabled, and running the analysis with the help of the links below:
http://docs.cython.org/src/tutorial/profiling_tutorial.html
http://blog.behnel.de/posts/coverage-analysis-for-cython-modules.html
However, I'm getting some results that I can't explain. It seems that many of the def/cdef/cpdef lines in the code are showing as not running, despite code within them being OK. The results aren't even consistent as some lines seem OK.
Example report: https://coveralls.io/files/1871744040
I don't know if I'm calling something wrong, if this is a bug, or if I'm just not interpreting the results correctly.
In the example above, the get_cost method seems OK, but the __set__ method for the property above is not called, despite the lines within the function having been called.
Update: It seems the issue is with Cython classes. If the class is defined with def rather than cdef the problem goes away. I guess there isn't full support for this yet.
If the Cython tracing facility does not seem to work as intended, it should be possible to use gcov for the coverage analysis of cython code. This way one could verify if some line of the generated C code is executed or not.
With a simple main.pyx
import mymod
def main():
mymod.test()
and mymod.pyx
def test():
return 42
and then
cython --embed main.pyx
cython mymod.pyx
gcc -O1 -fPIC -fprofile-arcs -ftest-coverage -Wall -I/usr/include/python2.7 -c -o main.o main.c
gcc main.o -fprofile-arcs -lpython2.7 -lgcov -o main
gcc -O1 -fPIC -fprofile-arcs -ftest-coverage -Wall -I/usr/include/python2.7 -c -o mymod.o mymod.c
gcc -shared mymod.o -fprofile-arcs -lgcov -lpython2.7 -o mymod.so
an executable was created. After executing ./main main.gcda and mymod.gcda were created for gcov.

what are the args that are being passed from clang to llc?

I am working on the llvm project. Recently I tryed to compiler one of my .c files using clang command line into an .s file by using the next command:
clang --target=arch -S -O0 select.c -o select.s
and it crashed in the backend in the function ARCHInstrInfo::storeRegToStackSlot with the backtrace of the stack.
However when I tryed to do it in steps:
clang -O0 -emit-llvm select.c -c -o select.bc
llc -filetype=asm -march=arch ./select.bc -o ./select.s -print-after-all -debug-only isel
it succeeded !! (?)
How can I see how the clang is calling to the backend (llc) ?
I tryed to run the clang with -v flag but it didn't printed how it is calling to the backend...
So the first one that sticks out is that llc defaults to O2 rather than O0 so you might want to look there first.

How to build lpeg on windows?

I've downloaded lpeg source code from http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-0.12.tar.gz
How to get the dll? I can't do it with the makefile included. I'm using mingw32.
You can use this simple batch file running from lpeg folder:
set LUA_DIR=D:\lua-5.2
gcc -O2 -shared -s -I %LUA_DIR%\src -L %LUA_DIR%\src -o lpeg.dll lptree.c lpvm.c lpcap.c lpcode.c lpprint.c -llua52
Just set LUA_DIR folder to the folder with your Lua installation; it works with both Lua 5.1 and Lua 5.2.
First change the LUADIR variable to the correct location of your Lua include files. Then add the following make target (using the correct path to your Lua DLL):
mingw: $(FILES)
$(CC) $(CFLAGS) -shared $(FILES) -o lpeg.dll C:\path\to\lua52.dll
I also had to change CC from gcc to mingw32-gcc, but that might just be my broken MinGW installation.
make mingw
should work now.

how does g++ linking order matter?

I am making a program on raspberry pi and it uses opencv and mysql. they both compile fine when I compile them separately. but after i combine the 2 files I cannot compile them.
I could compile my opencv part using
g++ $(pkg-config --libs --cflags opencv) cv.cpp -o cv -I/home/pi/git/robidouille/raspicam_cv -L/home/pi/git/robidouille/raspicam_cv -lraspicamcv -L/home/pi/git/raspberrypi/userland/build/lib -lmmal_core -lmmal -l mmal_util -lvcos -lbcm_host
without any problem and compile my mysql part using
g++ -w sql.cpp $(mysql_config --cflags) $(mysql_config --libs)
but after I merge the code and try to compile the merged code using
g++ $(pkg-config --libs --cflags opencv) merged.cpp -o merged $(mysql_config --cflags) $(mysql_config --libs) -I/home/pi/git/robidouille/raspicam_cv -L/home/pi/git/robidouille/raspicam_cv -lraspicamcv -L/home/pi/git/raspberrypi/userland/build/lib -lmmal_core -lmmal -l mmal_util -lvcos -lbcm_host
I get an error saying error: ‘conn’ does not name a type
here is my code for that section
MYSQL *conn;
conn = mysql_init(NULL); //error here

Using OpenCV on BeagleBoard XM

I'm trying to compile simple OpenCV code on the BeagleBoard XM, running Ångström Linux.
I know my way in OpenCV, but only under Windows and Visual Studio. I'm fairly with non-Microsoft OSes.
I think I've installed OpenCV on the BeagleBoard (opkg install opencv, right?), and I've transferred my code, which for now look like this:
#include <opencv2/opencv.h>
int main()
{
cv::Mat img(100, 100, CV_8U);
cv::imshow("Hello world", img);
cv::waitkey();
return 0;
}
How can I compile this code under the BeagleBoard? How can I tell it where the .so files are? Where are the OpenCV .so files?
Have a look at ECE597 OpenCV on the BeagleBoard for installation instructions.
If you have installed it properly, then open a terminal window and browse to the folder where you have put the code. Once there, use the following command to compile the code in file "main.cpp"
g++ main.cpp -o out `pkg-config --cflags --libs opencv`
After the code is compiled, use the following command to execute it.
./out
Also look at the answers to Stack Overflow question How to install OpenCV on Ångström Linux?.
export LD_LIBRARY_PATH=/usr/local/lib
gcc `pkg-config --cflags opencv` -g -o NameOfProgram main.cpp `pkg-config --libs opencv`
Probably these commands should the work. Just don't forget to change the cpp filename if needed. See this.

Resources