NetBeans 15 - C++ development (CCLS, GCC) - gcc

I want to start C++ development with NetBeans 15, on Lubuntu Kinetic Kudu (22.10).
I installed first build-essential
sudo apt install build-essential
g++ --version
g++ (Ubuntu 12.2.0-1ubuntu1) 12.2.0
gcc --version
gcc (Ubuntu 12.2.0-1ubuntu1) 12.2.0
When selecting Tools > Options > C/C++ it says that either ccls or the clangd language protocol servers are needed.
I installed ccls
sudo apt install ccls
ccls --version
Ubuntu ccls version 0.20220729-1
clang version 14.0.6-2
Not sure if I should have installed clangd instead or in addition to ccls.
Now when I start NetBeans 15 choosing the C/C++ option it automatically selected the path to ccls
/usr/bin/ccls
Now I wanted to start a first Hello World C++ project, but somehow it looks complicated.
I would like to use the highest possible C++ standard version. The installed build-essential comes with version 12.2, and here for example https://gcc.gnu.org/onlinedocs/12.2.0/ I assume that for C++ it supports Standard 20 or even higher. I looked into it the very first time.
1. Choose Project: File > New Project > C/C++ > Lightweight C/C++ Project
2. Location: Project Path
I created a new folder myfirstcpp in /home/me/NetBeansProjects and selected it on this step.
3. Editor: Compile Commands
Here no clue what to specify.
I leave it empty and proceed.
4. Build: "Configuration Name", "Build", "Clean" and "Run"
Here no clue what to specify.
I leave it empty and proceed.
The project is created but completely empty, no artifact created upfront.
I created a CPP file and copied the following code from the web
// C++ program to display "Hello World"
// Header file for input output functions
#include <iostream>
using namespace std;
// Main() function: where the execution of program begins
int main()
{
// prints hello world
cout << "Hello World";
return 0;
}
But the editor shows a yellow warning triangle stating compile commands not configured. Also no option to run that simple Hello World programm, every Run option is greyed out.
Obviously I have to configure steps 3-4 properly.
How?
Update on #skomisa comment
I found that post before, but placing a .ccls file with the exact same content
/home/me/NetBeansProjects/myfirstcpp/.ccls:
g++
-xc++
-Iinclude
-std=c++17
didn't change anything. Now I tried again, and after clicking around in the Project Properties in the Editor category by removing and adding the path /home/me/NetBeansProjects/myfirstcpp/.ccls to the .ccls file, switching into the Build category without changing anything, all of a sudden the Run options were active.
Weired, looks buggy to me... also when I closed NetBeans, restarted, everything was again greyed out, until I clicked around again in the Project Properties until the Run options appeared active.
However, when I clicked the Run Project (myfirstcpp) option I got this exception in the Output window
Exception in thread "main" java.io.IOException: Cannot run program "": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at org.netbeans.modules.cpplite.project.runner.Runner.main(Runner.java:35)
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:315)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:245)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
... 2 more
Either the content in the .ccls file is not correct or incomplete, or in addition the Build category has to be configured too.
I use OpenJDK
java --version
openjdk 18.0.2.1 2022-08-18
OpenJDK Runtime Environment (build 18.0.2.1+1-1)
OpenJDK 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing)
if this is relevant.

Just installed NB15 on Ubuntu 22.04 and running C++ (using gcc/g++12) project. Follow mostly from
https://stackoverflow.com/a/66832862/6760184
Enable C++:
Open Tools/Plugins/Settings
Check NetBeans 8.2 Plugin Portal
Go back to Available Plugins and press Check for Newest button.
Check C/C++ plugin and press Install button.
specify unpack200 location
Pre-13 OpenJDK is bundled at, for example, /usr/lib/jvm/java-11-openjdk-amd64/bin/unpack200 It is gone after version 14.
Or, install with sudo apt install mlocate and use ls -l `locate unpack200` to locate unpack200.
Enable C++17
Download and install NBM plugins.
https://github.com/dmochalov/PasteBin/tree/master/NetBeansDevBuild download for nbbuild_cndplugins_2018.zip
Unpack nbbuild_cndplugins_2018.zip to a folder
Open Tools/Plugins/Downloaded/Add Plugins… and select all 64 plugins then click Install.
Enable C++20
Right click project Properties/C++ Compiler/Additional Options and add
-std=c++20
Hope this helps!

Related

nvim_treesitter installation on windows

bad English (sorry).
I'm trying to get nvim_treesitter to work on my windows machine, on my Linux one it worked great but now when I try on windows the :checkhealth nvim_treesitter gives:
health#nvim_treesitter#check
Installation
ERROR: tree-sitter executable not found
OK: git executable found.
ERROR: cc executable not found.
ADVICE:
Check that either gcc or clang is in your $PATH
Parser/Features H L F I
Legend: H[ighlight], L[ocals], F[olds], I[ndents]
*) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}
and I'm totally new to this thing, any advice would help:)
The main issue from my perspective is "ERROR: cc executable not found.". It means nvim_treesitter couldn't find any compiler on your machine, and so no parsers could be compiled and installed when you issue ":TSInstall {some_parser_name}" commands.
If you have Visual Studio installed (since nvim gets compiled by VS 2017, it's fine to have 2017 or 2019 studio, I guess), try this:
Run "x64 Native Tools Command Prompt for VS 201x" if you've downloaded nvim-win64 release package or "x86 Native Tools Command Prompt for VS 201x" otherwise (nvim-win32 package)
Run nvim in this command prompt (i.e. nvim-qt GUI)
Install any parsers you want, let's say ":TSInstall c". Output should look like this:
Downloading...
Compiling...
Treesitter parser for c has been installed.
Optionally run :checkhealth nvim_treesitter again to see if everything is fine
Thereafter you can run nvim in any console, not via VS Tools one only (still use it to install or update parsers though).
Please also see https://github.com/nvim-treesitter/nvim-treesitter/wiki/Windows-support for various instructions.
For the Error: tree-sitter: You can checkout creating parsers and follow the description or you download the windows binary of the binary files and put it into a directory on your PATH.
For the Error: cc: You need to install gcc
Try to apply this vsc tutorial from Prerequisites №3
I had the same issue. It helped me.
Ok, here's what I've done and what helped me:
Go to https://www.msys2.org and follow ALL of the installation steps that are described there:
Download and install
Run pacman -Syu comman
Run pacman -S --needed base-devel mingw-w64-x86_64-toolchain and choose mingw-w64-x86_64-gcc there.
After everything is installed, put into your PATH Environment Variable the path to MinGW64\bin folder (if you installed everything to the default folder it will be c:\msys64\mingw64\bin)
And you are good to go! Now open nvim and run
:TSInstall <yourlang>
For example, :TSInstall php
PS: you can get the list of available languages using :TSInstallInfo

Windows IDE for Haskell

I need to setup a simple and compelling dev environment for small proyects written in Haskell in Windows machines for freshmen.
I have tried several ways to integrate Haskell into VSCode in Windows with no success.
I had a nice setup a few years ago, but I´m finding problems with dependencies recreating that environment:
Editor: Atom
Global binaries build using: stack with ghc-mod hlint stylish-haskell
Atom plugins: language-haskell, ide-haskell, ide-haskell-repl, haskell-ghc-mod
It seems that the "cool" way right now is Language Server Protocol + VScode. ghc-mod seems not to be mantained anymore, Intero has reached EOL, HEI is merging with another project... Having a stable and updated dev environment looks like a moving target.
So, the question is: does anyone have reproducible step-by-step instructions for having VSCode working with Haskell in Windows?
I will test any suggestion in a fresh Windows 10 64bits VM and report the results.
Note: VSCode + Docker container is not an option. Most of the student´s machines have 4GB RAM.
Thanks in advance.
There's a tool called ghcid (not to be confused with ghcide) that, while nowhere near a full-blown IDE, is pretty robust and provides some niceties like re-compiling on save and showing compile errors. It doesn't support go-to-definition though. It has a VSCode plugin.
Here's a possible way of setting up things in Windows:
Download the GHC 8.8.3 binaries for Windows from here.
Download the cabal-install 3.0.0.0 binaries for Windows from here.
Decompress them in some folder.
Add entries to your PATH environment variable so that it has access to the /bin folder of the GHC installation and to the folder containing the cabal executable.
Open a Powershell console.
Run cabal udpate
Run cabal install --install-method=copy --installdir=somefolder ghcid to install the ghcid executable, where "somefolder" is the destination folder. (If the installation fails, try running the command from a Git Bash or Cygwin terminal as a workaround.) Put the destination folder in PATH.
Open (or restart) VSCode and install the "Haskell Syntax Highlighting" and haskell-ghcid plugins.
Go to an example cabal project, use the Ctrl-Shift-P shortcut, and execute the Start ghcid action. The ghcid terminal will appear.
Example of a ghcid session showing an error:
The haskell-ghcid plugin can read a .ghcid file in the project root containing flags that should be passed to the ghcid command.
Extra instructions to set up code formatting:
Install the ormulu formatter by running cabal install ormolu --install-method=copy --installdir=somefolder. Again, make sure that the destination folder in in PATH.
Open (or restart) VSCode and install the ormulu plugin.
Now the "Format Document" and "Format Selection" actions in VSCode will use ormulu.
Another way of installing GHC and getting to ghcid and ormulu could be by using the stack tool, which handles GHC installation by itself.

Can't find file executable in your configured search path for gnc gcc compiler

My problem is that code::blocks error message tells me that it can't find file executable in the search path for gnc gcc compiler. Although, I don't know what that means. Also I typed out some code:
#include <iostream>
using namespace std;
int main(void) {
cout <<"Hello World" <<endl;
return 0;
}
I can't build it or run in code::blocks. What do I need to do?
I went on line but I got some answers that are way over my head. I was able to use code::blocks once before I installed Visual studios express 2013. Visual studios didn't work right either. It kept asking me to repair or uninstall every time I tried to open it. So I deleted it along with code::blocks. Now that I re-installed code::blocks I still can't get to work right.
This problem with compilers is taking up all my time and I can't practice learning programming because I can't get any compiler to work right. I need some help, please.
I'm guessing you've installed Code::Blocks but not installed or set up GCC yet. I'm assuming you're on Windows, based on your comments about Visual Studio; if you're on a different platform, the steps for setting up GCC should be similar but not identical.
First you'll need to download GCC. There are lots and lots of different builds; personally, I use the 64-bit build of TDM-GCC. The setup for this might be a bit more complex than you'd care for, so you can go for the 32-bit version or just grab a preconfigured Code::Blocks/TDM-GCC setup here.
Once your setup is done, go ahead and launch Code::Blocks. You don't need to create a project or write any code yet; we're just here to set stuff up or double-check your setup, depending on how you opted to install GCC.
Go into the Settings menu, then select Global compiler settings in the sidebar, and select the Toolchain executables tab. Make sure the Compiler's installation directory textbox matches the folder you installed GCC into. For me, this is C:\TDM-GCC-64. Your path will vary, and this is completely fine; just make sure the path in the textbox is the same as the path you installed to. Pay careful attention to the warning note Code::Blocks shows: this folder must have a bin subfolder which will contain all the relevant GCC executables. If you look into the folder the textbox shows and there isn't a bin subfolder there, you probably have the wrong installation folder specified.
Now, in that same Toolchain executables screen, go through the individual Program Files boxes one by one and verify that the filenames shown in each are correct. You'll want some variation of the following:
C compiler: gcc.exe (mine shows x86_64-w64-mingw32-gcc.exe)
C++ compiler: g++.exe (mine shows x86_64-w64-mingw32-g++.exe)
Linker for dynamic libs: g++.exe (mine shows x86_64-w64-mingw32-g++.exe)
Linker for static libs: gcc-ar.exe (mine shows x86_64-w64-mingw32-gcc-ar.exe)
Debugger: GDB/CDB debugger: Default
Resource compiler: windres.exe (mine shows windres.exe)
Make program: make.exe (mine shows mingw32-make.exe)
Again, note that all of these files are in the bin subfolder of the folder shown in the Compiler installation folder box - if you can't find these files, you probably have the wrong folder specified. It's okay if the filenames aren't a perfect match, though; different GCC builds might have differently prefixed filenames, as you can see from my setup.
Once you're done with all that, go ahead and click OK. You can restart Code::Blocks if you'd like, just to confirm the changes will stick even if there's a crash (I've had occasional glitches where Code::Blocks will crash and forget any settings changed since the last launch).
Now, you should be all set. Go ahead and try your little section of code again. You'll want int main(void) to be int main(), but everything else looks good. Try building and running it and see what happens. It should run successfully.
Just open your setting->compiler and click on the reset defaults and it will start work.
* How to Download and install CodeBlocks.* ( I have already downloaded )
***How to solve the CodeBlocks environment error.
Go to "Settings"----"Compiler"----"Selected compiler"( GNU GCC Compiler ).
Then, Selected "Toolchain executables".
Now, "( C:\Program Files (x86)\CodeBlocks\MinGW )"
See Video : https://youtu.be/Tb1VnXs60Lg
I had also found this error but I have solved this problem by easy steps. If you want to solve this problem follow these steps:
Step 1: First start code block
Step 2: Go to menu bar and click on the Setting menu
Step 3: After that click on the Compiler option
Step 4: Now, a pop up window will be opened. In this window, select "GNU GCC COMPILER"
Step 5: Now go to the toolchain executables tab and select the compiler installation directory like (C:\Program Files (x86)\CodeBlocks\MinGW\bin)
Step 6: Click on the Ok.
Now you can remove this error by follow these steps. Sometimes you don't need to select bin folder. You need to select only (C:\Program Files (x86)\CodeBlocks\MinGW) this path but some system doesn't work this path. That's why you have to select path from C:/ to bin folder.
Thank you.
For that you need to install binary of GNU GCC compiler, which comes with MinGW package. You can download MinGW( and put it under C:/ ) and later you have to download gnu -c, c++ related Binaries, so select required package and install them(in the MinGW ). Then in the Code::Blocks, go to Setting, Compiler, ToolChain Executable. In that you will find Path, there set C:/MinGW.
Then mentioned error will be vanished.
Uninstall/Remove your current codeblocks compiler.
Install codeblocks using this link that contains GCC compiler files: http://sourceforge.net/projects/codeblocks/files/Binaries/13.12/Windows/codeblocks-13.12mingw-setup-TDM-GCC-481.exe.
Now go to : Settings > Compiler.... > ToolChain Executables Tab
CLICK on Auto-detect button and then click OK button. Now just restart CodeBlocks and start writing your codes and use the Build and run option. It will RUN normally.
Fistly, Code Blocks is not a compiler. It is just an integrated development environment.
So, you must show the path of your compiler at first, (if you dont have a compiler you have to download an install, it is not difficult to find. f.e. GCC is good one.)
If code blocks could not find automatically the path of compiler it is an obligation to show it yourself.
But when you install, probably Code Blocks automatically find your compiler.
Enjoy.
This simple in below solution worked for me.
http://forums.codeblocks.org/index.php?topic=17336.0
I had a similar problem. Please note I'm a total n00b in C++ and IDE's but heres what I did (after some research)
So of course I downloaded the version that came with the compiler and it didn't work. Heres what I did:
1) go to settings in the upper part
2) click compiler
3) choose reset to defaults.
Hopefully this works
I'm a total noob but I reinstalled over the codeblocks giving me these "Can't find file executable in your configured search path for gnc gcc compiler" errors by downloading:
codeblocks-20.03mingw-setup.exe
(IMPORTANT: make sure it has the "mingw" in the file download name, that has the compiler build that is required to compile the code which doesn't automatically comes with the main codeblocks editor software download because codeblocks already assumes you already have another compiler installed on your computer {visual studio 2019 or such}).
Then when I created a new project (console application) and used the defaults to quickly test it out.
It gave me errors.
So I went to Settings > Compiler > Selected Compiler set to: GNU GCC Compiler > Click on the "Tooolchain executables" tab > Click on Auto-Detect > Should say "C:\Progam Files\CodeBlocks\MinGW" > Click OK.
Build and run a simple hello world code.
Should work! If not, look for the "MingGW" in the C:\Program Files\CodeBlocks and select it.
Here's an easy way for Windows users.
Uninstall the existing codeblocks from your system.
Restart system.
Go to http://www.codeblocks.org/downloads/26
Download the codeblocks-16.01mingw-setup.exe file. It includes the GCC/G++ compiler and GDB debugger from TDM-GCC (version 4.9.2, 32 bit, SJLJ).

Rust installation on Windows

I was trying to get Rust to work on my Windows box. I followed the instructions, however when I tried hello world program, it spits the below. It looks like it has not been able to link up to gcc.. and I have gcc out there. Could someone help me figure out what is the issue here?
$ rustc foo.rs
error: linking with `gcc` failed: exit code: 1
note: gcc arguments: '-m32' '-LC:\Program Files (x86)\Rust\bin\rustlib\i686-pc-m
ingw32\lib' '-o' 'foo' 'foo.o' '-shared-libgcc' '-LC:\MinGW\msys\1.0\home\ENwank
wo\.rust' '-LC:\MinGW\msys\1.0\home\ENwankwo' 'C:\Program Files (x86)\Rust\bin\r
ustlib\i686-pc-mingw32\lib\libstd-3e5aeb83-0.9.rlib' 'C:\Program Files (x86)\Rus
t\bin\rustlib\i686-pc-mingw32\lib\libgreen-83b1c0e5-0.9.rlib' 'C:\Program Files
(x86)\Rust\bin\rustlib\i686-pc-mingw32\lib\librustuv-2ba3695a-0.9.rlib' '-lws2_3
2' '-lpsapi' '-liphlpapi' '-lmorestack'
note: gcc: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found
compilation terminated.
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', C:\bot\slave\dist2-win\build\src\libs
yntax\diagnostic.rs:75
task '<main>' failed at 'explicit failure', C:\bot\slave\dist2-win\build\src\lib
rustc\lib.rs:453
This is how to install Rust on windows with Visual Studio Code and optionally MSYS2 MinGW
You can Instal Rust without installing "Microsoft C++ Build Tools". You can also use Rust with the gcc or clang tools from the MSYS2 suite.
I didn't want to install Rust on Windows with the required "Microsoft C++ Build Tools" because this would need too much disk space.
To get Microsoft C++ Build Tools on Windows you need to download a full Windows SDK which is very large (I think more than 4GB).
You can run and debug Rust programs without installing MSYS2.
If you want to use the gcc or clang compilers that are included in MSYS2 (you will need to install them in a separate step from the MSYS2 installation, using the version of the pacman package manager from MSYS2), then you can install MSYS2.
(MSYS2 also allows you build very easily, C++ programs inside Visual Studio Code with the C++ extensions installed, using the gcc or clang compilers).
The MSYS2 installation version needs 1.61 GB for MSYS2 ( The tools installed using mingw-w64-x86_64-toolchain occupy 1083.49 MiB of disk space out of the 1.61 for the total MSYS2 suite).
Rust installs about 1.46 GB of files - mostly in the "C:\Users\user\.rustup" folder when using the parameter "x86_64-pc-windows-gnu" (for a MSYS MinGW install).
Rust takes up 900 MB after installation, when using "x86_64-pc-windows-msvc" (for a "Microsoft C++ Build Tools" install).
For a better Rust experience inside VS Code it is recommended to install the rust-analyzer extension Online from the VS Code Marketplace, or instead of it, the Rust plugin from [Link1] below, at the bottom of the post.
All you have to do is:
Install Visual Studio Code
(Optional - Install MSYS2)
Install Rust
Install Pyton if you don't have it
Add the required folders to the PATH variable
Install rust-analyzer and CodellDB extensions inside VS Code
At the end of this guide you should be able to run and debug rust programs inside Visual Studio Code.
MSYS2 is optional, you can install it if you want to use the gcc or clang from the suite - after creating the cargo config file, the cargo build and cargo run commands will use msys64\mingw64\bin\clang++.exe (by default if both compilers are installed, or ..\msys64\mingw64\bin\gcc.exe if you set it up to do this).
Just follow the installation from Part 1 - below.
(This part is just for reference - it lists the files and folders required for setup and how I chose the installation directories - )
I installed the programs inside these folders:
D:\Applications\msys64
D:\Applications\VSCode
rustup-init.exe installs the .cargo folder in the default location:
C:\Users\user\.cargo
( The settings files for VS Code are created and edited inside the Visual Studio Code editor, you don't need to open the files form windows explorer:
C:\Users\user\AppData\Roaming\Code\User\settings.json
C:\Users\user\AppData\Roaming\Code\User\keybindings.json
)
Part 1 - Installation Steps with Details:
I will use the code needed to run the installation programs inside "quotes" - remove the quotes when you run the commands.
For example: "pacman -Syu" - remove the quotes and just run pacman -Syu .
Change the paths in the tutorial, for your installations.
The programs needed are VS Code, MSYS2 (MSYS2 has files/tools from MinGW), the rust-analyzer extension for VS Code for code completion and the CodeLLDB extension (with the author Vadim Chugunov) for debugging.
Make sure to have the Windows Firewall setup to allow connections out for MSYS2, VS Code, the Rust installer - rustup-init.exe (maybe rustup later on - during this tutorial you don't need it) and D:\Applications\msys64\usr\bin\pacman.exe. This will allow the programs to download necessary files for components or plugins.
a)
Download Visual Studio Code portable version for Windows from filehorse.com and extract the files (or install it any way you like).
Open VS Code and disable the 2 telemetry options from the settings:
Click on Edit > Preferences > Settings, type telemetry in the input box and disble the 2 telemetry options (or press the key combo: Ctrl + Shift + P, type open settings and press Enter to open the 'settings.json' file)
this will put inside the "settings.json" file this code, between the main open and close curly braces:
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false
Good fonts to use inside VS Code are: Fira Code, Consolas, DejaVu Sans Mono, Droid Sans Mono Slashed, Inconsolata-g, Bitstream Vera Sans Mono , Lucida Console, maybe Menlo Regular (was used in MacOS), Meslo LG DZ.
Fonts like 'Fira Code' have font ligatures present inside the font. 'Fire Code' doesn't have traditional font ligatures for example ft is not connected, but has ligatures specific for coding, for example the look of these character combinations are changed and usually look better with ligatures enabled: fl , -> , <= , >= . See the image below the post for an image with font ligatures on vs off.
To enable font ligatures, open the Preferences for Visual Studio Code, search for ligatures in the search box, and enable the setting: 'Editor:Font Ligatures' .
You can change the default user data directory from:
"C:\Users\user\AppData\Roaming\Code" to your desired location, e.g. :
"D:\Applications\VSCode\UserData\Code"
by creating a shortcut for VSCode with the parameter --user-data-dir, that you'll use to launch VS Code.
To do this create a shortcut for VSCode with the setting for Target: D:\Applications\VSCode\Code.exe --user-data-dir "D:\Applications\VSCode\UserData\Code"
b) This step is Optional, follow it only if you want to use gcc or clang from MSYS2:
You can run Rust programs and compile them in Visual Studio Code without installing MSYS2. Install MSYS2 only if you want to use its gcc or clang compiler.
Optional - Install MSYS2 - this is about 1.61 GB.
Download MSYS2 and follow the installation instructions - I will mention the most important steps:
Install MSYS2 and keep the checkbox selected: "run MSYS2 64bit" at the end of the installation.
Run pacman -Syu in the console that appears after the installation. This is the MSYS2 shell.
!!! For the next step, be careful an choose the right shortcut Don't choose the MinGW one, so
run the shortcut named "MSYS2 MSYS" from Start menu (it is "D:\Applications\msys64\msys2_shell.cmd -msys"). This is the MSYS2 shell.
Inside the shell run pacman -Su .
The next step is to download the programs needed to build the programs written in Rust, for the Windows Platform:
From the start menu run "MSYS2 MinGW 64-bit" (it is "D:\Applications\msys64\msys2_shell.cmd -mingw64"). This is for MinGW and it has a different parameter from the shortcut used above.
Run pacman -S mingw-w64-x86_64-toolchain.
Press Enter, Enter and type 'y' during the installation process.
( The guide on the msys2.org page said to also install some packages using the option '--needed base-devel' by runnig the command "pacman -S --needed base-devel mingw-w64-x86_64-toolchain", but I don't think they are needed here.
If you want, you can install single tools and their dependencies from the list of tools installed by the command "--needed base-devel", by selecting their corresponding number during the installation, for example you can just install make and not the rest of the tools present in the "--needed base-devel" package.
The simple rust "hello world" program that I wrote in rust using VS Code and the rustc and cargo tools/programs ran well without installing the "--needed base-devel" files.
The --needed base-devel files are not needed to run and debug simple Rust programs,but you can install them if you want.
To use the gcc or clang linker and compiler from MSYS2 you have to create the C:\Users\user\.cargo\config file:
To make the cargo use clang++.exe , add these lines to the C:\Users\user\.cargo\config file:
[target.x86_64-pc-windows-gnu]
linker = "D:\\Applications\\msys64\\mingw64\\bin\\clang++.exe"
ar = "D:\\Applications\\msys64\\mingw64\\bin\\llvm-ar.exe"
If you want to change the linker to gcc, create the C:\Users\user\.cargo\config file that contains the lines:
[target.x86_64-pc-windows-gnu]
linker = "D:\\Applications\\msys64\\mingw64\\bin\\gcc.exe"
ar = "D:\\Applications\\msys64\\mingw64\\bin\\ar.exe"
(clang++.exe is the same file as clang.exe from the same directory.)
I got everything installed and running well - I could run the programs and debug them using gcc or clang.
)
c)
Install Rust for Windows
Download the installer: rustup-init.exe from rust-lang.org
The browser should recognize that you ar using Windows and give you the link to "DOWNLOAD RUSTUP-INIT.EXE (64-BIT)" , that is:
[...]static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
Run rustup-init.exe . It is better to launch a console with cmd.exe and launch rustup-init.exe from there.
choose "Continue? (y/N)" by typing y and hitting the Enter key.
choose "2) Customize installation" using the keyboard.
paste or type the option: x86_64-pc-windows-gnu .
Press enter for the rest of the options.
Finally type "1" as input in the console, then press Enter, to choose the option "1 to proceed" with the Current installation Options.
There might be problems if you had rustup already installed.
If you already have rustup installed follow the indications on the guide at Source 1 Link at the bottom of the page with the step-by-step-instruction-to-install-rust-and-cargo-for-mingw-with-msys2 :
This is a quote from that post:
"Note: If rustup is already installed, then rerunning rustup-init won't actually install the requested toolchain. Instead, run rustup toolchain install stable-x86_64-pc-windows-gnu if you already have the MSVC-based toolchain. Then run rustup default stable-x86_64-pc-windows-gnu to set the GNU-based toolchain as the default."
d) Add the folders to the PATH
Add the folders that have useful programs from rust and msys2 to the Windows system PATH variable:
Adding the folders to the system PATH variable will allow VS Conde console, which defaults to PowerShell (you can change it to Command Prompt or other shell if you want), to recognize the commands:
cargo, rustc, etc.
This will make running and debugging rust programs in VS Code with the rust-analyzer and CodeLLDB extensions easy because you don't have to configure anything else.
To add the folders to the PATH use the System Properties window:
Right click on "My Computer" and select "properties"
Click on Advanced System Settings
In the Advanced tab, click on "Environment Variables"
under 'User variables for user' click on the PATH Variable and add the locations of your cargo\bin folder and mingw64\bin folder, (plus \msys64):
;C:\Users\user\.cargo\bin;D:\Applications\msys64;D:\Applications\msys64\mingw64\bin
This will add the folders "C:\Users\user\.cargo\bin", "D:\Applications\msys64", "D:\Applications\msys64\mingw64\bin" to the PATH variable. (stackoverflow is bad at formatting \. backslash followed by a dot - you have to use another backslash as an escape character)
To test that the PATH variable is updated open a NEW Command Prompt or PowerShell window, and in this window run cargo --version or gcc --version (if you installed MSYS2 and gcc.exe) or rustc --version inside a 'Command Prompt' window and inside a PowerShell Window.
If the commands are not found, restart your computer so that Windows can update the PATH variable. For me the change worked without having to restart, I just had to open a new shell window.
e) Install the Rust extensions for VS Code
rust-analyzer and CodeLLDB require Python to be installed.
Install Python 3.6.3, for example, and select to add it to the path during installation.
From the VS Code Marketplace install the needed extensions.
Open VS Code, click on the Extensions button on the right toolbar, and search and install the extensions:
rust-analyzer - (publisher: matklad) ;
CodeLLDB (publisher: Vadim Chugunov);
( I didn't have to do this next step so you shouldn't either - if rust-analyzer doesn't load/run properly, you may need to install the rust source code.
Using the 'Command Prompt' run: rustup component add rust-src to install the rust Source Code.
I didn't have to install it, the rust-analyzer worked well [ by the way, the VS Code could connect to the internet during testing].
)
[While running Visual Studio Code you may get a message telling you to install .Net Framework 4.5.2. Download and install the Offline version if the online version fails to install. (On Windows 7 without some updates, you may have to download and install the certificate: MicRooCerAut2011_2011_03_22.crt, and install some windows updates: Windows6.1-KB2533623-x64, windows6.1-kb2813430-x64, and maybe Windows6.1-KB4019990-x64 ) ]
Part 2 - Running and Debugging Rust programs with VS Code
Running and compiling in Rust with VS Code and Msys2:
After adding the folders to the PATH and installing the extensions, you basically need to run:
cargo init
cargo run - to run the program.
press the F5 key, or click the debug button to debug the code.
First you need to:
Create a folder for your Rust app.
Open the folder inside VS Code.
Press Ctrl+{`} to open the terminal panel.
The default shell will be 'PowerShell'.
You can select the 'Command prompt' shell from the Terminal pane using the down arrow on the left, that is near the plus button and x button.
Or you can set VS Code to use 'Command Prompt' as the default shell by adding the lines to the 'settings.json' file - the main Visual Studio Settings file.
"terminal.integrated.defaultProfile.windows": "Command Prompt",
You can use PowerShell or 'Command Prompt', they both work fine.
Run cargo init inside the terminal to create the project files.
Edit the main.rs file if you want. It is located inside 'app folder'\src\main.rs
Run cargo run inside the terminal
If you have rust-analyzer installed, the extension puts 2 buttons as popups on top of the main() function.
They are named 'Run' and 'Debug' and if clicked they do what their names say.
To debug, put a breakpoint inside your main.rs file and hit F5 (the menu entry Run > Start Debugging) or click the Debug button on top of the main() function placed there by the rust-analyzer extension if you have it installed.
If you click the debug button you don't have to create a launch.json config file.
If you hit the F5 key or click the menu entry Run > Start Debugging, a launch.json file will be added to your folder.
Just click Yes in the message box to auto generate the launch.json file.
Then hit the F5 key again to start debugging.
Now you can step through your code during the debugging process.
Link 1: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust
Link to Font Ligatures example - Image for the font 'Fira Code':
Image Link: Coding font with font ligatures
This question is old, but in the mean time a lot has changed.
The easiest way to install on Windows is to go to the Rust installation page and download and run rustup-init.exe. It installs rustc, rustup and similar tools. It just works™.

Compile OpenCV (2.3.1+) for OS X Lion / Mountain Lion with Xcode

Can anyone provide me some detailed guide how to compile OpenCV 2.3.1 on OS X Lion with Xcode?
I'm getting mad about this … I got the source, used cmake to create the Xcode template and tried to build it, but it fails with about 200 errors.
Thanks in advance,
Dom
SOLUTION in my answer post.
Detailed guide how to get OpenCV 2.3.1 up and running under OS X Lion (10.7.2) with Xcode 4.2.1 using MacPorts
EDIT 08/06/2012: This is also working for OpenCV 2.4.1. Just make sure you got the latest version of Xcode and installed the "Command Line Tools" (Xcode -> Preferences -> Downloads -> Command Line Tools).
EDIT 15/08/2012: Tested everything with Mountain Lion ans the current versions of Xcode & OpenCV … it's working :) And you don't have to use the LLVM compiler.
EDIT 16/10/204: Over the last year I abandoned MacPorts and started using brew, which works better for my purposes.
Brew guide
1.) Get the current Version of Brew here.
2.) Make sure brew is ready to us
brew doctor && brew update
3.) Install OpenCV (as of 17/20/2014 v2.4.9)
brew install opencv
4.) Fire up Xcode (as of 17/20/2014 v6.0.1) and open/create your project
5.) Select your target, go to "General" and hit the "+"-Button in the "Linked Frameworks and Libraries"
5.1.) Click "Add Other", hit "/", go to "/usr/local/lib" and add any libopencv_**.dylib you need
6.) Now add "/usr/local/include" to your "Header Search Paths" under "Build Settings" (target still selected)
7.) Finally make sure include OpenCV in your .mm files.
MacPorts guide (maybe outdated)
1.) Get the current Version of MacPorts here. Don't forget to add "/opt/local/(s)bin" to your environment PATH
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
2.) Keep your MacPorts up-2-date:
sudo port -v selfupdate
3.) Install OpenCV 2.3.1 (building with llvm-gcc)
sudo port install opencv configure.compiler=llvm-gcc-4.2
4.) Fire up Xcode and create your project
5.) Select your target, go to "Summary" and hit the "+"-Button in the "Linked Frameworks and Libraries"
5.1.) Click "Add Other", hit "/" and go to "/opt/local/lib"
5.2.) Add any libopencv_**.dylib you need
6.) Now add "/opt/local/include/" to your "Header Search Paths" under "Build Settings" (target still selected)
7.) Finally make sure to have the following lines at the beginning of your .pch file:
#ifdef __cplusplus
#import "opencv2/opencv.hpp"
#endif
Otherwise you'll get some nasty erros like this:
"Non-const static data member must be initialized out of line"
"Statement expression not allowed at file scope"
That's it! Hope it helps :)
Thanks to Vachidrewer, I was able to get OpenCv running on Mavericks.
I did things in a little different order,so here are my notes.
If it isn't installed, install Macports and add it to path.
(I already had it installed)
Use Macports to update itself from the command line
$ sudo port -v selfupdate
Use Macports to install opencv and its dependencies from the command line.
$ sudo port install opencv
If it isn't installed, install xCode. (I already had it installed)
Use xCode to create a C++ Command line project.
Use xCode to verify that the simple hello world C++ program it created works by running it in the xCode IDE.
Modify the main.cpp file created by xCode from the hello world example to the simple opencv example from Vachidrewer.
Notice that xCode editer reports that it can NOT find the header opencv header file.
Add /opt/local/include/ to the project search path and notice that the editer errors go away.
Try to run the program in the xCode IDE and notice that it reports that it can't find the opencv libraries.
Add a group called opencvfrqmework to the project and add /opt/local/lib/libopencv_core.dylib and /opt/local/lib/livopencv_highgui.dylib to the group.
Use the xCode IDE to run the project and notice that a window pops up with half od it darker then the other half.
Have you tried just building it using standard UNIX Makefiles?
Follow this guide, and see if that helps. If you have already downloaded the source code, you probably don't need to do the svn checkout that is suggested. You can probably start with Use CMake to build in section 2.
Hope that helps.
With small changes to #moosgummi answer below steps worked with Xcode 4.6 on Mac OSX 10.7 TEST code is included below.
Installation of OpenCV :
Get the current Version of MacPorts here.
Don't forget to add "/opt/local/(s)bin" to your environment PATH
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Keep your MacPorts up-2-date:
sudo port -v selfupdate
Install OpenCV with mac ports
sudo port install opencv
Configuring Xcode for using OpenCV
Create a new XCode project using the Command Line Utility/Standard Tool template. Name it and select C++
Select Project -> Edit Project Settings. Select the Build tab. Set Configuration to All Configurations
In the Architectures section, double-click Valid Architectures and remove all the PPC architectures if any.
Compiler for C/C++/Objective-C > Apple LLVM compiler 4.2
Language" > "C++ Standard Library", and select "libstdc++ (GNU C++ standard library)"
In the Search Paths section set Header Search Paths to /opt/local/include/
Please choose non-recursive as an option while adding that search path
Close the Project Info window
Select Project -> New Group and create a group called OpenCV Frameworks
With the new group selected, select Project -> Add files to 'Your Project Name'
Press the "/" key to get the Go to the folder prompt. Enter /opt/local/lib
Select libopencv_core.dylib, libopencv_highgui.dylib (you may need to add other library files from this folder to run other code.)
Uncheck Copy Items… and click Add
TEST CODE
Copy this code into your main.cpp file. It should open up a small window that is half shaded.
#include <iostream>
#include <opencv2/opencv.hpp>
int main(int argc, char *argv[])
{
// Open the file.
IplImage *img = cvCreateImage( cvSize(100,200), IPL_DEPTH_8U, 3); //if (!img) {
// printf("Error: Couldn't open the image file.\n");
// return 1;
//}
// Display the image.
cvNamedWindow("Image:", CV_WINDOW_AUTOSIZE);
cvShowImage("Image:", img);
// Wait for the user to press a key in the GUI window.
cvWaitKey(0);
// Free the resources.
cvDestroyWindow("Image:");
cvReleaseImage(&img);
return 0;
}
After get a lot of errors (segmentation fault etc) I finally get it working. Here is the tutorial:
http://www.guidefreitas.com/installing-opencv-2-4-2-on-mac-osx-mountain-lion-with-python-support

Resources