In this section I will collect short things that have taken me some time to figure out. The intent is that I would be able to avoid wasting time in the future after I have forgotten about them.
18.06.2015 (03.06.2016)
Suppose you have stored all of your papers inside the same Mercurial repository allpapers
as follows:
allpapers/
paper-a/
paper-a.tex
...
paper-b/
paper-b.tex
...
...
You want to move the paper-a
sub-directory to its own, new, repository just-paper-a
, while preserving its revision history:
just-paper-a/
Want the contents of allpapers/paper-a here, with all of its revision history!
This solution is from here.
The task is handled by the Convert extension of Mercurial. The caveat is that this is a one-way operation: it is not possible to commit changes from the new repository into the old repository. However, at least in my case this wasn’t a problem since I just wanted to remove paper-a
from the old repository afterwards.
The Convert extension is enabled by editing the Mercurial settings to
[extension]
(existing stuff...)
hgext.convert=
On TortoiseHg, you would do
Suppose you want to create the new repository into the directory just-paper-a
. Into the parent directory of just-paper-a
, create a file map.txt
, which reads
include "paper-a"
rename "paper-a" .
The first line instructs the Convert extension to move the paper-a
sub-directory into the new repository at just-paper-a/paper-a
. However, now there would be an extra sub-directory paper-a
inside the new repository.
Therefore, the second line instructs the convert extension to rename the new paper-a
sub-directory to .
, which means that the contents of the paper-a
sub-directory inside the old repository are moved into the contents of the just-paper-a
directory inside the new repository.
Go to the parent directory of just-paper-a
using command-line. Then perform the conversion by entering
hg convert --filemap map.txt allpapers just-paper-a
After updating to the tip-revision, you are done.
14.06.2015
In Matlab, on Mac OS X, you have built a mex which by some route links to the gfortran
library — perhaps because you use Lapack and/or BLAS. When you call the mex, Matlab gives an error which goes something like this:
Invalid MEX-file
'your_mex_file.mexmaci64':
dlopen(your_mex_file.mexmaci64, 6):
Symbol not found:
__gfortran_transfer_array_write
Referenced from:
(some library)
Expected in:
/Applications/MATLAB_R2015a.app/sys/os/maci64/libgfortran.3.dylib
in (some library)
Matlab has its own version of gfortran
library in
/Applications/MATLAB_R2015a.app/sys/os/maci64/libgfortran.3.dylib
The dynamic linker in the operating system resolves the gfortran
reference to this file. However, the mex library is linked against the version of gfortran
library in
/usr/local/lib/gcc/5/libgfortran.3.dylib
(or something similar). Since these libraries are not compatible, there is an error.
This solution is from here.
Replace
/Applications/MATLAB_R2015a.app/sys/os/maci64/libgfortran.3.dylib
with gcc’s library of the same name. On my computer, the latter is located in:
/usr/local/lib/gcc/5/libgfortran.3.dylib
This solution is from here.
Running
getenv('DYLD_LIBRARY_PATH')
on the Matlab command prompt gives the following:
/Applications/MATLAB_R2015a.app/sys/os/maci64:
/Applications/MATLAB_R2015a.app/bin/maci64/../../Contents/MacOS:
/Applications/MATLAB_R2015a.app/bin/maci64:
/Applications/MATLAB_R2015a.app/extern/lib/maci64:
/Applications/MATLAB_R2015a.app/sys/java/jre/maci64/jre/lib/./native_threads:
/Applications/MATLAB_R2015a.app/sys/java/jre/maci64/jre/lib/./server:
/Applications/MATLAB_R2015a.app/sys/java/jre/maci64/jre/lib/./lib/jli
This is a list of directories which Matlab gives to the operating system to search for dynamic libraries. Since the preceding paths have priority over the following ones, the first idea is to prepend gcc’s path to this list as
setenv('DYLD_LIBRARY_PATH', ['/usr/local/lib/gcc/5:', getenv('DYLD_LIBRARY_PATH')]);
on the Matlab command prompt. However, this change comes too late; the library has already been loaded. To get to an earlier point in Matlab initialization, we instead modify the file
/Applications/MATLAB_R2015a.app/bin/.matlab7rc.sh
The documentation in this file provides the following information:
LDPATH_PREFIX (path(s) that appear at the start of LD_LIBRARY_PATH)
Guided by this, we find LDPATH_PREFIX=
— under section mac|maci|maci64
— and replace it with
LDPATH_PREFIX="/usr/local/lib/gcc/5"
After a restart of Matlab, writing
getenv('DYLD_LIBRARY_PATH')
provides
/usr/local/lib/gcc/5:
(and the rest...)
as expected (LDPATH_PREFIX
is empty). The library will now be correctly resolved.
foreach
14.06.2015
In CMake, you want to iterate over a
, b
and c
, and write:
foreach(element "a;b;c")
endforeach()
Hoever, this does not work.
This works
set (elementSet "a;b;c")
foreach(element elementSet)
endforeach()
This is from here.
14.06.2015
Consider the following in CMake:
macro (Test x)
endmacro()
set (x "")
Test(${x})
Then CMake errors on the Test
call having too few arguments.
The call expands to
Test()
which causes the error.
The solution is to use quotation marks:
Test("${x}")
Then the call expands to
Test("")
09.06.2015
After the Yosemite OS X update on my Mac Mini 2012, Windows 8.1 (via Bootcamp) started to sometimes freeze at the loading screen; the Windows logo appeared, but the dots did not circle around.
The solution was to unplug-plug USB devices one by one. Windows 8.1 immediately continued loading on the offending USB device. The offending device was either my HP Laserjet P2055d printer (USB 2.0), or my USB hub (USB 2.0) — or both. Perhaps USB 2.0 devices are the problem here.
This time I slowly unplugged-plugged the USB devices to see which it is. Unfortunately, nothing worked. I tried different combinations, printer on and off, USB hub on and off, and different positions for the USB plugs. I also tried to unplug-plug monitor cables. I ended up hard-rebooting the computer.
The offending USB device was the USB 2.0 D-link hub. Plugging it off resumed Windows starting. It is possible that the same bug alternates between the devices based on the starting order.
04.06.2015
You have built a C++ library in CMake’s debug mode, and try to link it together with other C++ code in Matlab using the -g
debug flag. The linker raises the warning
warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
Under a Windows debug build, CMake defaults to dynamically-linked debug-mode C and C++ standard libraries (/MDd
on Visual Studio), while Matlab (under -g
) defaults to dynamically-linked release-mode standard libraries (/MD
on Visual Studio). This mixture of standard library versions causes the warning and the errors.
The solution is to match the versions of the standard libraries.
To match Matlab, force CMake to use release-mode standard libraries even in debug-mode:
string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
This is best made as an option for the build, so that it is only done when the library is to be built from Matlab’s mex.
To match CMake, force Matlab to use a debug-mode standard libraries in debug mode. Edit the compiler option file:
/MD
, /MDd
and /D_DEBUG
.However, I am not sure whether this is correct, since Matlab’s components have been built with the release-mode standard libraries; Matlab does not come with debug libraries.
03.06.2015
When trying to mount an ISO-image, Windows 8.1 throws the error
Sorry, there was a problem mounting the file.
Copy the ISO-image anywhere. After that Windows mounts it correctly. This is from here.
22.05.2015
You would like to reset the color of Windows command-line to white.
Type in the command-line:
color 07
This is from here.
22.05.2015
Given Makefile
s produced by CMake, you wish to build only a single file, to quickly test whether your changes are correct. However, if you run make
from the root, then it will build every file affected by the change. This takes time.
CMake produces one Makefile
for each directory. Change the directory to where the file resides, and then run make file.obj
. Note that while the source is .cpp
, the target is .obj
.
abs
may not be in std
namespace22.05.2015
The standard abs
function may not be contained in the std
namespace. This compiles in Visual Studio 2015 RC and gcc 4.9.3:
#include <cmath>
int main()
{
return abs(0);
}
24.04.2015
In Latex, you get a lot of warnings of the form
Overfull \hbox (17.52579pt too wide) in paragraph
When you look at the corresponding text in the PDF, the text leaks over the marginals.
The leakage probably happens because the text contains compound words with hyphens, such as quasi-norm
. Since Latex does not by default hyphenate explicit hyphens, the compound word becomes a big element which Latex cannot break into pieces and has problems positioning.
To solve, add this package:
% For hyphenating dashed words (e.g. sub-composability)
\usepackage[shortcuts]{extdash}
Then, in the text, replace -
with \-/
. For example, quasi\-/norm
.
24.04.2015
Suppose you use the hyperref
package to generate internal links, and write the following section title:
\section{Convergence in the $m$:th mean}
Then you will get the following warning:
Token not allowed in a PDF string (PDFDocEncoding):(hyperref) removing `math shift'
The section name is also used to name a PDF bookmark, for which math symbols are not allowed.
Use the \texorpdfstring
macro to provide alternative texts for math-symbols. For example:
\section{Convergence in the \texorpdfstring{$m$}{m}:th mean}
The first argument is used for the section name, and the second argument is used for the PDF bookmark.
24.04.2015
Suppose you use the environ
package, and change the type of Latex document from article
to book
. This results in obscure errors for the \NewEnviron
macro, which do not go away even after reverting the change.
11.03.2015
The installation of Kubuntu fails right on the start with a garbled screen. To resolve, push Right Ctrl + F1
, followed by Right Ctrl + F7
. This is from here.
11.03.2015
To make CMake use Clang under Linux, set
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
Only the second is needed for C++. This is from here.
04.03.2015
When using preview-versions of Visual Studio, Boost library emits an error where it says that it does not recognize the used compiler. To get around this, open
boost\config\compiler\visualc.hpp
Navigate to the bottom, where it says
#if (_MSC_VER > 1800 && _MSC_FULL_VER > 190022129)
or something similar. Replace 190022129
with a proper version number, which you can obtain by running:
#include <iostream>
#include <string>
int main()
{
std::cout << _MSC_FULL_VER << std::endl;
std::string tmp;
std::getline(std::cin, tmp);
return 0;
}
06.02.2015
The printer-scanner Ricoh Aficio MP C4502, that we have at the university, produced every scanned page in landscape, no matter how I set the settings. This was a bug in the printer firmware, which appeared only when the scanning was done in grayscale. The solution was to set the scanner to automatically set the output-type, or to scan in color.
The same printer also had problems printing the document it had just scanned. Printing 11 pages of scanned documents, using a PS-driver, took 12 minutes 30 seconds. I tried printing the same document at home with my HP Laserjet P2055d, using a PCL5 driver, and it did the job in 1min 50 seconds. I wonder whether the problem is in using a PS-driver.
31.07.2015
Once I upgraded to Windows 10, the printer worked out of the box.
06.02.2015
After I upgraded from Windows 7 to Windows 8.1, my HP Laserjet P2055d printer stopped working. I was able to fix it.
If there are no drivers for the printer, then Windows attempts to install them automatically when the printer is turned on and connected via USB.
The automatic driver installation takes a long time, but eventually completes.
Two printers are added into “Devices and Printers”: “HP Laserjet P2055 Series” and “HP Universal Printing PCL 6, 1”.
Only one printer is added into the “Print” dialog: “HP Universal Printing PS”.
After the automatic driver installation the printer crashes on a firmware error “49 Err 3D910C8 Turn Off then On”, given on the two-line display on the printer itself. The firmware error is not reflected to the operating system.
Although it seems that the automatic driver installation succeeds, it fails, and does this silently:
Choosing “Printer Options” on the “HP Universal Printing PCL 6, 1” gives the error “Printer properties cannot be displayed.” The same happens for “Printing Preferences”.
Choosing “Printing Preferences” in the “Print” dialog causes the firmware error “49 Err 3D910C8 Turn Off then On” on the printer’s display.
Connecting the printer to D-Link USB 2.0 hub breaks the printer. This is a bug in the D-Link hub, or in the printer’s firmware, but I don’t know which.
When installing the drivers manually, the duplex unit for the Laserjet P2055d must be enabled manually.
At some point, when trying to access “Printing Preferences” in the “Print” dialog, I got the error “Function address 0x65b661a8 caused a protection fault. (exception code 0xc0000005) The application property sheet page(s) may not function properly”.
At some point, the printer port was assigned to the LPT1 printer port, although it should have been USB001. I am not sure whether I set this myself by accident, or whether it was set by another installation program. This may have been connected to the protection fault above.
From the printers console in the printer, I printed a configuration report, which showed that the firmware version was 20090430; outdated.
Make sure the printer is connected via USB to the computer directly; not through a USB hub.
Turn the printer on.
Update the firmware.
I went to the HP support pages to search for a firmware update. However, I was unable to find one for Windows 8.1. The firmware update was listed only under Windows 7. I downloaded that; there probably is no difference.
The firmware update warned about that the “RFU” setting must first be disabled from the printer’s control panel, to make it possible to update the firmware. However, there was no RFU setting. A little research showed that the RFU setting was only added in a later firmware update, and it was a way to protect the firmware from “accidental” updates.
I proceeded to update the firmware, and it completed succesfully. The configuration test page confirmed this; the firmware version was updated to 20120615. The RFU setting appeared after the firmware update, as expected.
Turn the printer off.
Remove all devices related to the printer in “Devices and Printers”.
Turn the printer on.
Wait until the printer “HP Laserjet P2055 Series” automatically appears into “Devices and Printers”. Note that this assumes that you have automatic driver installation turned on (this is the default in Windows).
The driver installation is now broken.
Remove all devices related to the printer (“HP Universal Printing PCL 6” and similar), except the printer “HP Laserjet P2055 Series”.
Download the latest PCL5 driver for Laserjet P2055d.
Do not download the latest PCL6 driver; it is broken.
When I installed a PCL6 driver, I could print some types of papers, but not all. For example, the printer failed to print a scanned PDF document, producing PCL XR errors printed on the paper:
PCL XL Error
Subsystem: KERNEL
Error: IllegalTag
Operator: 0x
Position: 26967
Install the PCL5 driver in “Standard” or “Traditional” mode.
Stop the search for printers.
Select to install a local printer.
Select USB001 as the printer port (or whatever USB-port is available).
Select to replace the current driver.
Finalize the installation with other choices.
In “Devices and Printers”, right-click on the installed printer, and select “Printer Properties”.
Go to the “Device Settings” tab.
Change “Duplex Unit” from “Not installed” to “Installed”.
In “Devices and Printers”, right-click on the installed printer, and select “Printing Preferences”.