The following script allows for GUI popup display for Ubuntu and the likes:
#!/bin/bash
# basic script to display a GUI popup box
# requires libnotify-bin (for command notify-send)
notify-send -t 4000 "Take a look at the console !" $(eval pwd)"\n"`date +%Y/%m/%d-%H:%M:%S`
Thursday, December 24, 2015
Thursday, December 10, 2015
c++ change pointer passed as argument
To change the pointer passed in argument you need something like this:
void foo(int **ptr) //pointer to pointer
{
*ptr = new int[10]; //just for example, use RAII in a real world
}
orvoid bar(int *& ptr) //reference to pointer (a bit confusing look)
{
ptr = new int[10];
}
Original thread: http://stackoverflow.com/questions/11842416/function-does-not-change-passed-pointer-c
C++ headers and sources, templates
Original thread: http://stackoverflow.com/questions/23962044/multiple-definition-of-first-defined-here-in-the-same-line-in-a-data-struc
If I understand you correctly, you are doing things like this:
There is one special case where this is allowed, and that's when
Incidentally, the reason things work when you move the function bodies inside the class definition is because that has the effect of making them implicitly inline.
If I understand you correctly, you are doing things like this:
// C.h
class C
{
void f(); // declaration of f; ok to include in many modules
};
// definition of f; must not exist in more than one module
void C::f()
{
}
That doesn't work because the definition of f() will
wind up in every module that includes C.h, leading to exactly the linker
error you describe. You can fix this by either marking f() as inline, or by moving the definition of f() to a separate cpp file.There is one special case where this is allowed, and that's when
f() is a template (either directly or because C is a template). In that case, the definition must
be in the header so the compiler can know how to instantiate it for
whatever type(s) you specify. This does make life difficult for the
linker since you can and often do end up with the sorts of redundant
definitions that would normally be errors (e.g if you use f() in more than one module). Special behavior is needed to handle this.Incidentally, the reason things work when you move the function bodies inside the class definition is because that has the effect of making them implicitly inline.
Friday, November 27, 2015
git graphical diff
One can use the "git difftool" command, which has direct knowledge of many diffing tools, including meld.
By default it always asks for which diffing tool to use (and defaults to 'meld' on my box), but you can automate the choice with configuration variables. See "git help difftool" for details.
Src: http://blog.deadlypenguin.com/blog/2011/05/03/using-meld-with-git-diff/
see "comments" sections
By default it always asks for which diffing tool to use (and defaults to 'meld' on my box), but you can automate the choice with configuration variables. See "git help difftool" for details.
Src: http://blog.deadlypenguin.com/blog/2011/05/03/using-meld-with-git-diff/
see "comments" sections
Wednesday, November 25, 2015
CUDA_VISIBLE_DEVICES – Masking GPUs
Src: http://acceleware.com/blog/cudavisibledevices-masking-gpus
Does your CUDA application need to target a specific GPU? If you are writing GPU enabled code, you would typically use a device query to select the desired GPUs. However, a quick and easy solution for testing is to use the environment variable CUDA_VISIBLE_DEVICES to restrict the devices that your CUDA application sees. This can be useful if you are attempting to share resources on a node or you want your GPU enabled executable to target a specific GPU.
CUDA will enumerate the visible devices starting
at zero. In the last case, devices 0, 2, 3 will appear as devices 0, 1,
2. If you change the order of the string to “2,3,0”, devices 2,3,0 will
be enumerated as 0,1,2 respectively. If
To determine the device ID for the available hardware in your system, you can run NVIDIA’s deviceQuery executable included in the CUDA SDK. Happy programming!
Does your CUDA application need to target a specific GPU? If you are writing GPU enabled code, you would typically use a device query to select the desired GPUs. However, a quick and easy solution for testing is to use the environment variable CUDA_VISIBLE_DEVICES to restrict the devices that your CUDA application sees. This can be useful if you are attempting to share resources on a node or you want your GPU enabled executable to target a specific GPU.
| Environment Variable Syntax | Results |
|---|---|
| CUDA_VISIBLE_DEVICES=1 | Only device 1 will be seen |
| CUDA_VISIBLE_DEVICES=0,1 | Devices 0 and 1 will be visible |
| CUDA_VISIBLE_DEVICES=”0,1” | Same as above, quotation marks are optional |
| CUDA_VISIBLE_DEVICES=0,2,3 | Devices 0, 2, 3 will be visible; device 1 is masked |
CUDA_VISIBLE_DEVICES
is set to a device that does not exist, all devices will be masked. You
can specify a mix of valid and invalid device numbers. All devices
before the invalid value will be enumerated, while all devices after the
invalid value will be masked.To determine the device ID for the available hardware in your system, you can run NVIDIA’s deviceQuery executable included in the CUDA SDK. Happy programming!
Monday, November 23, 2015
Nvidia Visual Profiler (NVVP) version 7.5 crashes on new session on Ubuntu
Original thread: http://stackoverflow.com/questions/26436009/eclipse-luna-crashes-on-new-project-in-ubuntu
Extracted Solution:
According to comment 20 in this bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=440660#c20
Extracted Solution:
According to comment 20 in this bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=440660#c20
This seems to be a bug in GTK according to https://bugs.launchpad.net/ubuntu/+source/gtk2-engines-oxygen/+bug/1242801 (there a similar problem for Meld was reported).
Another workaround mentioned there is for Oxygen, edit the normally already existing file/usr/share/themes/oxygen-gtk/gtk-2.0/gtkrcand change
into`GtkComboBox::appears-as-list = 1`
This workaround is working for me.`GtkComboBox::appears-as-list = 0`
Tuesday, November 3, 2015
LD cannot find library because of version numbering
It is Debian convention to separate shared libraries into their runtime components (
Because the library's soname is
However, because the library is specified as
See Diego E. Pettenò: Linkers and names for details on how this all works on Linux.
In short, you should
This will not only give you
src: http://stackoverflow.com/questions/335928/ld-cannot-find-an-existing-library
libmagic1: /usr/lib/libmagic.so.1 → libmagic.so.1.0.0) and their development components (libmagic-dev: /usr/lib/libmagic.so → …).Because the library's soname is
libmagic.so.1, that's the string that gets embedded into the executable so that's the file that is loaded when the executable is run.However, because the library is specified as
-lmagic to the linker, it looks for libmagic.so, which is why it is needed for development.See Diego E. Pettenò: Linkers and names for details on how this all works on Linux.
In short, you should
apt-get install libmagic-dev.This will not only give you
libmagic.so but also other files necessary for compiling like /usr/include/magic.h.src: http://stackoverflow.com/questions/335928/ld-cannot-find-an-existing-library
Subscribe to:
Posts (Atom)