Extract the sources to some folder, open the command prompt and go to that directory.
Then enter following commands…
> bootstrap.sh > bjam.exe --toolset=msvc --link=static --runtime-link=static --build-type=complete stage
Extract the sources to some folder, open the command prompt and go to that directory.
Then enter following commands…
> bootstrap.sh > bjam.exe --toolset=msvc --link=static --runtime-link=static --build-type=complete stage
Boost::format’s performance sucks.
I used boost::format in an inner loop in my project, and the optimized runtime was 20 seconds for 1 small case.
I optimized away boost::format by replacing it with stream manipulators and i got the runtime down to 2 seconds for the same case.
I’ll publish an article later on the details on how to do this.
I always forget how to use boost::format when I need it. So, here are a few samples from when I did remember.
Only need is to include the proper boost header. No compile of any of the boost libraries is necessary.
The source is also available in subversion (webclient) (subversion checkout).
// build with make or:
//
// g++ -I../../boost_1_46_0 fmt.cpp
//
#include <iostream>
#include <sstream>
#include <boost/format.hpp>
using namespace std;
using namespace boost;
int main()
{
stringstream ss;
int year = 2011;
int month = 3;
int day = 11;
int hour = 12;
int minute = 1;
double seconds= 23.35;
double epoch = 1231234567890.35;
// Fill with whitespace, right align
ss << format("#1.0 %4i %4i %4i\n") % year % month % day;
// Output: #1.0 2011 3 11
// Fill with whitespace, left align
ss << format("#1.1 %-4i %-4i %-4i\n") % year % month % day;
// Output: #1.1 2011 3 11
// Fill with zero (pad)
ss << format("#2.0 %04i %04i %04i\n") % year % month % day;
// Output: #2.0 2011 0003 0011
// Floating point precision
ss << format("#3.0 %11.2f\n") % seconds;
// Output: #3.0 23.35
// Floating point precision with zero-fill (zero pad)
ss << format("#4.0 %011.2f\n") % seconds;
// Output: #4.0 00000023.35
// Left aligned string literal with 30+20 columns
ss << format("#5.0 %-30s%-20s\n") % "LEFT ALIGNED 1" % "LEFT ALIGNED 2";
// Output: #5.0 LEFT ALIGNED 1 LEFT ALIGNED 2
// Right aligned string literal
ss << format("#6.0 %30s%20s\n") % "RIGHT ALIGNED 1" % "RIGHT ALIGNED 2";
// Output: #6.0 RIGHT ALIGNED 1 RIGHT ALIGNED 2
cout << ss.str();
return 0;
}
The output should be:
#1.0 2011 3 11 #1.1 2011 3 11 #2.0 2011 0003 0011 #3.0 23.35 #4.0 00000023.35 #5.0 LEFT ALIGNED 1 LEFT ALIGNED 2 #6.0 RIGHT ALIGNED 1 RIGHT ALIGNED 2
This is a reminder to myself.
To sort a collection of non-POD types (not Plain Old Data) with STL we need to tell it how to sort these objects.
To the std::sort method we simply supply a predicate! It’s just a method taking 2 arguments of that type and apply our logic to tell if the first argument is lesser than the last argument. With templates it becomes a little more complex, but still it’s very simple when you know how it works.
Here is some sample code:
#include <iostream> // Provides cout
#include <vector> // Provides our basic container
#include <algorithm> // Provides std::sort
using namespace std;
// Structures I'll sort with 1 template function
//
//
struct A
{
A(size_t i, size_t t) : id(i), time(t), other_data(false){}
size_t id;
size_t time;
bool other_data;
};
struct B
{
B(size_t i, size_t t) : id(i), time(t), other_data("string data"){}
size_t id;
size_t time;
string other_data;
};
struct C
{
C(size_t i, size_t t) : id(i), time(t), other_data("character array data"){}
size_t id;
size_t time;
char* other_data;
};
// Our predicate
//
template<typename CLASS>
bool timeSortPredicate( const CLASS &a, const CLASS &b )
{
return a.time < b.time;
}
template<typename CLASS>
bool idSortPredicate( const CLASS &a, const CLASS &b )
{
return a.id < b.id;
}
// Our collection printer
//
template<typename CLASS>
void print( const CLASS &c )
{
typedef typename CLASS::const_iterator cit;
for ( cit it = c.begin(); it != c.end(); ++it )
{
cout << it->id << " " << it->time << endl;
}
}
int main()
{
// Construct the objects ... tedious I know
A a1(1,15), a2(2,20), a3(3,14);
B b1(3,4), b2(2,10), b3(1,12);
C c1(11,0), c2(12,0), c3(13,0);
// Construct collections
vector<A> alist;
alist.push_back(a1);
alist.push_back(a2);
alist.push_back(a3);
vector<B> blist;
blist.push_back(b1);
blist.push_back(b2);
blist.push_back(b3);
vector<C> clist;
clist.push_back(c1);
clist.push_back(c2);
clist.push_back(c3);
// Print stuff
cout << "Collection A" << endl;
print(alist);
cout << "Collection B" << endl;
print(blist);
cout << "Collection C" << endl;
print(clist);
cout << "Sorting collections by time" << endl;
sort(alist.begin(), alist.end(), timeSortPredicate<A> );
sort(blist.begin(), blist.end(), timeSortPredicate<B> );
sort(clist.begin(), clist.end(), timeSortPredicate<C> );
// Print stuff
cout << "Collection A" << endl;
print(alist);
cout << "Collection B" << endl;
print(blist);
cout << "Collection C" << endl;
print(clist);
cout << "Sorting collections by id" << endl;
sort(alist.begin(), alist.end(), idSortPredicate<A> );
sort(blist.begin(), blist.end(), idSortPredicate<B> );
sort(clist.begin(), clist.end(), idSortPredicate<C> );
// Print stuff
cout << "Collection A" << endl;
print(alist);
cout << "Collection B" << endl;
print(blist);
cout << "Collection C" << endl;
print(clist);
return 0;
}
Compile with:
g++ sortpredicate.cpp -o sortpredicate
The output should be:
Collection A 1 15 2 20 3 14 Collection B 3 4 2 10 1 12 Collection C 11 0 12 0 13 0 Sorting collections by time Collection A 3 14 1 15 2 20 Collection B 3 4 2 10 1 12 Collection C 11 0 12 0 13 0 Sorting collections by id Collection A 1 15 2 20 3 14 Collection B 1 12 2 10 3 4 Collection C 11 0 12 0 13 0
Okay. This is going to be somewhat personal.
I’m a professional software developer for a medium sized company, which is really not a software company. It’s only internal software I write.
I’ve also wanted to make a game since I started playing games. That’s probably why I’m a software developer today. I’ve been doing more or less C++ since I was 14, doing (at least trying to) 3D-graphics since I was 18. Without knowledge of the particular mathematics involved with 3D-graphics it proved to be difficult.
I’ve started numerous projects with OpenGL, and some are more advanced than others, but I didn’t continue working on a project for more than 2-3 days before I got tired.
I’ve started an other project now. I don’t know what I’ll make, or whether if I’ll make anything. But I’ve started an other project. The only real difference from previous projects is that I know the value of libraries and there is no point in re-inventing the wheel for every project.
Standard template library is there, Boost is there and some other libraries. I know how to use them. And I know they exist!
For this project I know I’m going to use
I’m not so sure about the sound and physics part, but for now I think I’ll stick with
I must also review the licenses for the libraries to make sure they are allowed to be used in commercial projects or not. I’m not saying my project is going to be commercial, but I won’t exclude it. I’ll also aim for Windows and Linux support. And probably Mac if it’s going to be commercial.
So far I have an empty scene with a blue background.
It’s a start! … again
When I get this error, it’s always because I’ve opened the debugging process in Process Explorer.
Error 1 fatal error LNK1201: error writing to program database 'e:\blergh\blergh\bin\blergh_d.pdb'; check for insufficient disk space, invalid path, or insufficient privilege
Close the handle in Process Explorer or restart Process Explorer.
When porting projects from Visual Studio 2008 or earlier to Visual Studio 2010, and you’re using boost::shared_ptr or other features present in TR1, there will be conflicts. Boost has their own implementation of shared_ptr in boost::shared_ptr and with VS2010 they have put shared_ptr in std::tr1 and they have made shared_ptr available through std::shared_ptr. When using using namespace std; and using namespace boost; there will be ambiguities.
To disable the C++0x/TR1 headers from VS2010 and use the boost implementation, define _HAS_CPP0X=0 in the preprocessor project settings for your VS2010 project.
This little macro prints out user warnings to the output window in a format the “Error List” within Visual Studio will understand and parse. Taken from Stack Overflow and modified a little.
#define STRINGISE_IMPL(x) #x
#define STRINGISE(x) STRINGISE_IMPL(x)
// Use: #pragma message WARN("My message")
#if _MSC_VER
# define FILE_LINE_LINK __FILE__ "(" STRINGISE(__LINE__) ") : "
# define WARN(exp) (FILE_LINE_LINK "warning: " exp)
#else//__GNUC__ - may need other defines for different compilers
# define WARN(exp) ("WARNING: " exp)
#endif
It will produce output like this:
1>.\src\bug.cpp(82) : warning: check me
When this line is present in the source file.
#pragma message WARN("check me")
Open Visual Studio command prompt.
Go to the folder you installed the source files in.
Execute configure with the wanted options.
S:\Qt\2009.04\qt>configure -debug-and-release -fast -no-webkit -opensource This is the Qt for Windows Open Source Edition. You are licensed to use this software under the terms of the GNU General Public License (GPL) version 3 or the GNU Lesser General Public License (LGPL) version 2.1. Type '3' to view the GNU General Public License version 3 (GPLv3). Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1). Type 'y' to accept this license offer. Type 'n' to decline this license offer. Do you accept the terms of the license?
Wait.
Then execute nmake and wait.
Usage: configure [-buildkey <key>]
[-release] [-debug] [-debug-and-release] [-shared] [-static]
[-no-fast] [-fast] [-no-exceptions] [-exceptions]
[-no-accessibility] [-accessibility] [-no-rtti] [-rtti]
[-no-stl] [-stl] [-no-sql-<driver>] [-qt-sql-<driver>]
[-plugin-sql-<driver>] [-system-sqlite] [-arch <arch>]
[-D <define>] [-I <includepath>] [-L <librarypath>]
[-help] [-no-dsp] [-dsp] [-no-vcproj] [-vcproj]
[-no-qmake] [-qmake] [-dont-process] [-process]
[-no-style-<style>] [-qt-style-<style>] [-redo]
[-saveconfig <config>] [-loadconfig <config>]
[-qt-zlib] [-system-zlib] [-no-gif] [-qt-gif] [-no-libpng]
[-qt-libpng] [-system-libpng] [-no-libtiff] [-qt-libtiff]
[-system-libtiff] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]
[-no-libmng] [-qt-libmng] [-system-libmng] [-no-qt3support] [-mmx]
[-no-mmx] [-3dnow] [-no-3dnow] [-sse] [-no-sse] [-sse2] [-no-sse2]
[-no-iwmmxt] [-iwmmxt] [-direct3d] [-openssl] [-openssl-linked]
[-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform <spec>]
[-qtnamespace <namespace>] [-qtlibinfix <infix>] [-no-phonon]
[-phonon] [-no-phonon-backend] [-phonon-backend]
[-no-webkit] [-webkit]
[-no-scripttools] [-scripttools]
[-graphicssystem raster|opengl]
Installation options:
You may use these options to turn on strict plugin loading:
-buildkey <key> .... Build the Qt library and plugins using the specified
<key>. When the library loads plugins, it will only
load those that have a matching <key>.
Configure options:
The defaults (*) are usually acceptable. A plus (+) denotes a default value
that needs to be evaluated. If the evaluation succeeds, the feature is
included. Here is a short explanation of each option:
-release ........... Compile and link Qt with debugging turned off.
* -debug ............. Compile and link Qt with debugging turned on.
+ -debug-and-release . Compile and link two Qt libraries, with and without
debugging turned on.
-opensource ........ Compile and link the Open-Source Edition of Qt.
-commercial ........ Compile and link the Commercial Edition of Qt.
-developer-build ... Compile and link Qt with Qt developer options
(including auto-tests exporting)
* -shared ............ Create and use shared Qt libraries.
-static ............ Create and use static Qt libraries.
-ltcg .............. Use Link Time Code Generation. (Release builds only)
* -no-ltcg ........... Do not use Link Time Code Generation.
* -no-fast ........... Configure Qt normally by generating Makefiles for all
project files.
-fast .............. Configure Qt quickly by generating Makefiles only for
library and subdirectory targets. All other Makefiles
are created as wrappers which will in turn run qmake
-no-exceptions ..... Disable exceptions on platforms that support it.
* -exceptions ........ Enable exceptions on platforms that support it.
-no-accessibility .. Do not compile Windows Active Accessibility support.
* -accessibility ..... Compile Windows Active Accessibility support.
-no-stl ............ Do not compile STL support.
* -stl ............... Compile STL support.
-no-sql-<driver> ... Disable SQL <driver> entirely, by default none are
turned on.
-qt-sql-<driver> ... Enable a SQL <driver> in the Qt Library.
-plugin-sql-<driver> Enable SQL <driver> as a plugin to be linked to at run
time.
Available values for <driver>:
mysql
psql
oci
odbc
tds
db2
+ sqlite
sqlite2
ibase
(drivers marked with a '+' have been detected as
available on this system)
-system-sqlite ..... Use sqlite from the operating system.
-no-qt3support ..... Disables the Qt 3 support functionality.
-no-opengl ......... Disables OpenGL functionality
-platform <spec> ... The operating system and compiler you are building on.
(default %QMAKESPEC%)
-xplatform <spec> .. The operating system and compiler you are cross
compiling to.
See the README file for a list of supported operating
systems and compilers.
-qtnamespace <namespace> Wraps all Qt library code in 'namespace name {...}
-qtlibinfix <infix> Renames all Qt* libs to Qt*<infix>
-D <define> ........ Add an explicit define to the preprocessor.
-I <includepath> ... Add an explicit include path.
-L <librarypath> ... Add an explicit library path.
-l <libraryname> ... Add an explicit library name, residing in a
librarypath.
-graphicssystem <sys> Specify which graphicssystem should be used.
Available values for <sys>:
* raster - Software rasterizer
opengl - Using OpenGL accelleration, experimental!
-help, -h, -? ...... Display this information.
Third Party Libraries:
-qt-zlib ........... Use the zlib bundled with Qt.
+ -system-zlib ....... Use zlib from the operating system.
See http://www.gzip.org/zlib
-no-gif ............ Do not compile the plugin for GIF reading support.
+ -qt-gif ............ Compile the plugin for GIF reading support.
See also src/plugins/imageformats/gif/qgifhandler.h
-no-libpng ......... Do not compile in PNG support.
-qt-libpng ......... Use the libpng bundled with Qt.
+ -system-libpng ..... Use libpng from the operating system.
See http://www.libpng.org/pub/png
-no-libmng ......... Do not compile in MNG support.
-qt-libmng ......... Use the libmng bundled with Qt.
+ -system-libmng ..... Use libmng from the operating system.
See See http://www.libmng.com
-no-libtiff ........ Do not compile the plugin for TIFF support.
-qt-libtiff ........ Use the libtiff bundled with Qt.
+ -system-libtiff .... Use libtiff from the operating system.
See http://www.libtiff.org
-no-libjpeg ........ Do not compile the plugin for JPEG support.
-qt-libjpeg ........ Use the libjpeg bundled with Qt.
+ -system-libjpeg .... Use libjpeg from the operating system.
See http://www.ijg.org
Qt for Windows only:
-no-dsp ............ Do not generate VC++ .dsp files.
* -dsp ............... Generate VC++ .dsp files, only if spec "win32-msvc".
-no-vcproj ......... Do not generate VC++ .vcproj files.
* -vcproj ............ Generate VC++ .vcproj files, only if platform
"win32-msvc.net".
-no-incredibuild-xge Do not add IncrediBuild XGE distribution commands to
custom build steps.
+ -incredibuild-xge .. Add IncrediBuild XGE distribution commands to custom
build steps. This will distribute MOC and UIC steps,
and other custom buildsteps which are added to the
INCREDIBUILD_XGE variable.
(The IncrediBuild distribution commands are only added
to Visual Studio projects)
-no-plugin-manifests Do not embed manifests in plugins.
* -plugin-manifests .. Embed manifests in plugins.
-no-qmake .......... Do not compile qmake.
* -qmake ............. Compile qmake.
-dont-process ...... Do not generate Makefiles/Project files. This will
override -no-fast if specified.
* -process ........... Generate Makefiles/Project files.
-no-rtti ........... Do not compile runtime type information.
* -rtti .............. Compile runtime type information.
-no-mmx ............ Do not compile with use of MMX instructions
+ -mmx ............... Compile with use of MMX instructions
-no-3dnow .......... Do not compile with use of 3DNOW instructions
+ -3dnow ............. Compile with use of 3DNOW instructions
-no-sse ............ Do not compile with use of SSE instructions
+ -sse ............... Compile with use of SSE instructions
-no-sse2 ........... Do not compile with use of SSE2 instructions
+ -sse2 .............. Compile with use of SSE2 instructions
+ -direct3d .......... Compile in Direct3D support (experimental - see
INSTALL for more info)
-no-openssl ........ Do not compile in OpenSSL support
+ -openssl ........... Compile in run-time OpenSSL support
-openssl-linked .... Compile in linked OpenSSL support
-no-dbus ........... Do not compile in D-Bus support
+ -dbus .............. Compile in D-Bus support and load libdbus-1 dynamicall
y
-dbus-linked ....... Compile in D-Bus support and link to libdbus-1
-no-phonon ......... Do not compile in the Phonon module
+ -phonon ............ Compile the Phonon module (Phonon is built if a decent
C++ compiler is used.)
-no-phonon-backend . Do not compile the platform-specific Phonon backend-pl
ugin
* -phonon-backend .... Compile in the platform-specific Phonon backend-plugin
-no-webkit ......... Do not compile in the WebKit module
+ -webkit ............ Compile in the WebKit module (WebKit is built if a
decent C++ compiler is used.)
-no-scripttools .... Do not build the QtScriptTools module.
* -scripttools ....... Build the QtScriptTools module.
-arch <arch> ....... Specify an architecture.
Available values for <arch>:
* windows
windowsce
boundschecker
generic
-no-style-<style> .. Disable <style> entirely.
-qt-style-<style> .. Enable <style> in the Qt Library.
Available styles:
* windows
+ windowsxp
+ windowsvista
* plastique
* cleanlooks
* motif
* cde
windowsce
windowsmobile
-loadconfig <config> Run configure with the parameters from file configure_
<config>.cache.
-saveconfig <config> Run configure and save the parameters in file
configure_<config>.cache.
-redo .............. Run configure with the same parameters as last time.
Qt for Windows CE only:
-no-iwmmxt ......... Do not compile with use of IWMMXT instructions
+ -iwmmxt ............ Do compile with use of IWMMXT instructions (Qt for
Windows CE on Arm only)
* -no-crt ............ Do not add the C runtime to default deployment rules
-qt-crt ............ Qt identifies C runtime during project generation
-crt <path> ........ Specify path to C runtime used for project generation.
-no-cetest ......... Do not compile Windows CE remote test application
+ -cetest ............ Compile Windows CE remote test application
-signature <file> .. Use file for signing the target project
-opengl-es-cm ...... Enable support for OpenGL ES Common
-opengl-es-cl ...... Enable support for OpenGL ES Common Lite
-opengl-es-2 ....... Enable support for OpenGL ES 2.0
* -phonon-wince-ds9 .. Enable Phonon Direct Show 9 backend for Windows CE
Lengste, største og styggeste feil jeg har fått…
Error 2 error LNK2019: unresolved external symbol "class std::auto_ptr<class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::set<class openvrml::node_interface,struct openvrml::node_interface_compare,class std::allocator<class openvrml::node_interface> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::set<class openvrml::node_interface,struct openvrml::node_interface_compare,class std::allocator<class openvrml::node_interface> > > > > > __cdecl openvrml::profile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?profile@openvrml@@YA?AV?$auto_ptr@V?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$set@Vnode_interface@openvrml@@Unode_interface_compare@2@V?$allocator@Vnode_interface@openvrml@@@std@@@2@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$set@Vnode_interface@openvrml@@Unode_interface_compare@2@V?$allocator@Vnode_interface@openvrml@@@std@@@2@@std@@@2@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z) referenced in function "public: void __thiscall openvrml::vrml97_grammar<struct openvrml::null_vrml97_parse_actions,struct openvrml::vrml97_parse_error_handler>::definition<class boost::spirit::scanner<class boost::spirit::position_iterator<class std::_String_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::spirit::file_position_base<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,struct boost::spirit::nil_t>,struct boost::spirit::scanner_policies<class boost::spirit::skip_parser_iteration_policy<struct openvrml::vrml97_skip_grammar,struct boost::spirit::iteration_policy>,struct boost::spirit::match_policy,struct boost::spirit::action_policy> > >::on_scene_start_t::operator()<class boost::spirit::position_iterator<class std::_String_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::spirit::file_position_base<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,struct boost::spirit::nil_t> >(class boost::spirit::position_iterator<class std::_String_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::spirit::file_position_base<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,struct boost::spirit::nil_t>,class boost::spirit::position_iterator<class std::_String_iterator<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::spirit::file_position_base<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,struct boost::spirit::nil_t>)const " (??$?RV?$position_iterator@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$file_position_base@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@spirit@boost@@Unil_t@45@@spirit@boost@@@on_scene_start_t@?$definition@V?$scanner@V?$position_iterator@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$file_position_base@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@spirit@boost@@Unil_t@45@@spirit@boost@@U?$scanner_policies@V?$skip_parser_iteration_policy@Uvrml97_skip_grammar@openvrml@@Uiteration_policy@spirit@boost@@@spirit@boost@@Umatch_policy@23@Uaction_policy@23@@23@@spirit@boost@@@?$vrml97_grammar@Unull_vrml97_parse_actions@openvrml@@Uvrml97_parse_error_handler@2@@openvrml@@QBEXV?$position_iterator@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$file_position_base@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@spirit@boost@@Unil_t@45@@spirit@boost@@0@Z) moc_qtdifi.obj