MSYS starts in wrong root directory - msys

I accidentally closed MSYS while compiling CMake project and now MSYS is broken. When MSYS starts up it prints sh-3.1$ instead of Username$ like it used to. It also creates a directory called etc in the /home directory. Any MSYS commands don't work neither (ls, cmp, etc.).
My best quess is that for some reason it thinks /home is my root directory. Maybe the compiling messed up some environment variable or something like that?
How do I fix this?

Removing all the MinGW files and reinstalling helped.

Related

How to add MinGW to PATH?

I'm following this tutorial by vscode to install a C++ compiler on Windows. Right now, I'm trying to edit C:\msys64\mingw64\bin to environment variables and save MinGW to path. I clicked OK multiple times but seems like it can't save. I also entered g++ --version and gdb --version to check for installation. It just shows "'g++' is not recognized as an internal or external command,
operable program or batch file."
If reinstalling MinGW doesn't work, add MinGW to PATH manually by this:
Find your computer's property, and then go to Advanced.
Click Alt+N
Find PATH in the box below.
Add the path of your MinGW compiler to it.
Note: Add the BIN folder.
If adding the BIN folder doesn't work, add the BIN folder in the folder under C:\msys64\mingw64 that has a long name like this:
x86_64-w64-mingw32
or whatever your folder is named.
IMPORTANT NOTE: REMEMBER TO RESTART YOUR COMPUTER AFTER DOING THIS.

Why can I use CMake supplied modules (CMakeDependentOption.cmake specifically) locally, but not on CI or Docker?

I have a cmake project that successfully builds locally but errors with
include could not find load file:
CmakeDependentOption
when trying to build on a CI platform or in Docker. Note that CMakeDependentOption.cmake is a script that comes with cmake itself. So it should just be available. On CI to install cmake, I wget the relevant cmake release from their downloads page, unzip it and add the bin directory to the PATH environment variable. Then I use the cmake command to build my library. The result is the above error.
I suspect this means that a CMake variable (such as "CMAKE_MODULE_PATH" but not, since this variable seems to be empty at the start of the cmake script) is messed up or not set somehow. The path to the correct file to include is
<cmake_root>/share/cmake-3.18/Modules/CMakeDependentOption.cmake
And I have verified that it exists manually. My question: is there a way to locate this directory from within cmake? Perhaps a cmake --config or cmake --libs mode (a bit like pkg-config?)
Failing that, does anybody have any suggestions as to why this is happening and how to get around it.
You can locally because most likely you don't use a linux based platform, like windows or mac. This is because linux filesystem are case sensitive. Which means CmakeDependentOption is different from CMakeDependentOption.
Docker runs containers in linux, so filenames are gonna be case sensitive, and the include is going to fail if the cases are different.

Clion "Cannot load CMake project: CMake executable is incorrect" issue

I ran into a problem while trying to use Clion.
I imported a project, yet all off the headers and .cpp files are greyed out. The error shown is as in the title: "Cannot load CMake project: CMake executable is incorrect".Here is a screenshot of it.
It's worth noting that I'm working with kubuntu and have downloaded all of the following: gcc, g++, make, cmake, gdb.
I would love some help with solving this problem so I could start working with Clion.
Thanks in advance.
I just ran into this. Deleting the project's .idea directory and having clion recreate it fixed the issue for me.
Clion also reported that Bundled Cmake does not work in this enviroment
And when setting the actual path to the cmake binary it said it wasn't there when it was.
make a c executable project.
go to file->settings
Look for a setting where you can configure the path of Cmake on your system (maybe /usr/bin/cmake).
Clion hasn't found cmake executable
first case cmake isn't installed :
1.1. ubuntu : sudo apt-get install cmake
1.2. Go to Settings->Build,Execution,Deployement-> Toolchains:
set cmake executable to custom , and type : which cmake in your console
set field right to custom to dir of cmake
do same thing for gdb the apply
second case cmake is install then go to (1.2)
I am using WSL (wsl2 to be correct) and I had the same issue. Somehow CLion seems to have a problem with /usr/bin/cmake only being a link to the real cmake file. So to resolve this, follow each link till you hit the location of the executable
for windows users being new to linux:
which cmake (most probably shows /usr/bin/cmake)
cd /usr/bin/cmake
ls -la | grep cmake (shows something like 20 Mar 26 09:54 cmake -> /opt/cmake/bin/cmake)
do this till there is no link anymore
pass this path to clion
I already added this as a bug: https://youtrack.jetbrains.com/issue/CPP-20644

GDB not a recognized command - Windows command prompt

I am trying to use GDB to debug a C++ program, but my system is not recognizing gdb as a command. I installed it, along with many other tools, via MinGW. I have not had any problem with the other features I have used (gcc, g++), so the issue doesn't seem to be with my general set up. I have added the MinGW\bin directory to my PATH. The gdb.exe is in that folder. But it will not run when invoked from my project directory, it simply errors: "'gdb' is not recognized as an internal or external command, operable program, or batch file." Is there some step in setup or invocation that I missed for using GDB?
EDIT: Alright, I think I found the problem: there are two MinGW directories in my PATH, one at C:\MinGW, and another in folder that got installed with some Haskell compilers I used a while ago. It appears to be defaulting to the Haskell folder, perhaps because this directory is listed first. However, this folder contains gcc and g++, but NOT gdb. I was able to get the gdb command working by creating the fstab file in the msys directory, a step I apparently forgot when setting up MinGW. I added my C:\MinGW directory to it, and now the gdb command is working properly! Out of curiosity, what does this file do?
Also, ideally I would like it to look in the C:\MinGW directory first, since this is the folder I plan to keep updated, and the one that contains ALL of the various applications. However, the Haskell directory is specified via the system PATH variable, which I've read it's not a good idea to touch. Would switching the order that they appear even fix my problem?
EDIT 2: Not 100% sure what happened, but the gdb command appears to be working now. I have always been using the Windows cmd prompt to run these tools, so per the answer below (that I should not need to mess with msys) I deleted the fstab file, and lo, it still works! However, my second question above still stands: What is the best way to get the compilers to run out of C:\MinGW\bin instead of C:\Program Files (x86)\Haskell Platform\2013.2.0.0\bin? Is moving the Haskell location out of the system PATH and to the end of the user PATH a viable option?
I had to run pacman -S mingw-w64-x86_64-gdb separately and then gdb showed up in the bin.
You do not have to run gdb (or gcc and all other MinGW tools for that matter) within msys - it is not like Cygwin in that respect. Had you run it from the Windows cmd console, it should work.
The msys shell is useful for running configure scripts generated by Autoconf used by many Linux originated open source projects, but its environment is independent of the Windows environment.

Eclipse CDT build error: make not in path

I just recently(actually today) started using Eclipse CDT for windows. Created a project, a test C file(Hello World) added to project. Build the project, I got error as below.
Error: Program make is not found in Path -
So then I read that Eclipse CDT needs Mingw/MSYS, which I did install. Now i See that there is make.exe in
C:\MinGW\msys\1.0\bin
But Since I dont have administrator privileges, I could not add this folder containing make to the Path system variable on Windows. (I am not likely to get administrator privileges)
Now how do I work around this error to build and use CDT on windows? Any Project settings for Eclipse CDT which if added the path to make could help resolve this?
Was able to get a fix around this problem.
Added the correct paths for two exes - make and gcc/g++ (installed by Mingw/Ansys) to the User environment variable Path (Was not allowed to edit System variable Path).
But adding these paths to User environment variable Path also helped to resolve this. Now Eclipse CDT built and executed the code fine.
check environment variable path has c:/cygwin/bin or c:/mingw/bin or wherever u installed it
if makefile name is mingw32-make.exe or something else , make a copy and rename that to make.exe
The problem is simply that your IDE need to know where is the place of GNU Binary Utilities so how to deal with that simple go to
Windows -> preference -> C/C++ -> new c++ project wizerd -> makefile
then chose what are u instal for example I use MinGW so now I will chose GUN elf parse and now I need the location for c++ filt :D
you will go to place where u install minGW in default it will be C:\MinGW
and search for c++ filt.exe :D and now u done :D
and you can install minGW from
http://www.mingw.org/
Also after adding C:\MinGW\bin to PATH variable. Make sure your new project is created with MinGW GCC toolchain as shown below.