Everything is perfectly explained in this post:
List of commands
Everything is perfectly explained in this post:
List of commands
Show information that save kernel when application crashed
FastCGI comes with Win32 project for VisualStudio6. Unfortunately when you try to open it in VisualStudio2010 the project will be corrupted. To correctly compile it for VS2010 it's necessary to download library sources, get patches from cybozu.co.jp site and apply it.
Download latest version of Development Kit here and extract it to standalone directory.
Download all five patches from Cybozu site. Now when you have patches it's necessary to convert all files to correct windows-ending format. This can be done for example in Notepad++.
Now you need some application capable to apply the patches. Unfortunately windows doesn't contain any application for this task and also lot of comparing/merging applications can't do that.
Open directory with fastcgi library, copy all patch files to this directory and open command line. As next run patch command for all fives patches:
In case you will see following error message:
it's necessary to convert ALL patch files to correct Windows format (correct EOL) as mentioned in previous section.
When you apply patches by cybozu it's time to apply my own patches ;-).
As first, it's probably that you will see following message:
It's because original patch is for older version of library and file os_win32.c is slightly different. To fix that, edit this file at line 841 and manually update following line:
Now turn off generating the Map Files in project configuration. These files aren't necessary and it isn't possible to compile project correctly with this settings.
And that's all. Now you will be able to sucesfully compile fast-cgi library.
**Visual Studio C++ fcgi Echo Example** - http://www.coastrd.com/cppecho
CGICC - how to update it for VS2010 COMPILATION
During our development we found that Microsoft RegEx (Regular expression) implementation contains a bug which caused crashes of our applications. The application module using RegEx passed all unit test, but sometimes under heavy usage the application crashed at our customer. Because we use **BugTrap **for error and crash notifications, we knew the error was in atlrx.h file.
After several hours of testing and searching we found the bug. The crash didn't occur after first code execution, but we had to run thousand iterations of the same code over and over. The bug is located in file atlrx.h at line 708.
case RE_ADVANCE: sz = CharTraits::Next(szCurrInput); szCurrInput = sz; if ( sz == NULL || *sz == '') goto Error; ip = 0; pContext->m_nTos = 0; break;
Problem is, that variable szCurrInput have in some circumstances NULL value and this causes the crashes.
**Updated file with bug fix:**
case RE_ADVANCE: if( szCurrInput == NULL || *szCurrInput == '' ) goto Error; sz = CharTraits::Next(szCurrInput); szCurrInput = sz; if ( sz == NULL || *sz == '') goto Error; ip = 0; pContext->m_nTos = 0; break;
We change the first two lines. It is necessary to test szCurrInput variable for NULL and empty string value. If szCurrInput is NULL or empty string, it's necessary to stop processing RegEx. Otherwise stack overflow during processing string occurs.
Some time later we had other problems with Microsoft RegEx implementation and non-standard RegEx syntax. So we left MS RegEx parser and moved to Boost.Regex which is really nice piece of code (as well as other libraries of the Boost pack) and supports Perl and POSIX regular expressions. Whole Boost library is carefully unit test and can be relied on.
System performance tools
Linux test tools (not tested yet)
The problem was that boost build helper run my python.bat instead of correct python.exe from %PATH% directory.
To check which python is used enter following param:
How to solve problem with gdb: "ptrace: operation not permited"
The bug is probably caused by wrong alignment or incorrect VS2010 compiler optimalization.
go to $QTDIR/mkspecs/win32-msvc2010/qmake.conf and replace -02 with -01 (ie. reducing the optimzation level).Also /Ob0 could be used.
File patch name VS10-KB2268081-x86.exe
Service pack could also contains required fix.
Error appear when using BOOST::fusion::map<....>
Invalid source code
for fix simply change result_of::at_key to result_of::value_at_key
After fixing this error, you can achieved problem with const modifier. Correct syntax for const definition is:
The problem is that the number of user-defined conversions that are invoked implicitly is limited (to 1) by the Standard.
B ob = a;
implies two user conversions:
The solution is to use explicit conversion
For g++ compiler is sometimes necessary to specify more typename / template keywords than for Visual Studio. This is one of examples.
To the following code it's necessary to add template keyword:
MinGW-32, MinGW-64 and MSYS to folder MinGW64 (Bin folder from MinGW will be merged with bin folder from MSYS, etc.)
http://www.martinfowler.com/bliki/AnemicDomainModel.html (Anemic domain model - why huge service layer is bad)
If your application using some externals dynamic libraries (called .dylib in MacOs system), you have to provide all these libraries. The simplest way is to provide these libraries into the Application.app directory.
Qt provide really useful tool called **"otool"** which serves to lots of purpose. One of them is to detect which shared libraries are required by our application. For this purpose otool has parameter -L. The usage is following:
Output could looks like this:
Output from "otool" is simmilar to linux tool "ldd".
Because manual copying and configuring all shared libraries to our application could be difficult, Qt have deployment tool which do all work for us. Tool is called "macdeployqt" and can be found in /Developer/Tools/Qt/macdeployqt.
**Note:** Every time when you call macdeployqt tool, project have to be build from scratch. But is sufficient when whole result directory is removed and linked again:
Quick post about problem which I already solved, but think that could be handy for someone else.
I have following code:
When compiling under Visual studio, everything is ok. But when try the same code snippet under g++, have following error:
This is because compiler doesn’t known FindByType method, because T2 is templated argument. The solution which I found is in adding keyword template before FindByType method name. So updated source code will look like this:
After this update, code will be compiled correctly under both compilers.
Project site: http://teng.sourceforge.net/?page=home
External project documentation: http://teng.olmik.net/
Latest TENG source code: http://teng.cvs.sourceforge.net/teng/ (**Note**: Source code referenced from main site isn't latest! )
Compilation under Windows is possible only using MinGW and with few modifications in TENG code (because there is few glitch which didn't meet c++ standards). If you want more information or updated TENG version, please let me know.
Sometime it's useful to know what defines are available on specific platform and compiler. Here is command which shows these defines:
Example visualizator for XString
Here is a simple example how to use the iconv library.
During my attempts with libiconv library I encountered two different problems:
This is because iconv function modify pOut ptr during string processing. When you need to access output buffer after **iconv()** function finish its work, you have to access it via different pointer than one passed to this function. In my code I'm using *dst and pOut ptrs;
Check if have correct order of parameters in your **iconv_open()** and **iconv()** function. Function **iconv_open()** has as its first parameter OUTPUT encoding, and as second parameter INPUT encoding. While **iconv()** function has as first parameters INPUT variables, and as second parameters OUTPUT variables. This inconsistency is really confusing.
Official libiconv site: http://www.gnu.org/software/libiconv/
Official libiconv documentation: http://www.gnu.org/software/libiconv/documentation/libiconv-1.13/
Lots of open source libraries (like libiconv, libintl, ...) doesn't have MSVC project files or makefiles. Only supported way how to compile given library under Window is using MinGW and MSYS compiler tools.
Here is step-by-step guide how to download, install and compile libraries using MinGW.
From MinGW home web site http://www.mingw.org/ download "Automated MinGW Installer". Current version could be downloaded here: http://sourceforge.net/projects/mingw/files_beta/Automated MinGW Installer
Run downloaded executable. As install directory leave C:\MinGW. It's recommended not to change this path. On component screen select C compiler, C++compiler, MSYS Basic System and MinGW Developer Toolkit.
After that select next,next,next, finish ;-). After that installer downloads all necessary files. This could take a few minutes.
When installation is done, as next step is necessary to setup PATH variable to c:\MinGW. Installer doesn't modify it automatically. (more info about modifying PATH variable) .
These two packages isn't listed in available components. If you wish to install it, use mingw-get-inst. In c:\MinGW\bin directory run following commands:
Launch cmd tool, go to directory with source code and use g++.
Laung MinGW from startmenu or msys.bat from %INSTALL_PATH%\MinGW\msys\1.0\msys.bat.
As first, download latest libiconv source files from http://www.gnu.org/software/libiconv. And extract whole package somewhere on your disk.
Launch MinGW console and go to the extracted directory. When you extracted directory to the path:
Type following command to MinGW console:
after that, run **configure** with required library params (in our case we want static and dynamic version of library)**:**
and than run make
Compiled libraries are located in directory "libiconv-1.13.1\lib\.libs". There is additional information about building libiconv library on stackoverflow.
This list is compilation of answer to questions and informations how to solve some problems which I had during my installations.
Use **"configure --help"** command.