<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-474731956337179291</id><updated>2011-09-01T11:42:10.429-07:00</updated><category term='linux'/><category term='msvc'/><category term='xml'/><category term='hiberlite'/><category term='dll'/><category term='ode'/><category term='windows service'/><category term='cygwin'/><category term='Do The Same Series'/><category term='IDE'/><category term='visual studio'/><category term='c#'/><category term='programming libraries'/><category term='boost.rdb'/><category term='csharp'/><category term='mingw'/><category term='libxml++2'/><category term='gtkmm'/><category term='programming tools'/><category term='SDL'/><category term='twitter'/><category term='orm'/><category term='xpath'/><category term='debian'/><category term='Qt'/><category term='asp.net'/><category term='programming languages'/><category term='libcurl'/><category term='c++'/><category term='opencv cmake libstdc++-6.dll custom build mingw make make.exe win32'/><category term='interesting libraries series'/><title type='text'>void page</title><subtitle type='html'>My computing adventures.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-6563220584636882142</id><published>2011-09-01T03:37:00.000-07:00</published><updated>2011-09-01T11:42:10.446-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='opencv cmake libstdc++-6.dll custom build mingw make make.exe win32'/><title type='text'>Building opencv on win32 with mingw and cmake</title><content type='html'>&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I will be logging my successful attempt at building opencv 2.3.1 on windows with mingw.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Rationale:&lt;/div&gt;&lt;div&gt;1. The binaries provided with &lt;a href="http://sourceforge.net/projects/opencvlibrary/"&gt;opencv superpack&lt;/a&gt; fail, requiring a mysterious libstdc++-6.dll&lt;/div&gt;&lt;div&gt;2. I have to build a robot. NOW.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Steps to reproduce success:&lt;/div&gt;&lt;div&gt;1. Download &lt;a href="http://sourceforge.net/projects/opencvlibrary/"&gt;opencv superpack&lt;/a&gt;&lt;/div&gt;&lt;div&gt;2. Download &lt;a href="http://nuwen.net/mingw.html"&gt;nuwen mingw&lt;/a&gt; because it is the most complete mingw `distro' out there (includes &lt;a href="http://www.libsdl.org/"&gt;SDL&lt;/a&gt;, &lt;a href="http://gcc.gnu.org/onlinedocs/"&gt;latest gcc&lt;/a&gt; and &lt;a href="http://www.boost.org/"&gt;boost&lt;/a&gt; goodness!)&lt;/div&gt;&lt;div&gt;3. &lt;a href="http://www.cmake.org/cmake/resources/software.html"&gt;Install cmake&lt;/a&gt;&lt;/div&gt;&lt;div&gt;4. Start cmd.exe, not msys.&lt;/div&gt;&lt;div&gt;5. Type in set PATH=&lt;mingwdir&gt;mingwdir\bin;cmakedir&lt;cmakedir&gt;\bin&lt;/cmakedir&gt;&lt;/mingwdir&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;where mingwdir and cmakedir are full paths to mingw and cmake installation locations.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The reason I resetted PATH variable is because you don't need any other paths in your current cmd.exe session in order to build opencv. Other systems such as &lt;a href="http://code.google.com/p/msysgit/"&gt;msysgit&lt;/a&gt; can interfere with your build, causing cmake to fail. Which is what happened in my case.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6. Extract opencv and go to opencv root dir.&lt;/div&gt;&lt;div&gt;7. execute the command:  cmake -G "MinGW Makefiles" -D CMAKE_MAKE_PROGRAM:string="&lt;mingwpath&gt;mingwdir\bin\make.exe" .&lt;/mingwpath&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Of course you can specify target dir, lib dir etc. I'm just giving this as an example to get over the problem that cmake can't find your make executable unless you tell it specifically with this variable. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The dot at the end means "current directory" where your opencv CMakeLists.txt resides.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;8. Execute make &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hope this will be useful for me in the future when I forget how to do things.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;End of log. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-6563220584636882142?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/6563220584636882142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=6563220584636882142&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/6563220584636882142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/6563220584636882142'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2011/09/building-opencv-on-win32-with-mingw-and.html' title='Building opencv on win32 with mingw and cmake'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-1294010444983083064</id><published>2009-12-16T23:59:00.000-08:00</published><updated>2010-02-14T03:23:35.819-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='boost.rdb'/><category scheme='http://www.blogger.com/atom/ns#' term='orm'/><category scheme='http://www.blogger.com/atom/ns#' term='interesting libraries series'/><category scheme='http://www.blogger.com/atom/ns#' term='hiberlite'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><title type='text'>Interesting Libraries Series #2</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Today's interesting libraries&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;C++&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Hiberlite &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-weight: bold;"&gt;Link&lt;/span&gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/hiberlite/"&gt;http://code.google.com/p/hiberlite/&lt;/a&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Properties&lt;/span&gt;&lt;br /&gt;Cross-Platform&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Synopsis&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;Provides a lazy interface to sqlite databases. Provides ORM capability using macros and boost.serialization library.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Boost.Rdb &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Link&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://code.google.com/p/boost-rdb/"&gt;&lt;span&gt;http://code.google.com/p/boost-rdb/&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Cross-Platform&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Synopsis&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;Boost based database access library. Provides &lt;a href="http://code.google.com/p/boost-rdb/source/browse/libs/rdb/test/rdb/test_tables.hpp"&gt;ORM capability&lt;/a&gt; and &lt;a href="http://code.google.com/p/boost-rdb/source/browse/libs/rdb/doc/examples.cpp"&gt;syntax like linq&lt;/a&gt;.&lt;br /&gt;This might, in the future, become the de-facto standard C++ database library.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;End of log&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-1294010444983083064?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/1294010444983083064/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=1294010444983083064&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/1294010444983083064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/1294010444983083064'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2009/12/interesting-libraries-series-2.html' title='Interesting Libraries Series #2'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-645256207905662641</id><published>2009-12-08T00:08:00.000-08:00</published><updated>2009-12-08T00:41:45.698-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='interesting libraries series'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><title type='text'>Interesting Libraries Series #1</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Today's interesting libraries&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;C++&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;UTF8-CPP &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-weight: bold;"&gt;Link&lt;/span&gt;&lt;br /&gt;&lt;a href="http://utfcpp.sourceforge.net"&gt;http://utfcpp.sourceforge.net&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Properties&lt;/span&gt;&lt;br /&gt;Cross-Platform&lt;br /&gt;Header-Only&lt;br /&gt;Iterator-Based&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Synopsis&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;Provides conversions between UTF-32, UTF-16 and UTF-8. Doesn't have its own string types. &lt;span&gt;Validates UTF-8 sequences. &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;RapidXML&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Link&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://rapidxml.sourceforge.net"&gt;&lt;span&gt;http://rapidxml.sourceforge.net&lt;/span&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt; &lt;span style="font-weight: bold;"&gt;Properties&lt;/span&gt;&lt;br /&gt;Cross-Platform&lt;br /&gt;Header-Only&lt;br /&gt;Iterator-Based&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Synopsis&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;Very fast parser. Optimized with memory pools. Boost.PropertyTree library uses it as its default xml parser.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;End of log&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-645256207905662641?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/645256207905662641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=645256207905662641&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/645256207905662641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/645256207905662641'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2009/12/interesting-libraries-series-1.html' title='Interesting Libraries Series #1'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-7775373626201622098</id><published>2009-08-19T00:40:00.000-07:00</published><updated>2009-08-19T00:50:08.185-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='programming tools'/><category scheme='http://www.blogger.com/atom/ns#' term='programming languages'/><category scheme='http://www.blogger.com/atom/ns#' term='dll'/><title type='text'>How to create a Visual C++ DLL for implicit linking</title><content type='html'>I will be logging how to create a dynamic link library (DLL) for implicit linking.&lt;br /&gt;&lt;br /&gt;See &lt;a href="http://msdn.microsoft.com/en-us/library/9yd93633.aspx"&gt;MS documentation on DLLs&lt;/a&gt; for further information. &lt;br /&gt;&lt;br /&gt;Problems encountered:&lt;br /&gt;----------------------------&lt;br /&gt;&lt;br /&gt;* dll file wasn't getting generated.&lt;br /&gt;* lib file (import library) wasn't getting generated.&lt;br /&gt;&lt;br /&gt;Solutions:&lt;br /&gt;---------------&lt;br /&gt;&lt;br /&gt;To get the dll file generated, just set the Project/Properties/Configuration Properties/Linker/General/Output File manually.&lt;br /&gt;&lt;br /&gt;To get the lib file generated, use __dllspec(dllexport) on classes and functions like this:&lt;br /&gt;&lt;br /&gt;void __dllspec(dllexport) f(){}&lt;br /&gt;class __dllspec(dllexport) wtf{};&lt;br /&gt;&lt;br /&gt;To generate a static build, use __dllspec(dllimport) instead. &lt;br /&gt;&lt;br /&gt;End of log.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-7775373626201622098?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/7775373626201622098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=7775373626201622098&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/7775373626201622098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/7775373626201622098'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2009/08/how-to-create-visual-c-dll-for-implicit.html' title='How to create a Visual C++ DLL for implicit linking'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-4459459038925933972</id><published>2009-08-10T05:08:00.000-07:00</published><updated>2009-08-10T05:22:15.041-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='twitter'/><title type='text'>Twitter</title><content type='html'>I'm on twitter now. Watch me fail at using it here:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://twitter.com/the_epitaph"&gt;http://twitter.com/the_epitaph&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-4459459038925933972?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/4459459038925933972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=4459459038925933972&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/4459459038925933972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/4459459038925933972'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2009/08/twitter.html' title='Twitter'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-7432275184008670957</id><published>2009-05-27T10:45:00.000-07:00</published><updated>2011-05-31T06:49:22.964-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='programming languages'/><title type='text'>Pseudo-Partial-Function-Template-Specialization in C++</title><content type='html'>In thist post, I will be logging a simple technique to create Pseudo-Partial-Function-Template-Specialization (PPFTS?) in C++.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Rationale:&lt;/span&gt;&lt;br /&gt;* PFTS is a nice thing to have.&lt;br /&gt;* The C++ standard currently does not allow it&lt;br /&gt;* The next C++ standard (C++0x) will allow it, but that's a long time from now.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Motivating example:&lt;/span&gt;&lt;br /&gt;&lt;div class="highlight" style="line-height:1.1em"&gt;&lt;pre&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;strx&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;XType&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;XType&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;stry&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;cstr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"123.12"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;dbl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cstr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Being able to specialize convert&lt;t1,&gt; partially, allowing only one specialization for std::string to act on all types, and so on.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Implementation:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Simply partial specialize a struct with a static member function and call it from the template function.&lt;br /&gt;&lt;br /&gt;&lt;div class="highlight" style="line-height:1.1em"&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="n"&gt;From&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Converter&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;From&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;   &lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;stringstream&lt;/span&gt; &lt;span class="n"&gt;converter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span class="n"&gt;converter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;converter&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Converter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;   &lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;istringstream&lt;/span&gt; &lt;span class="n"&gt;converter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;converter&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt; }&lt;br /&gt;&lt;span class="p"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Converter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt;   &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;   &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;sscanf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"%d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="n"&gt;From&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;From&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;br /&gt; &lt;span class="n"&gt;To&lt;/span&gt; &lt;span class="n"&gt;nrvo&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Converter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;From&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;To&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;::&lt;/span&gt;&lt;span class="n"&gt;convert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;nrvo&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;No overloads. End of log.&lt;/t1,&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-7432275184008670957?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/7432275184008670957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=7432275184008670957&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/7432275184008670957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/7432275184008670957'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2009/05/pseudo-partial-function-template.html' title='Pseudo-Partial-Function-Template-Specialization in C++'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-8345218574456156684</id><published>2008-09-11T11:17:00.000-07:00</published><updated>2008-09-11T12:28:48.773-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='libxml++2'/><category scheme='http://www.blogger.com/atom/ns#' term='Do The Same Series'/><category scheme='http://www.blogger.com/atom/ns#' term='xpath'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='programming languages'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='libcurl'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><category scheme='http://www.blogger.com/atom/ns#' term='csharp'/><title type='text'>Do The Same Series 1 - XmlDocument VERSUS libcurl &amp;&amp; libxml++2</title><content type='html'>In the "Do The Same Series", I am going to explore programming tasks which I perform in C#.NET and try to compare them with C++ alternatives, often involving third party libraries. This will probably end up being the only entry in the series.&lt;br /&gt;&lt;br /&gt;This post is about downloading and querying very specific regions of an xml document easily using xpath. I am going to use the url of an xml file which has currency rates.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C#.NET:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;XmlDocument xml_document= new XmlDocument();&lt;br /&gt;xml_document.Load("http://www.tcmb.gov.tr/kurlar/today.xml");&lt;br /&gt;String xpath= "/Tarih_Date/Currency[@CurrencyCode='USD']/BanknoteBuying";&lt;br /&gt;XmlNode node= xml_document.SelectSingleNode(xpath);&lt;br /&gt;String value= node.InnerText; // gives me the current $/YTL ratio&lt;br /&gt;&lt;br /&gt;Very few lines of code and almost no margin of error. I like C#.NET.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C++ (and libcurl and libxml++2):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There is no short way of doing this. The C++ wrapper for libcurl just introduces overhead with no useful facilities. So I will introduce a few of my own.&lt;br /&gt;&lt;br /&gt;The C API of curl is very sane, giving great flexibility to programmers with C style callbacks. I won't spend time wrapping them to use member functions and such. The function callbacks are ok for now.&lt;br /&gt;&lt;br /&gt;There are two curl options of interest here:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;CURLOPT_WRITEDATA:&lt;/span&gt;&lt;br /&gt;The option which tells curl where the write function will output its data. The default is stdout.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;CURLOPT_WRITEFUNCTION:&lt;/span&gt;&lt;br /&gt;The option which tells curl which funciton to call when it needs to write downloaded data. The default is a function which writes to a file.&lt;br /&gt;&lt;br /&gt;So I can change the writedata to a C++ container and the writefunction to something which appends to that container. I will also write a simple function which takes a url and puts it into the given container.&lt;br /&gt;&lt;br /&gt;namespace pwned{ namespace curl&lt;br /&gt;{&lt;br /&gt;template &amp;lt;typename containerT&amp;gt;&lt;br /&gt;std::size_t output_to_container(void* data, std::size_t size, std::size_t nmemb, void* input)&lt;br /&gt;{&lt;br /&gt; containerT* con= static_cast&amp;lt;containerT*&amp;gt;(input);&lt;br /&gt; char* cstr= static_cast&amp;lt;char*&amp;gt;(data);&lt;br /&gt; std::size_t len= size* nmemb;&lt;br /&gt; // insert will work on any sequence including std::string&lt;br /&gt; try { con-&amp;gt; insert(con-&amp;gt; end(), cstr, cstr+ len); }&lt;br /&gt; catch(...) { return CURLE_WRITE_ERROR; }&lt;br /&gt; return len;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;template &amp;lt;typename containerT&amp;gt;&lt;br /&gt;void set_output_container(CURL* c, containerT &amp;amp;s)&lt;br /&gt;{&lt;br /&gt; curl_easy_setopt(c, CURLOPT_WRITEDATA, &amp;amp;s);&lt;br /&gt; std::size_t(*f)(void*, std::size_t, std::size_t, void*)= output_to_container&amp;lt;containerT&amp;gt;;&lt;br /&gt; curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, f);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;template &amp;lt;typename containerT&amp;gt;&lt;br /&gt;void url_to_container(std::string const &amp;amp;url, containerT &amp;amp;c)&lt;br /&gt;{&lt;br /&gt; CURL* curl= curl_easy_init();&lt;br /&gt; curl_easy_setopt(curl, CURLOPT_URL, url.c_str());&lt;br /&gt; pwned::curl::set_output_container(curl, c);&lt;br /&gt; curl_easy_perform(curl);&lt;br /&gt; curl_easy_cleanup(curl);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;} // curl&lt;br /&gt;} // pwned&lt;br /&gt;&lt;br /&gt;Now, on to xml parsing. The library I chose was libxml++2, a very nice C++ wrapper for libxml2. The only sin of libxml2 is that it can't validate xml, but we are not bothered with schemas right now. The point is, it provides xpath search and can use utf-8 strings from glibmm, so it is as close as they get to .NET's functionality. It is also very accessible on windows and linux. (accompanies gtkmm on win32)&lt;br /&gt;&lt;br /&gt;std::string xml;&lt;br /&gt;pwned::curl::url_to_container("http://www.tcmb.gov.tr/kurlar/today.xml", xml);&lt;br /&gt;xmlpp::DomParser parser;&lt;br /&gt;parser.parse_memory(xml);&lt;br /&gt;std::string xpath= "/Tarih_Date/Currency[@CurrencyCode='USD']/BanknoteBuying";&lt;br /&gt;xmlpp::NodeSet nodes= parser.get_document()-&amp;gt; get_root_node()-&amp;gt; find(xpath);&lt;br /&gt;xmlpp::Element* element= dynamic_cast&amp;lt;xmlpp::Element*&amp;gt;(nodes.at(0));&lt;br /&gt;std::string value= element-&amp;gt; get_child_text()-&amp;gt; get_content();&lt;br /&gt;&lt;br /&gt;On my linux distro I could build and run the test program using:&lt;br /&gt;g++ test.cpp `pkg-config libcurl libxml++2 --cflags --libs` &amp;amp;&amp;amp; ./a.out&lt;br /&gt;&lt;br /&gt;See you next time, should there be one.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-8345218574456156684?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/8345218574456156684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=8345218574456156684&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/8345218574456156684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/8345218574456156684'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2008/09/do-same-series-1-xmldocument-versus.html' title='Do The Same Series 1 - XmlDocument VERSUS libcurl &amp;&amp; libxml++2'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-7095485453382500069</id><published>2008-05-10T13:21:00.000-07:00</published><updated>2008-05-10T14:01:49.544-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming tools'/><category scheme='http://www.blogger.com/atom/ns#' term='asp.net'/><category scheme='http://www.blogger.com/atom/ns#' term='programming languages'/><category scheme='http://www.blogger.com/atom/ns#' term='c#'/><category scheme='http://www.blogger.com/atom/ns#' term='windows service'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><category scheme='http://www.blogger.com/atom/ns#' term='csharp'/><title type='text'>Impersonating users on ASP.NET login is easy</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;Rationale:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I had to write a web interface for controlling a windows service on a server using VS2008, but it took me a few hours of research. So I thought I'd log my experiences.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;Problems:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Website user authentication faking a windows authentication account.&lt;br /&gt;VS2008 not giving access to global.asax file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;Solutions:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First of all, the way I chose to do this was to create an asp.net page with a login control.&lt;br /&gt;1) I created a role (AWESOME)&lt;br /&gt;2) I created a user associated with that role (ASPUSERNAME)&lt;br /&gt;Don't forget to add a reference to System.ServiceProcess&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;So the layout is like:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;loginview&amp;gt;&lt;br /&gt;  &amp;lt;anonymoustemplate&amp;gt;&lt;br /&gt;    &amp;lt;login&amp;gt;&lt;br /&gt;    &amp;lt;/login&amp;gt;&lt;br /&gt;  &amp;lt;/anonymoustemplate&amp;gt;&lt;br /&gt;  &amp;lt;rolegroups&amp;gt;&lt;br /&gt;    &amp;lt;rolegroup roles="AWESOME"&amp;gt;&lt;br /&gt;      &amp;lt;contenttemplate&amp;gt;&lt;br /&gt;        &amp;lt;start button="btnStart" /&amp;gt;&lt;br /&gt;        &amp;lt;stop button="btnStop" /&amp;gt;&lt;br /&gt;      &amp;lt;/contenttemplate&amp;gt;&lt;br /&gt;    &amp;lt;/rolegroup&amp;gt;&lt;br /&gt;  &amp;lt;/rolegroups&amp;gt;&lt;br /&gt;&amp;lt;/loginview&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;On Page_Load I did:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;control= new ServiceController("serviceName");&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;On btnStart_Clicked I did:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;control.Start(); // try/catch&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;On btnStop_Clicked I did:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;control.Stop(); // try/catch&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 102, 255);"&gt;In web.config I did:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;authorization&amp;gt;&lt;br /&gt;  &amp;lt;allow users="ASPUSERNAME" /&amp;gt;&lt;br /&gt;&amp;lt;/authorization&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;authentication mode="Forms" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;rolemanager enabled="true" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;identity impersonate="true" username="MACHINE\USER" password="PASSWORD" /&amp;gt;&lt;br /&gt;&lt;br /&gt;(yes, single '\')&lt;br /&gt;&lt;br /&gt;Now if you coded everything correctly, your project most likely won't build, and give you an error like:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Failed to start monitoring changes to SOMEPATH global.asax because &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);" class="searchTerm"&gt;access&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt; is &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);" class="searchTerm"&gt;denied&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You just have to start VS2008 as administrator. All done.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-7095485453382500069?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/7095485453382500069/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=7095485453382500069&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/7095485453382500069'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/7095485453382500069'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2008/05/impersonating-users-on-aspnet-login-is.html' title='Impersonating users on ASP.NET login is easy'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-1140387274078390784</id><published>2008-01-18T08:51:00.000-08:00</published><updated>2008-01-18T20:44:19.210-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mingw'/><category scheme='http://www.blogger.com/atom/ns#' term='programming tools'/><category scheme='http://www.blogger.com/atom/ns#' term='Qt'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><title type='text'>Compiling and using Qt4.3.3 with mingw g++ 4.2</title><content type='html'>I will be logging my attempt at compiling and using Qt opensource 4.3.3 using mingw.&lt;br /&gt;I got mingw from &lt;a href="http://nuwen.net/mingw.html"&gt;http://nuwen.net/mingw.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Reasons to compile:&lt;br /&gt;==============&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Qt opensource 4.3.3 binaries aren't ABI compatible with g++ 4.2 on my mingw distro, so you get linker errors when building.&lt;/li&gt;&lt;li&gt;Rebuilding Qt with required parameters.&lt;/li&gt;&lt;/ol&gt;Problems encountered:&lt;br /&gt;=================&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Qt 4.3.3 sources had missing forward declarations. &lt;/li&gt;&lt;li&gt;Environment variables caused header file confusion.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Compilation:&lt;br /&gt;=========&lt;br /&gt;&lt;br /&gt;Extract the package and make sure its \bin directory is in PATH.&lt;br /&gt;&lt;br /&gt;I got the latest Qt opensource release from &lt;a href="http://trolltech.com/developer/downloads/qt/windows"&gt;here.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Extract the sources.&lt;br /&gt;&lt;br /&gt;Start cmd.exe and move to the source directory.&lt;br /&gt;&lt;br /&gt;On my platform, the INCLUDE environment variable had the Platform SDK directory,&lt;br /&gt;so Qt build system was finding the wrong Windows.h. To clean things up, I did:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;set include=&lt;br /&gt;set lib=&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Qt 4.3.3 sources actually had a couple of errors. For this version I had to do the following:&lt;br /&gt;&lt;br /&gt;Edit \src\corelib\kernel\qeventdispatcher_win.cpp&lt;br /&gt;A forward declaration is missing. Add it after the #includes:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;LRESULT CALLBACK qt_internal_proc(HWND, UINT, WPARAM, LPARAM);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Edit \src\gui\inputmethod\qwininputcontext_win.cpp&lt;br /&gt;A forward declaration is missing. Add it after the #includes:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;bool qt_sendSpontaneousEvent(QObject*, QEvent*);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Run&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;configure.exe -platform win32-g++&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;and any additional parameters you would like with configure.&lt;br /&gt;That should give you a Makefile.&lt;br /&gt;&lt;br /&gt;This will be a long compilation, I've used:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;make -j 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In my case this process resulted in debug and release shared&lt;br /&gt;libraries and import libraries in \lib and \bin directories.&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;====&lt;br /&gt;&lt;br /&gt;The qmake which is built by this process will have the build directory hardcoded,&lt;br /&gt;so make sure that you build it in the correct directory.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-1140387274078390784?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/1140387274078390784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=1140387274078390784&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/1140387274078390784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/1140387274078390784'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2008/01/compiling-and-using-qt433-with-mingw-g.html' title='Compiling and using Qt4.3.3 with mingw g++ 4.2'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-6510869732331012147</id><published>2007-11-23T08:44:00.000-08:00</published><updated>2008-07-01T21:11:43.344-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='mingw'/><category scheme='http://www.blogger.com/atom/ns#' term='programming tools'/><category scheme='http://www.blogger.com/atom/ns#' term='msvc'/><category scheme='http://www.blogger.com/atom/ns#' term='programming languages'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><title type='text'>SQLite 3 on windows with mingw and vc2005</title><content type='html'>I will be logging my attempt to make use of SQLite 3 on windows.&lt;br /&gt;&lt;br /&gt;If you want to write programs and link them to sqlite using mingw or msvc, first you need to download the binaries from sqlite's website: &lt;a href="http://sqlite.org/download.html"&gt;http://sqlite.org/download.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Download the dll binary, extract it somewhere.&lt;br /&gt;You will find one .dll and one .def file.&lt;br /&gt;&lt;br /&gt;The def file and the dll file together can be used to create an import library on windows.&lt;br /&gt;There are two ways of accomplishing this. Using msvc or using mingw.&lt;br /&gt;&lt;br /&gt;With msvc:&lt;br /&gt;==========&lt;br /&gt;1) Start a visual studio 2005 command prompt, move to our directory.&lt;br /&gt;2) Give the command: lib /def:sqlite3.def /machine:X86&lt;br /&gt;(your machine may vary)&lt;br /&gt;&lt;br /&gt;With mingw:&lt;br /&gt;===========&lt;br /&gt;1) Edit sqlite3.def and to the beginning add: LIBRARY sqlite3.dll ( otherwise the import library won't know what dll it requires at runtime, default is (null).dll )&lt;br /&gt;2) Issue command: dlltool -d sqlite3.def -l libsqlite3.dll.a&lt;br /&gt;3) You won't even need an import library anyway, since the linker can use a dll directly.&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;=====&lt;br /&gt;If you issue: g++ prog.cpp -l sqlite3&lt;br /&gt;First, a libsqlite3.dll.a is searched for.&lt;br /&gt;Then a libsqlite3.a is searched for.&lt;br /&gt;Then sqlite3.dll will be searched for.&lt;br /&gt;Sometimes mingw can't link dlls. I don't know the details, but it worked for me in this case.&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;=====&lt;br /&gt;If you already have a vc2005 .lib file, you can just rename it to libsqlite3.dll.a and use it with mingw. There are no symbol name mangling conflicts thanks to extern "C".&lt;br /&gt;&lt;br /&gt;Header File:&lt;br /&gt;============&lt;br /&gt;Now all you need is the sqlite3.h file. It is standalone and only includes C headers. It can be found within the sqlite source download or the cvs. Mine was named sqlite3.h.in, I just renamed it and copied it over.&lt;br /&gt;&lt;br /&gt;Now for some sqlite3:&lt;br /&gt;=====================&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;sqlite.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;string&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #800000;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; main()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3* db;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; result= sqlite3_open(&lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"test.db"&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &amp;amp;db);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt;(result!= SQLITE_OK) { std::cerr&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"Error opening test.db&lt;/span&gt;&lt;span style="color: #ff00ff;"&gt;\n&lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;; return 1; }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_stmt* s;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; std::string q= &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"create table isimler(no int, ad text, soyad text)"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_prepare_v2(db, q.c_str(), q.size(), &amp;amp;s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_step(s);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_reset(s);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; q= &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"insert into isimler(no, ad, soyad) values(?, :ad, :soyad)"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_prepare_v2(db, q.c_str(), q.size(), &amp;amp;s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #800000;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; no= &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;; std::string ad= &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"nurettin ali"&lt;/span&gt;&lt;span style="color: #000000;"&gt;, soyad= &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"berkol"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_bind_int(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;, no);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_bind_text(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;2&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ad.c_str(), ad.size(), SQLITE_STATIC);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_bind_text(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;3&lt;/span&gt;&lt;span style="color: #000000;"&gt;, soyad.c_str(), soyad.size(), SQLITE_STATIC);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_step(s);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_reset(s);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; no= &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;2&lt;/span&gt;&lt;span style="color: #000000;"&gt;; ad= &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"yesari asim"&lt;/span&gt;&lt;span style="color: #000000;"&gt;; soyad= &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"arsoy"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_bind_int(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;, no);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_bind_text(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;2&lt;/span&gt;&lt;span style="color: #000000;"&gt;, ad.c_str(), ad.size(), SQLITE_STATIC);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_bind_text(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;3&lt;/span&gt;&lt;span style="color: #000000;"&gt;, soyad.c_str(), soyad.size(), SQLITE_STATIC);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_step(s);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_reset(s);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_clear_bindings(s);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; q= &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"select no, ad, soyad from isimler"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_prepare_v2(db, q.c_str(), q.size(), &amp;amp;s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;while&lt;/span&gt;&lt;span style="color: #000000;"&gt;(sqlite3_step(s)== SQLITE_ROW)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  std::cout&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;   &amp;lt;&amp;lt; sqlite3_column_int(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;" | "&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;   &amp;lt;&amp;lt; sqlite3_column_text(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;" | "&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;   &amp;lt;&amp;lt; sqlite3_column_text(s, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;2&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"&lt;/span&gt;&lt;span style="color: #ff00ff;"&gt;\n&lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_finalize(s);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt; sqlite3_close(db);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-6510869732331012147?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/6510869732331012147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=6510869732331012147&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/6510869732331012147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/6510869732331012147'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2007/11/sqlite-3-on-windows-with-mingw-and.html' title='SQLite 3 on windows with mingw and vc2005'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-2121866574921072163</id><published>2007-10-07T01:57:00.000-07:00</published><updated>2007-10-13T20:52:06.581-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mingw'/><category scheme='http://www.blogger.com/atom/ns#' term='programming tools'/><category scheme='http://www.blogger.com/atom/ns#' term='SDL'/><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><title type='text'>Building SDL from cygwin using mingw (no stdio redirection)</title><content type='html'>I will be logging my successful attempt at building SDL from cygwin using mingw on windows vista.&lt;br /&gt;The process was simple enough, the only thing you need to do is to install mingw properly and give correct parameters to the configure script.&lt;br /&gt;&lt;br /&gt;Install mingw. I used the mingw distro from &lt;a href="http://nuwen.net/mingw.html"&gt;http://nuwen.net/mingw.html&lt;/a&gt;&lt;br /&gt;Set up PATH as described and make sure gcc -dumpversion  works properly when you open a commandline.&lt;br /&gt;&lt;br /&gt;At the time of writing this, the output was:&lt;br /&gt;&lt;blockquote&gt;4.2.1-dw2&lt;/blockquote&gt;Install a minimal cygwin.&lt;br /&gt;Start cygwin commandline and make sure gcc -dumpversion gives the same result.&lt;br /&gt;Download and extract SDL sources from &lt;a href="http://libsdl.org/"&gt;http://libsdl.org&lt;/a&gt;&lt;br /&gt;In the cygwin commandline, move to the directory SDL sources are.&lt;br /&gt;Make a build directory as usual, so that our attempt remains separate from other building attempts and we won't have to clean up the next time we build from this source.&lt;br /&gt;&lt;br /&gt;Something like:&lt;br /&gt;&lt;blockquote&gt;mkdir cygwinmingwbuild&lt;/blockquote&gt;Now move into that directory and if you want to build SDL without stdio redirection, type:&lt;br /&gt;&lt;blockquote&gt;../configure --build=i686-pc-mingw32 --host=i686-pc-mingw32 --enable-stdio-redirect=no&lt;/blockquote&gt;And any other flags that you desire, but try not to break the build at your first try. Omit the --enable flag if you want redirection.&lt;br /&gt;Hopefully your system is fast enough and you won't get "out of synch" errors from cygwin.&lt;br /&gt;Don't mind if you get a warning about configure.in being old, and you will get the static and shared libraries under:&lt;br /&gt;&lt;br /&gt;cygwinmingwbuild/build&lt;br /&gt;cygwinmingwbuild/build/.libs&lt;br /&gt;&lt;br /&gt;From these directories you need:&lt;br /&gt;libSDLmain.a&lt;br /&gt;libSDL.a&lt;br /&gt;libSDL.dll.a&lt;br /&gt;SDL.dll&lt;br /&gt;&lt;br /&gt;libSDL.dll.a is searched by default if you aren't statically linking.&lt;br /&gt;libSDL.a is for -static linking&lt;br /&gt;&lt;br /&gt;You may want to&lt;br /&gt;&lt;blockquote&gt;strip libSDL*&lt;br /&gt;strip SDL.dll&lt;br /&gt;upx SDL.dll&lt;br /&gt;&lt;/blockquote&gt;If you want smaller binaries, but that's not going to speed anything up.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-2121866574921072163?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/2121866574921072163/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=2121866574921072163&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/2121866574921072163'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/2121866574921072163'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2007/10/buiding-sdl-from-cygwin-using-mingw-no.html' title='Building SDL from cygwin using mingw (no stdio redirection)'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-4624972206677309727</id><published>2007-09-23T08:32:00.000-07:00</published><updated>2007-11-23T10:16:56.367-08:00</updated><title type='text'>boost::function and SDL timer callbacks:</title><content type='html'>I will be describing how to wrap SDL timer callback API using boost.function.&lt;br /&gt;Thankfully, after version 1.2.7, SDL timer callback signature has a void* where you can pass any kind of data. Same applies to most sane C APIs. But of course C++ programmers also require type safety and the ability of passing member functions as callbacks.&lt;br /&gt;&lt;br /&gt;A simple solution would be:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;typedef&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; boost::function&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;()&amp;gt; f_type;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Uint32 add_timer_helper(Uint32 interval, &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;* p)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  f_type* fp= &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;static_cast&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;lt;f_type*&amp;gt;(p);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  (*fp)();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; interval;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;SDL_TimerID add_timer(f_type &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;const&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &amp;amp;f, Uint32 interval)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  SDL_TimerID id= SDL_AddTimer(interval, add_timer_helper,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;                               &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;const_cast&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;*&amp;gt;(&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;static_cast&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;const&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;*&amp;gt;(&amp;amp;f)));&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;  &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);"&gt;return&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; id;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;However, this requires you to store a boost::function instance and keep it alive until it is no more called. Since it is not practical to change the value of this stored boost function, we can store the added boost function callbacks somewhere and not care about them.&lt;br /&gt;&lt;br /&gt;Since we don't want to store them by copy and we want to erase the function by timer id, it is a logical choice to store them in a boost::ptr_map. I placed this map inside a class. It probably needs to go into a singleton, but that's up to the reader.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;ostream&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;cassert&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;map&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;boost/function.hpp&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;boost/bind.hpp&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;boost/ptr_container/ptr_map.hpp&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;SDL.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;namespace&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;struct&lt;/span&gt;&lt;span style="color: #000000;"&gt; sdl_timer&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;typedef&lt;/span&gt;&lt;span style="color: #000000;"&gt; boost::function&amp;lt;&lt;/span&gt;&lt;span style="color: #800000;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt;()&amp;gt; f_type;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;typedef&lt;/span&gt;&lt;span style="color: #000000;"&gt; boost::ptr_map&amp;lt;SDL_TimerID, f_type&amp;gt; cb_map;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    cb_map cb;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #800000;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; Uint32 add_timer_helper(Uint32 interval, &lt;/span&gt;&lt;span style="color: #800000;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt;* p)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      f_type* fp= &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;static_cast&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;f_type*&amp;gt;(p);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      (*fp)();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; interval;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    SDL_TimerID add(f_type &lt;/span&gt;&lt;span style="color: #800000;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &amp;amp;f, Uint32 interval)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      f_type* fp= &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; f_type(f);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      SDL_TimerID id= SDL_AddTimer(interval, add_timer_helper, fp);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      cb.insert(id, fp);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; id;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #800000;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; remove(SDL_TimerID id)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      SDL_RemoveTimer(id);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      cb.erase(id);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #800000;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; change(f_type &lt;/span&gt;&lt;span style="color: #800000;"&gt;const&lt;/span&gt;&lt;span style="color: #000000;"&gt; &amp;amp;f, Uint32 interval, SDL_TimerID &amp;amp;id)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      remove(id);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      id= add(f, interval);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  } timer_api;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;struct&lt;/span&gt;&lt;span style="color: #000000;"&gt; wtf&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  SDL_TimerID id1, id2;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #800000;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; f(){ std::cout&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"wtf::f()"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&amp;lt; std::endl; }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #800000;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; g(){ std::cout&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"wtf::g()"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&amp;lt; std::endl; }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #800000;"&gt;void&lt;/span&gt;&lt;span style="color: #000000;"&gt; h(){ std::cout&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"wtf::h()"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&amp;lt; std::endl; }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #800000;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; main(&lt;/span&gt;&lt;span style="color: #800000;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #800000;"&gt;char&lt;/span&gt;&lt;span style="color: #000000;"&gt;*[])&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  std::ios::sync_with_stdio(&lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;false&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #800000;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; err= SDL_Init(SDL_INIT_TIMER| SDL_INIT_VIDEO);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  assert(err== &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  SDL_Surface* vid= SDL_SetVideoMode(&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;640&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;480&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;32&lt;/span&gt;&lt;span style="color: #000000;"&gt;, SDL_SWSURFACE);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  assert(vid!= &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  wtf w;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  w.id1= timer_api.add(boost::bind(&amp;amp;wtf::f, &amp;amp;w), &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  w.id2= timer_api.add(boost::bind(&amp;amp;wtf::h, &amp;amp;w), &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  SDL_Delay(&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;2000&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  timer_api.change(boost::bind(&amp;amp;wtf::g, &amp;amp;w), &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;1000&lt;/span&gt;&lt;span style="color: #000000;"&gt;, w.id1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  SDL_Delay(&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;2000&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  timer_api.remove(w.id1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  timer_api.remove(w.id2);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  SDL_Quit();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="font-weight: bold;color: #000000;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; EXIT_SUCCESS;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: normal;font-size:85%;" &gt;So now we can add and remove timers as well as switch callback functions.&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-4624972206677309727?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/4624972206677309727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=4624972206677309727&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/4624972206677309727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/4624972206677309727'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2007/09/boostfunction-and-sdl-timer-callbacks.html' title='boost::function and SDL timer callbacks:'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-3597555613372461623</id><published>2007-09-15T23:01:00.001-07:00</published><updated>2007-11-23T10:18:45.265-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='programming languages'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><title type='text'>#define dependent lines in C++</title><content type='html'>This is an attempt at creating a macro dependent scope using boost preprocessor. The lines within this scope won't be executed unless a certain macro is defined. I also introduced a small macro to log expressions if NDEBUG is not defined.&lt;br /&gt;&lt;br /&gt;Note that any expression which has a comma in it will be processed as separate macro arguments, so the parenthesis around such an expression is neccessary. I did all this because I thought&lt;br /&gt;&lt;br /&gt;#ifdef MACRO&lt;br /&gt;  specific code here&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;Scopes, in my opinion, looked ugly compared to&lt;br /&gt;DEBUG_CODE&lt;br /&gt;(&lt;br /&gt;  specific code here&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;ostream&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;iomanip&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;ios&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;boost/preprocessor/stringize.hpp&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;boost/preprocessor/facilities/is_empty.hpp&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#include &amp;lt;boost/preprocessor/control/if.hpp&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#define MACRO_DEPENDENT(m, c) \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;BOOST_PP_IF(BOOST_PP_IS_EMPTY(m),,c)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#define DEBUG_CODE(l) \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;MACRO_DEPENDENT(NDEBUG,l)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#define CLOG_EXPR(v)                                \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;(::std::clog                                      \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;  &amp;lt;&amp;lt; ::std::boolalpha                             \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;  &amp;lt;&amp;lt; ( "( " BOOST_PP_STRINGIZE(v) " ) = " )       \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;  &amp;lt;&amp;lt; (v)                                          \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;  &amp;lt;&amp;lt; ::std::endl);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#define DEBUG_CLOG_EXPR(c) \&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;DEBUG_CODE(CLOG_EXPR(c))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #800000;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; main()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #800000;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; n= &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;42&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#define NDEBUG&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;  DEBUG_CODE&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      (&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;       (std::cout&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"This will not show up"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&amp;lt; std::endl);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #008000;"&gt;#undef NDEBUG&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      DEBUG_CLOG_EXPR(n + &lt;/span&gt;&lt;span style="color: #0000ff;"&gt;42&lt;/span&gt;&lt;span style="color: #000000;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      DEBUG_CODE&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      (&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;       (std::cout&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"DEBUG_CODE, line 1"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&amp;lt; std::endl); &lt;/span&gt;&lt;span style="font-style: italic;color: #808080;"&gt;// beware the comma&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      (std::cout&amp;lt;&amp;lt; &lt;/span&gt;&lt;span style="color: #dd0000;"&gt;"DEBUG_CODE, line 2"&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&amp;lt; std::endl);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;      )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-3597555613372461623?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/3597555613372461623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=3597555613372461623&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/3597555613372461623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/3597555613372461623'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2007/09/code-test.html' title='#define dependent lines in C++'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-43040984849297791</id><published>2007-08-21T01:12:00.000-07:00</published><updated>2008-10-14T02:54:32.485-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='mingw'/><category scheme='http://www.blogger.com/atom/ns#' term='programming tools'/><category scheme='http://www.blogger.com/atom/ns#' term='programming languages'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><category scheme='http://www.blogger.com/atom/ns#' term='gtkmm'/><title type='text'>How to set up gtkmm on windows vista easily:</title><content type='html'>&lt;span style="font-family:arial;"&gt;I will be logging how to set up gtkmm for programming on windows vista. This will only work on a win32 platform.&lt;br /&gt;&lt;br /&gt;To install gtkmm, first you need the gtk+ development libraries.&lt;br /&gt;Latest version can be found in the &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=98754&amp;package_id=111411"&gt;sourceforge archives&lt;/a&gt;.&lt;br /&gt;And install it.&lt;br /&gt;&lt;br /&gt;Next you need the gtkmm development libraries.&lt;br /&gt;Latest version can be found on the &lt;a href="http://ftp.gnome.org/pub/gnome/binaries/win32/gtkmm/"&gt;gnome ftp site&lt;/a&gt;.&lt;br /&gt;And install it to the default directory. It should default to the place you installed gtk+.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Working with MinGW and gtkmm from the commandline in Windows Vista:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;I use the mingw distro from &lt;a href="http://nuwen.net/mingw.html"&gt;nuwen.net&lt;/a&gt;&lt;br /&gt;Just install it to C:\MinGW and add C:\MinGW\bin to your PATH variable.&lt;br /&gt;&lt;br /&gt;Now if you want to get gtkmm to work from the commandline, you need to set up your PKG_CONFIG_PATH.&lt;br /&gt;The value should be (install path)&lt;installation dir=""&gt;\lib\pkgconfig  where all the *.pc files are.&lt;br /&gt;&lt;br /&gt;Start a new command prompt and you should be able to get the output from&lt;br /&gt;&lt;span style="font-style: italic;"&gt;pkg-config --list-all&lt;/span&gt;&lt;br /&gt;Find the latest gtkmm version from that list, mine was gtkmm-2.4 so I used:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;pkg-config gtkmm-2.4 --cflags --libs&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This gave me all the include/linker flags neccessary to build gtkmm programs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/installation&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-43040984849297791?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/43040984849297791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=43040984849297791&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/43040984849297791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/43040984849297791'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2007/08/how-to-set-up-gtkmm-on-windows-vista_21.html' title='How to set up gtkmm on windows vista easily:'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-8682011120637206171</id><published>2007-08-19T08:23:00.001-07:00</published><updated>2007-08-20T05:48:09.657-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='ode'/><category scheme='http://www.blogger.com/atom/ns#' term='programming languages'/><category scheme='http://www.blogger.com/atom/ns#' term='programming libraries'/><title type='text'>Open Dynamics Engine (ODE) basics:</title><content type='html'>I am logging the basics I learned about using &lt;a href="http://www.ode.org/"&gt;ODE&lt;/a&gt; in my programs which need rigid body physics. I encountered a few problems when reading &lt;a href="http://artis.imag.fr/Membres/Xavier.Decoret/resources/ode/tutorial1.html"&gt;online tutorials&lt;/a&gt; and &lt;a href="http://www.ode.org/ode-latest-userguide.html"&gt;documentation&lt;/a&gt;, so I decided to write my own introduction to ODE. As you read this introduction, you need to keep the documentation open.&lt;br /&gt;&lt;br /&gt;The documentation had a list of steps the &lt;a href="http://www.ode.org/ode-latest-userguide.html#sec_3_10_0"&gt;programmer needs to take&lt;/a&gt; in order to write a typical simulation, but I had to jump around in the documentation as I tried to gather the functions to accomplish these steps.&lt;br /&gt;&lt;br /&gt;For a typical simulation, it is a good idea to use ODE in this manner:&lt;br /&gt;&lt;br /&gt;//Create a physics world.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dWorldID world= dWorldCreate();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//Create bodies in the world.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dBodyID ball= dBodyCreate(world);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/*Note:&lt;br /&gt;A body is used for associating a mass with a geometry. If you don't set a geometry's body, it will have a body without a custom mass. I don't know the specifics of what kind of mass a geometry has by default. Perhaps none.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//Create masses for the bodies.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;dMass ball_mass;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dMassSetSphereTotal(&amp;ball_mass, 10, 40);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dBodySetMass(ball, ball_mass);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/*Note:&lt;br /&gt;When body masses are set, they will be affected by gravity, momentum and impulse during simulation steps.&lt;br /&gt;&lt;br /&gt;The documentation does not mention units of mass here.&lt;br /&gt;&lt;br /&gt;Search the documentation for dMassSet* to see what kinds of masses you can apply to bodies and how you can rotate/translate them.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//Create a collision space.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dSpaceID collision_space= dSimpleSpaceCreate(0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/*Note:&lt;br /&gt;See documentation for other space create functions.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//Create geometries for the bodies in the collision space.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dGeomID ball_geom= dCreateSphere(collision_space, 40.f);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//Create geometries which aren't attached to any body as needed, also in the //collision space.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dGeomID platform_geom= dCreateBox(collision_space, 100.f, 40.f, 0.f);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/*Note:&lt;br /&gt;See documentation for other dCreate* functions&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//You need to set the starting positions.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dGeomSetPosition(ball_geom, 320.f, 50.f, 0.f);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dGeomSetPosition(platform_geom, 320.f, 430.f, 0.f);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/*Note:&lt;br /&gt;This function puts the geometry into a position where the geometric middle stands on the given arguments. ODE knows the geometric middle of predefined geometries.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//You need to set error reduction and constraint force mixing parameters.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dWorldSetERP(0.9);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dWorldSetCFM(0.00001);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/*Note:&lt;br /&gt;The documentation details these functions If you set them to these extremes, the simulation may not behave correctly. If you set them to more normalized values, the simulation becomes sluggish and inexact. Which also means it won't behave correctly. In short, you need to tweak until you get something similar to what you want.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//If needed, set the gravitational acceleration vector. All masses will accelerate.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dWorldSetGravity(world, 0.f, -9.81f, 0.f);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;/*Note:&lt;br /&gt;Now the world has a ball, a 2D box and approximately earth's acceleration. Gravity won't affect the box, because it is just a geometry and has no body. So it is just a platform hanging there. Its only effect is to provide a static rigid body for collisions. How to do collisions follows.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//Create a contact joint group.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dJointGroupID contact_joint_group= dJointGroupCreate(0);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/*Note:&lt;br /&gt;joint group is a container of joints. You can add joints into it, or empty it. This will be useful for storing contact joints which just give the collision dynamics effect.&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;//Apply a collision callback function to every geometry in the space which is //likely to collide.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dSpaceCollide(collision_space, void_pointer_parameter, collision_callback);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;/*Note:&lt;br /&gt;The other option was to call dCollide for every geometry in space, which would end up with&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;Inside the callback function, you prepare a number of contact informations and check if two geometries collided. If they did, the information will be pushed into the contact informations.&lt;br /&gt;&lt;br /&gt;signature:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;void (*)(void* p, dGeomID g1, dGeomID g2)&lt;/span&gt;&lt;br /&gt;inside:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dContact contacts[10]; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;for(int i= 0; i&lt;&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  contact[i].surface.mode = dContactBounce;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  contact[i].surface.mu = .0f;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  contact[i].surface.bounce = .5f;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  contact[i].surface.bounce_vel = .0f;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Each contact is bouncy, has a surface friction of 0, things which bounce off this surface will retain half their energy and the minimum velocity for bouncing off each contact is 0. If you don't set bounce_vel for each potential contact, your colliding body probably won't bounce. This was not done in one of the tutorials, so nothing bounced when I tried getting the code to work.&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int n_contacts= dCollide(g1, g2, 10, &amp;contact[0].geom, sizeof(dContact));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;This will figure out how many contact points exist in between the geometries g1 and g2. sizeof(dContact) is the number of bytes between the address of each contiguous contact's geometries. They probably left this function relaxed so that the collision data structure is customizable.&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;Joints are attached between bodies, so we get the bodies of the geometries.&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dBodyID b1= dGeomGetBody(g1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dBodyID b2= dGeomGetBody(g2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;for(int i= 0; i&lt;&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  dJointID contact_joint= &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    dJointCreateContact( WORLDID, CONTACT_JOINT_GROUP, &amp;contact[i])&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;  dJointAttach(contact_joint, b1, b2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;The world ID and contact joint group ID somehow need to be passed into this function. It is up to the programmer to make use of the void* parameter of the callback or global variables.&lt;br /&gt;&lt;br /&gt;So dSpaceCollide called the collision callback for potential collisions, which checked if the geometries really collided and if they did, got the contact information, which is used to create contact joints in the contact group.&lt;br /&gt;&lt;br /&gt;Next action is to take a simulation step.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dWorldStep(0.03);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;See the world step functions for details on the argument and other function choices.&lt;br /&gt;&lt;br /&gt;So the simulation will happen with the contact joints connected to some bodies. The forces will be applied, etc. If the joints remain connected when you take another simulation step, the bodies will remain attached and won't be able to separate. Se after taking a simulation step, the contact joints must be removed.&lt;br /&gt;&lt;br /&gt;Easiest way is to empty the contact joint group:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dJointGroupEmpty(contact_joint_group);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;And so on. Continue stepping the simulation with these three functions:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dSpaceCollide(collision_space, void_pointer_parameter, collision_callback);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dWorldStep(n);&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;dJointGroupEmpty(contact_joint_group);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;Every step, the geometry coordinates can be accessed:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;dReal const* ball_pos= dGeomGetPosition(ball_geom);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;This log ends here. I will post a complete example if neccessary.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-8682011120637206171?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/8682011120637206171/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=8682011120637206171&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/8682011120637206171'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/8682011120637206171'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2007/08/open-dynamics-engine-ode-basics.html' title='Open Dynamics Engine (ODE) basics:'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-474731956337179291.post-6709325995606065108</id><published>2007-08-19T08:23:00.000-07:00</published><updated>2007-08-19T09:00:16.279-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IDE'/><category scheme='http://www.blogger.com/atom/ns#' term='programming tools'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><title type='text'>code::blocks on debian lenny</title><content type='html'>I am logging my attempt at creating binary packages for code::blocks svn build 4402. This will only work for i386 and amd64 architectures.&lt;br /&gt;&lt;br /&gt;Problems I encountered:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;g++-4.1 segfaulted (ICE) on a certain file. It is a reproducable bug which I was too lazy to file. So use g++-4.2, it is in lenny.&lt;/li&gt;&lt;li&gt;Package dependencies weren't set up correctly, I had to edit debian build scripts. The build will stop with a missing header if you try to build with wxgtk2.6.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;You need the codeblocks sources. &lt;a href="http://developer.berlios.de/svn/?group_id=5358"&gt;This page&lt;/a&gt; shows how to check out the svn repository.&lt;br /&gt;&lt;tt&gt;&lt;br /&gt;&lt;blockquote&gt;svn checkout svn://svn.berlios.de/codeblocks/trunk&lt;/blockquote&gt;&lt;/tt&gt;&lt;br /&gt;Then edit the &lt;span style="font-style: italic;"&gt;debian/control&lt;/span&gt; script under trunk. Change all:&lt;br /&gt;libwxgtk2.6-dev        -&gt;   libwxgtk2.8-dev&lt;br /&gt;libstdc++6-4.0-dev   -&gt;   libstdc++6-4.2-dev&lt;br /&gt;&lt;br /&gt;Debian lenny or sid don't have wxgtk2.8, wxwidgets website &lt;a href="http://www.wxwidgets.org/downloads/"&gt;tells you&lt;/a&gt; to add this repository to your apt sources:&lt;br /&gt;&lt;blockquote&gt;deb http://apt.tt-solutions.com/debian/ etch main&lt;/blockquote&gt;&lt;br /&gt;edit /etc/apt/sources.list to add this line. The page also shows an ubuntu repository for the library.&lt;br /&gt;&lt;br /&gt;Now update:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sudo aptitude update&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;You need these installed:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sudo aptitude install libwxgtk2.8-dev devscripts libtool autoconf g++-4.2 -y&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Make sure your g++ symlink points at g++-4.2&lt;br /&gt;&lt;span style="font-style: italic;"&gt;ls -l /usr/bin/g++&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If it shows g++-4.1, remove the symlink and make it point at g++-4.2:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sudo rm /usr/bin/g++&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sudo ln -s /usr/bin/g++ /usr/bin/g++-4.2&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;Now start building. First bootstrap (create configure script, etc.) then build debs.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;./bootstrap&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;debuild&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;This took a long time on my single processor amd64 box, but it completed. Not bad for amd on summer.&lt;span style="font-style: italic;"&gt; &lt;/span&gt;Now go to the directory above and install the packages.&lt;br /&gt;&lt;span style="font-style: italic;"&gt;cd ..&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sudo dpkg -i *deb&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And you're most likely done. &lt;br /&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/474731956337179291-6709325995606065108?l=voidpage.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://voidpage.blogspot.com/feeds/6709325995606065108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=474731956337179291&amp;postID=6709325995606065108&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/6709325995606065108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/474731956337179291/posts/default/6709325995606065108'/><link rel='alternate' type='text/html' href='http://voidpage.blogspot.com/2007/08/codeblocks-on-debian-lenny.html' title='code::blocks on debian lenny'/><author><name>Nurettin Onur</name><uri>http://www.blogger.com/profile/08366872774642860189</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_LPUBbSy5__U/SMl4BW-kfUI/AAAAAAAAAA0/rxBwXF9rb6I/S220/gendo3.jpg'/></author><thr:total>0</thr:total></entry></feed>
