Waiting for the wind

programming memo in different platforms

「Embedded system’s Road」分類文章彙整

redirect stdout to a file

發文作者 cotton5415 於 五月 31, 2008

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);

發表於 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
  • % gcc -c libtest.c -o libtest.o
    % ar rcs libtest.a libtest.o

  • to build dynamic library
  • -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

  • to use static library
  • % gcc -static main.c -L. -ltest -o testStatic

  • to use dynamic library
  • % 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)

  • in static link, library name is lib.a ex: libtest.a libcheckitout.a or libxxxx.a
  • in dynamic link, library start with lib ex: libtest or libtest.so or lib….
  • 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 | 張貼留言 »

    EM8621L get media duration

    發文作者 cotton5415 於 九月 14, 2007

    1. to get mp4′s duration, open track video/audio first.

    sample code.tgz

    發表於 Embedded system'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:

    1. build php with configuration –with-thttpd=<thttpd_src_folder>
      ./configure –with-thttpd=<thttpd_src_folder>
      make all; make install
    2. 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 | 張貼留言 »

     
    Follow

    Get every new post delivered to your Inbox.