How do you connect Eclipse to Valgrind via WSL on Windows 10? - valgrind

I want to do memcheck on C applications on Windows.
My hypothesis is that Valgrind via WSL would also require compiled executable to be done in Linux. Is this setup to be avoided or recommended?

Related

Profiler in CLion 2022.2.4 over WSL 2

I am wanting to run a CPU profiler on my C++ code via CLion. The profiler in CLion only used to be available for Linux (using perf) and macOS (using DTrace), but as of CLion 2021.2, the profiler is supposed to be available for WSL (also using perf) and I am using CLion 2022.2.4. CLion's docs have also been updated to reflect this change, listing WSL under the supported OSs, but there is no additional information for it, so I would assume the steps would be identical to those of Linux.
perf is only available for WSL on WSL 2, but I am using WSL 2 and have successfully installed perf. I have configured a CLion toolchain for this same WSL instance, and have successfully managed to use another WSL-only feature (Valgrind MemCheck) through it.
However, with Valgrind, all Valgrind-related IDE features (settings, run configurations, notifications...) were available to me before I even installed WSL, whereas the equivelant features for profiling don't seem to be available even after completely configuring WSL 2. How can I access the profiler for WSL?
By default, CLion has a plugin called Copyright enabled, but it appears I must have disabled it. There is a bug which causes profiler-related features to only show with this plugin enabled, and enabling it fixed the issue.

What is the best way to remotely edit a file using VS code?

Currently, I have two machines, one with Ubuntu in the company and one with Mac OS at home. Sometimes I would like to work at home while accessing the Ubuntu machine in the company. I can ssh into the Ubuntu machine and navigate and compile there. However, when I actually want to edit some cpp source codes, I realize that the editor (VS code) is actually opened in the Ubuntu machine, so I cannot view it from Mac. What should I do if want to edit files remotely on my Mac through VS code?
Though many of the answers mention using version control tools like git, it can be hard to use in my specific case. The problem is that the building environment of my company is Linux, so most of the building tools I have can only run on Linux. This means that I can only compile my source codes in Linux. If I use git, then every time I want to compile and debug my codes, I have to commit and push with my Mac, and then pull and test on Linux. This can be time consuming if want to incrementally modify, test and debug my codes.
Use some version control system like git. Then you might edit and compile at home (provided your code is portable between Linux & MacOSX, e.g. because it is POSIX compliant).
You could install some X11 server on your Mac and use ssh -X to access the remote Ubuntu machine (then run a GUI or editor remotely, e.g. ssh -X remotelinuxhost.company.com emacs). However, that requires good bandwidth and latency between your home computer and the remote one.
BTW, you might use some other source code editor, like emacs (it is capable of remote editing) or vim.
Since Linux and MacOSX are both POSIX systems, it is usually (but not always) easy to port source code from Linux to MacOSX and write source code compilable on both systems. BTW, many Linux frameworks (e.g. Qt, GTK, POCO, Boost, etc...) and build systems are usable and ported to MacOSX. Some Linux system calls (listed in syscalls(2)) are not available on MacOSX (e.g. signalfd(2)...)
Of course you could install Linux (perhaps inside some VM) on your Apple laptop.

Are libraries built using the Linux subsystem in Windows 10 accessible to a Windows development environment?

I'm currently trying to connect MongoDB to a Windows QT C++ application and am following the tutorial here. While there Windows installation instructions are presented, to avoid having to install Visual Studio or other tools, I'm wondering if I can follow the package-manager or Linux instructions on the inbuilt Linux/ Ubuntu subsystem of Windows 10 and build the libraries in my Linux environment, later somehow accessing them from my Windows development environment.
I don't fully understand how compilation/ byte-code works in the Linux subsystem on Windows, so I haven't been able to piece together an answer for this myself based on my understanding of the various systems involved. Any explanation or assistance would be appreciated.
You can run a Windows executable from a WSL console window or a Linux executable from Windows command line / power shell. And capture the output, pipe between applications etc. But the application must run entirely on one platform; you cannot mix a Windows executable with Linux libraries or vice-versa.
I don't know how you will connect to MongoDB but, if it has a socket interface like MySql, you could create a bash script on WSL which runs your QT application to access the database, wherever it is.
But if you're using QT as a GUI you're going to struggle. People have been able to get a Linux desktop running on WSL by installing an X server on the Windows host but you might find that more trouble than it's worth.

MSYS2: is a windows or unix environment?

I'm confused about the environment. Using MSYS2 under Windows, I want to compile, say, the boost library:
http://www.boost.org/users/history/version_1_64_0.html
What file I have to download? The one for Windows or the one for unix?
MSYS2 is a not a Unix environment. It is a hybrid environment made up of these main components:
POSIX-emulation layer called msys-2.0.dll, which is a fork of cygwin.
Tools like GNU Make, Bash, and ls that depend on the msys-2.0.dll runtime.
pacman, another msys-2.0.dll program, that lets you install precompiled packages from the MSYS2 developers.
Native Windows software, which lives under the /mingw32 (for 32-bit) and /mingw64 (for 64-bit) directories.
Anyway, it seems like you are just getting started with MSYS2 and don't know much about it. If your goal is to write native Windows software that could some day be used outside of MSYS2, you should install the native Windows version of Boost provided by the MSYS2 developers. So run one of the commands below:
pacman -S mingw-w64-i686-boost
or
pacman -S mingw-w64-x86_64-boost
Then make sure you are using the right flavor of MSYS2 shell, and make sure you install the corresponding GCC toolchain. For 32-bit development, you must launch MSYS2 with the "MinGW-w64 32-bit Shell" shortcut and use pacman to install mingw-w64-i686-toolchain (pacman -S mingw-w64-i686-toolchain).
If you try to download binaries from boost's website, you will likely run into all sorts of compatibility issues. It's better to use software built using an MSYS2 GCC toolchain, especially if MSYS2 already has a package for that software.

Linux or Windows version of a library in Cygwin?

I have developed some codes in Linux which use boost::serialization library. Now I want to copy my files into Cygwin and compile them to produce executable for Windows. I know that I should use Mingw-64 g++ compiler. But how about boost library? Should I download the Windows version or the Linux version of this library?
In Cygwin, you install Boost libraries as per Unix/Linux. From the documentation
Getting Started on Windows
A note to Cygwin and MinGW users
If you plan to use your tools from the Windows command prompt, you're in the right place.
If you plan to build from the Cygwin bash shell, you're actually running on a POSIX
platform and should follow the instructions for getting started on Unix variants.
Other command shells, such as MinGW's MSYS, are not supported—they may or may not work.