2012年10月31日 星期三

[bash] $'\r': command not found


Error:
I got message below when I execute a bash script.
D:/asmbin/gnuasm: line 2: $'\r': command not found
D:/asmbin/gnuasm: line 4: $'\r': command not found

Solution:
It is caused by end of line is Windows style '\n\r'
Unix think the eol should be '\n'
Mac think the eol should be '\r'

The bash is unix environment, so we have to change '\n\r' to 'n'.
I use notepad++ as editor to fix the script.

Reference:
http://stackoverflow.com/questions/11616835/cgywin-r-command-not-found-bashrc-bash-profile
http://chunshucaca.blog.163.com/blog/static/6045100020082317363713/

[bash] MS-DOS style path detected


Error:
I got message below when I execute a bash script.
cygwin warning:
  MS-DOS style path detected: D:/asmbin/gnuasm
  Preferred POSIX equivalent is: /cygdrive/d/asmbin/gnuasm
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

Solution:
To ignore the message, please add "set CYGWIN=nodosfilewarning" in head of script

Reference:
http://blog.csdn.net/liuhongjavaen/article/details/7254077

2012年10月30日 星期二

[.Net] Dumpbin to see the contents of windows library (*.lib)


To view what functions inside lib file, we can open "Visual Studio Command Prompt", and type "Dumpbin /exports [file_path]" to show all functions be implemented.

C:\Program Files\Microsoft Visual Studio 9.0\VC>dumpbin /exports "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\libegl.lib"
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\libegl.lib

File Type: LIBRARY

     Exports

       ordinal    name

            14    eglBindAPI
            20    eglBindTexImage
             7    eglChooseConfig
            33    eglCopyBuffers
            23    eglCreateContext
            18    eglCreatePbufferFromClientBuffer
            10    eglCreatePbufferSurface
            11    eglCreatePixmapSurface
             9    eglCreateWindowSurface
            24    eglDestroyContext
            12    eglDestroySurface
             8    eglGetConfigAttrib
             6    eglGetConfigs
            26    eglGetCurrentContext
            28    eglGetCurrentDisplay
            27    eglGetCurrentSurface
             2    eglGetDisplay
             1    eglGetError
            34    eglGetProcAddress
             3    eglInitialize
            25    eglMakeCurrent
            15    eglQueryAPI
            29    eglQueryContext
             5    eglQueryString
            13    eglQuerySurface
            21    eglReleaseTexImage
            17    eglReleaseThread
            19    eglSurfaceAttrib
            32    eglSwapBuffers
            22    eglSwapInterval
             4    eglTerminate
            16    eglWaitClient
            30    eglWaitGL
            31    eglWaitNative

  Summary

          C3 .debug$S
          14 .idata$2
          14 .idata$3
           4 .idata$4
           4 .idata$5
           C .idata$6


You also can type "Dumpbin /exports /out:[outFile] [file_path]" to list all functions in text file if functions are too many to show in screen.

Reference:

2012年10月22日 星期一

[CMake] Some settings for VS project file

This is a simple note that showing some statement in CMakeList.txt to configure setting of VS project.

To add Preprocessor Definitions.
add_definitions(-DNOENTRY)










To add Additional Include Directories.

INCLUDE_DIRECTORIES(${VCInstallDir}/include/sys)










To modify Runtime Library.
STRING(REPLACE "/MTd" "/MDd" CMAKE_CXX_FLAGS_DEBUG
${CMAKE_CXX_FLAGS_DEBUG})
STRING(REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
STRING(REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
STRING(REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL})








To Exclude Build Project from solution.
If project is added by this line add_library(foo EXCLUDE_FROM_ALL foo.c)
Add statement below to exclude project from build.
set_target_properties(foo PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)



[Git] error: bad index file sha1 signature fatal: index file corrupt

Error:
I got an error message below.
$ git pull --rebase
error: bad index file sha1 signature
fatal: index file corrupt
error: bad index file sha1 signature
fatal: index file corrupt
error: bad index file sha1 signature
fatal: index file corrupt
Cannot pull with rebase: You have unstaged changes.
error: bad index file sha1 signature
fatal: index file corrupt
Additionally, your index contains uncommitted changes.
Please commit or stash them.


Solve:
1. Delete file .git/index
2. git reset --hard HEAD


Reference:
http://blog.wu-boy.com/2010/08/git-%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%EF%BC%9A%E5%88%A9%E7%94%A8-git-reset-%E6%81%A2%E5%BE%A9%E6%AA%94%E6%A1%88%E3%80%81%E6%9A%AB%E5%AD%98%E7%8B%80%E6%85%8B%E3%80%81commit-%E8%A8%8A%E6%81%AF/

2012年10月11日 星期四

[Webkit] fatal error LNK1106: invalid file or disk full

Problem:
Build Webkit on VS2008+Windows 7 32-bit, got the error message as title.
fatal error LNK1106: invalid file or disk full

Solve:
Install the VS2005 hot fix KB949009
https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=18623

It is very weird for VS2008, perhaps I had installed VS 2005 before.

Reference:
http://lists.macosforge.org/pipermail/webkit-help/2010-May/001141.html

2012年10月8日 星期一

[Webkit] error LNK2019: unresolved external symbol localtime_s referenced in function localtimeOffset

When I build webkit with WinCE 6.0 SDK, I got the error message as title.
error LNK2019: unresolved external symbol localtime_s referenced in function localtimeOffset

To solve the problem, I remove the code in bold font below.

#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \
     defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
//#define HAVE_LOCALTIME_S 1
#endif


After that, I got the error message below.
error C2040: 'localtime' : 'tm *(const time_t *)' differs in levels of indirection from 'int ()'

To solve the problem, I add the code before where function localtime is called.
struct tm *__cdecl localtime(const time_t *t);



Reference:
http://web.archiveorange.com/archive/v/fwvdeo1G1weLoWDuyUPP
http://hi.baidu.com/lihex/item/2243dfe144e14ef82a09a4d4
http://stackoverflow.com/questions/6380981/c-c-c4047-differs-in-levels-of-indirection-from-int

[Webkit] Memory Leak in GraphicContext

* BSQUARE Corp. and I remain the copyright of the code and article.

[Memory Leak in GraphicContext]
The function in GraphicContextCairoWin.cpp below will allocate a memory block to cairo_t*
static cairo_t* createCairoContextWithHDC(HDC hdc, bool hasAlpha)

We have to release memory when platform destory in GraphicContextCairo.cpp

void GraphicsContext::platformDestroy()
{
RefPtr<cairo_t> cr = platformContext()->cr();
cr.~RefPtr();
    delete m_data;
}




2012年10月1日 星期一

[CMake] Re-run cmake with a different source directory.

Problem:
CMake Error: The source "Path1/CMakeLists.txt" does not match the source "Path2/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source
directory.


I got above error message when I execute below cmake command to generate solution for webkit.
cmake -G "Visual Studio 9 2008" -DCMAKE_WINCE_SDK="SDK_Name" -DPORT=WinCE -D3RDPARTY_DIR=Path1 Path2


Solve:
Delete CMakeCache.txt in the folder you executing cmake.









[Webkit] Failed to determine path to Apple Application Support directory

Problem:
After I successful build webkit by VS 2008 in Windows 7. I try to start up MiniBrowser.exe or WinLauncher.exe, and I got the error message as title.
Failed to determine path to Apple Application Support directory










Solve:
Edit registry table 
Add key Apple Application Support into HKEY_LOCAL_MACHINE\SOFTWARE\Apple Inc.
Then add string value 'InstallDir', 'UserVisibleVersion' and 'Version' as figure below.













Reference:
http://www.cnblogs.com/xyz2abc/archive/2012/04/09/2438913.html

[Webkit] Can't locate http/date.pm in @inc

Problem:
I got an error message as title when I try to update webkit auxiliary library.











Solve:
It is caused by our Cygwin’s Perl package is missing the HTTP/Date.pm module.
Type cpan HTTP::Date to fix.











Update again.








Reference:
http://blog.ashodnakashian.com/2012/09/