“There are stopped jobs”

Seeing this message when trying to exit bash means some interactive processes launched from this terminal are still running in the background. Use the jobs command to list them. Use fg <n> to bring job number n to the foreground and exit the process properly.

As an example, if a command being piped to less exits and less is left hanging without anything to show, it goes to the background. Example:

This means that less is still running in the background waiting for input. Here’s how to bring it to the foreground and exit it.

In this case, after fg 1, it is not immediately clear what to do. But since I know that it is less that’s running now, I hit q (since q is the less keystroke to quit).

Object Relationships using smart pointers and “Modern C++”

  1. Don’t use raw pointers as class members; that requires managing object life time and manually avoiding dangling pointers
  2. Use smart pointers instead of raw pointers
  3. Don’t use object references as class members as that makes objects of the class non-assignable (which means you cannot store said objects in standard C++ containers)
  4. Using raw pointers and object references to objects stored in standard C++ containers is problematic or impossible. Objects in containers can be relocated (addresses can change) rendering raw pointers and object references invalid.
  5. Best (only feasible?) option is to store std::shared_ptr of the dynamically allocated object in the container.
  6. std::shared_ptr is reference counted std::weak_ptr is not
  7. Use std::make_shared to create an std::shared_ptr to a dynamically created object instance or use std::shared_ptr(new T())
  8. Only way to access members via std::weak_ptr is by calling std::weak_ptr::lock which returns an std::shared_ptr or 0
  9. To create an std::weak_ptr from the this pointer, the class must first derive from std::enable_shared_from_this and then call the shared_from_this function to get an std::shared_ptr pointing to the object. The object in question must be “owned” by an std::shared_ptr or else undefined behaviour results. Also, shared_from_this must not be called from a constructor since the object is yet to be reference counted (i.e. object is not yet “owned” by an std::shared_ptr)
  10. As a result of the previous point, it helps to ensure that objects can only be created via std::shared_ptr by using a public static create function (which returns objects “owned” by an std::shared_ptr) and making constructors private. Note that when constructors are made private, you can no longer use std::make_shared to create a shared pointer. You must use std::shared_ptr(new T()) in this case.

Modern C++ Object Relationships

“The procedure entry xxx could not be located in the dynamic link library msvcrt.dll.”

This is the error I was getting when trying to install an MSI I created for a C++/CLI project. Turns out that the MSI included glut.dll and opengll.dll. When building the MSI files, warnings are displayed to the effect that those two files should be excluded.

Click on the file name under “Application Folder” and set the “Exclude” property to false in the property grid. This fixes the problem.

Linux Package Names

Package Name on Repo
GNU Standard C++ Library libstdc++
Documentation for the GNU standard C++ library libstdc++-docs
The Boost C++ headers and shared development libraries boost-devel
HTML documentation for the Boost C++ libraries boost-doc
Apache HTTP Server httpd
The MySQL server and related files mysql-server
PHP scripting language for creating dynamic web sites php
A module for PHP applications that use MySQL databases php-mysql
Free Feature-rich PHP Mailer php-swift-Swift
Development files for GTK+ gtk2-devel
The Boost C++ headers and shared development libraries boost-devel
C++ support for GCC gcc-c++

MySQL calls via PDO fail silently

By default any error that occurs on a MySQL call via PDO fails quietly. The caller must inspect $pdo->errorCode() to see if the call succeeded/failed. This behaviour can be changed by setting the ATTR_ERRMODE attribute either while constructing the PDO object or after construction via setAttribute.