FILE * fp = fopen(“myfile.txt","w+a") ;
int fd= -1;
if ( fp != NULL ) dup2(fd,1) ; // 1 for stdout
if ( fd < 0 ) return false ; // fail
else return true ; // success
close(fd);
fclose(fp);
「Embedded system’s Road」分類文章彙整
redirect stdout to a file
發文作者 cotton5415 於 五月 31, 2008
發表於 Debian's Road, eee pc's road, Embedded system's Road, MAC OS X's Road, network programming | 張貼留言 »
blit banchmark on each platform
發文作者 cotton5415 於 四月 2, 2008
ref:
http://www.rocklyte.com/news_20030917.html
發表於 Debian's Road, eee pc's road, Embedded system's Road, Evolutionary Music, Fedora Core 6's Road, MAC OS X's Road, Win32's Road | 張貼留言 »
make file link with dynamic and static libraries
發文作者 cotton5415 於 三月 21, 2008
- to build static library
- to build dynamic library
- to use static library
- to use dynamic library
% gcc -c libtest.c -o libtest.o
% ar rcs libtest.a libtest.o
-fPIC option tells gcc to create position independant code which is necessary for shared libraries
% gcc -c -fPIC libtest.c -o libtest.o
% gcc -shared -o libtest.so libtest.o
% gcc -static main.c -L. -ltest -o testStatic
% gcc main.c -L. -ltest -o testDynamic
the source file of application who uses the library ltest, sould be located before -l options
-L<path to search libraries> (no spacing after -L)
-o <output file>
-l<lib_name> (no spacing after -l)
gcc [options] -o
發表於 Debian's Road, eee pc's road, Embedded system's Road, Fedora Core 6's Road, MAC OS X's Road | 張貼留言 »
warning: control may reach end of non-void function
發文作者 cotton5415 於 二月 13, 2008
because the called function declared as the non-void (ex: int add(int a,int b) ) but in the called function it has no “return" value.
發表於 Debian's Road, Embedded system's Road, MAC OS X's Road, Win32's Road | 張貼留言 »
order of link libraries in makefile
發文作者 cotton5415 於 十月 15, 2007
example:
libabc.a is an user make library, in this lib, use a function pow in linux lib -lm.
in makefile you should
$(CC) -o a.out -labc -lm
if you
$(CC) -o a.out -lm -labc
there would be an link error
發表於 Debian's Road, Embedded system's Road, Fedora Core 6's Road, MAC OS X's Road, Win32's Road | 張貼留言 »
stray ‘\’ in program
發文作者 cotton5415 於 九月 13, 2007
problem
compiling error:
mmi_gfx_macro.h:21: parse error before `{‘
mmi_gfx_macro.h:21: stray ‘\’ in program
mmi_gfx_macro.h:22: stray ‘\’ in program
root cause
Possibly \ at “end" of a CRLF terminated line is not seen as
line-continued?
solution:
%dos2unix <your_c_file>
發表於 Debian's Road, Embedded system's Road, Fedora Core 6's Road, MAC OS X's Road, network programming, networking | 張貼留言 »
Build php with thttpd
發文作者 cotton5415 於 四月 3, 2007
Steps:
-
build php with configuration –with-thttpd=<thttpd_src_folder>
./configure –with-thttpd=<thttpd_src_folder>
make all; make install -
in thttpd source folder
./configure
make all; make install
Remarks:
- php5.x with thttpd –> 3.xMB
- php4.x with thttpd –> 1.xMB
Reference:
http://www.phpe.net/manual/install.linux.php
發表於 Embedded system's Road | 張貼留言 »
