Category: C++

Linking Boost library from Qt application with MinGW

While integrating NetCom’s app_gui module (Qt app) with GLog module that relies on Boost library, I encountered a long long list of linking errors: g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o .\NetCom.exe .\main.o .\MainWindow.o.\TestCaseDialog.o .\RunTestPlanDialog.o .\MsgCommDialog.o .\moc_MainWindow.o .\moc_TestCaseDialog.o .\moc_RunTestPlanDialog.o .\moc_MsgCommDialog.o -L"C:\Qt\2010.02.1\qt\lib" -L"C:\boost_1_41_0\stage\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4 -llibboost_date_time-mt-d C:\boost_1_41_0\stage\lib/libboost_date_time-mt-d.lib(greg_month.o): In function `ZN5boost9gregorian10greg_month17get_month_map_ptrEv': c:/boost_1_41_0/libs/date_time/src/gregorian/greg_month.cpp:36: undefined reference […]

Tuesday June 8th, 2010 in C++, Learning in progress, NetCom, Project | Comments Off

Build failure with Qt makefile: undefined reference to `_Unwind_Resume’

While building NetCom’s app_gui module through command line with the makefile auto-generated by Qt, I encountered following error: undefined reference to `_Unwind_Resume’ Just in case anyone makes the same mistake, here is the tip: makefile generated by Qt requires some environment variables to be set up beforehand.  In another word, if you run build from […]

Sunday April 4th, 2010 in C++, Learning in progress, NetCom, Project, Sharing | Comments Off

C++ library linking

While porting NetCom Simulator’s GLog module from Windows to Linux, I found all my library linking, i.e. to Boost C++ libraries, are broken. After some study and experiment works, I realize that library linking works slightly different on the two platforms. Here is my finding base on the experiment as well as ideas received from […]

Tuesday December 29th, 2009 in C++, Learning in progress, Sharing | Comments Off

GLog module is thread safe now

Finally, the GLog module can be use safely from multiple threads concurrently. This is achieved by using the Boost.Asio library, which is one of the options mentioned in previous post. Asio provides some convenient utilities, such as io_service and strand, which makes implementation of asynchronous I/O and synchronous access to shared resources relatively easy. In fact, these are the missing […]

Sunday December 20th, 2009 in C++, Learning in progress, NetCom, Project | Comments Off

Journey to a threadsafe GLog module

I’m still in the progress of trying to make GLog module threadsafe. Right now, log output to screen still having multithreading issue, which must be solve no matter how. Below is what has been happening up to this point: Knowing that std::cout is not threadsafe, have been looking for alternative, without applying lock on every […]

Saturday December 12th, 2009 in C++, Learning in progress, NetCom, Project | 1 Comment »

Initial threading support for NetCom Simulator

While trying to make GLog module thread safe, I have been wondering if I should directly use the pthread APIs, Boost.Thread, or write a GThread module that wraps up either of them. After some struggling, I decided to use Boost.Thread directly for the moment, both from the gUtil layer and from application codes. Reasons: I […]

Thursday November 26th, 2009 in C++, NetCom, Project | Comments Off

‘Boost’-ing NetCom Simulator

I’d heard about Boost since my last job, back to 2006. Knowing what Boost library is all about, I have not taste it out before, however. And on this week, I finally place my hands on it, so that Netcom Simulator project can have a thread-safe facility for dealing with date time. These functions can […]

Sunday November 8th, 2009 in C++, Learning in progress, NetCom, Project | Comments Off

Note – Type casting supported by C++

There are four explicit type castings supported in C++: dynamic_cast reinterpret_cast static_cast const_cast dynamic_cast Typically used for downcasting and upward casting. For downcasting, Base class has to be polymorphic. Safety checking will be perform during runtime to ensure compatibility, thus slower performance. If conversion fails, returned pointer will be null pointer. Can be use to […]

Sunday September 6th, 2009 in C++, Learning in progress | Comments Off

Note – Inheritance in C++

There are three types of inheritance in C++. Following snippet tells their syntax and typical usage: // public inheritance, the most discussed "is-a" relationship class Derived : public Base { … }   // protected inheritance, another form of "has-a" relationship // (a.k.a. composition). Choose the member object approach // over this method unless there […]

Sunday August 30th, 2009 in C++, Learning in progress | Comments Off

C++ dynamic binding

C++ realizes dynamic binding through vTable. From programmer’s perspective, this is done through declaring base class’s function as virtual. Assumed that a Derived class inherits from Base class, and overriding the Base class function, here are few scenarios in coding with different result: Non-virtual function The function is invoked on a Base class object pointed […]

Sunday August 30th, 2009 in C++, Learning in progress | Comments Off