Configuring protocol buffer in windows - protocol-buffers

I am trying to install the google protocol buffer in windows, the instructions first as me this:
cd' to the directory containing the package's source code and type
'./configure' to configure the package for your system. If you're
using 'csh' on an old version of System V, you might need to type
'sh ./configure' instead to prevent 'csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
When I do the './configure' command it tries to open the file label configure in the directory and if I use 'sh ./configure' it doesn't recognise sh as a term. Any ideas?

The instructions you're looking at are for Unix. On Windows, usually you'll want to follow the Windows installation instructions:
https://github.com/google/protobuf#c-installation---windows
As an exception, you'll want to follow the Unix instructions if you plan to use MinGW or Cygwin as your compiler (rather than Visual Studio). In these cases, you'll want to use the MSYS shell (for MinGW) or the Cygwin shell to run the commands in the instructions, not the regular Windows command prompt.

Related

How to enable bash commands in Windows CMD?

I've two Windows machines and both have bash installed. However, they differ in the way bash starts up:
Machine 1:
Typing "bash" starts the bash. Then I can type commands like ls.
Machine 2:
It seems like it starts bash and directly runs ls in it, by only typing "ls". After that it switches back to CMD automatically, like this:
Does anyone know which setting enables the behavior of machine 2? Everything looks the same for me. It's a nice feature and I want to enable it on machine 1 as well.
Bash on Ubuntu on Windows executables (binaries) cannot run from Windows applications such as cmd.exe or PowerShell.exe - Windows doesn't even see them as executable.
The likeliest explanation is that you've installed a separate Unix emulation environment such as GnuWin, which comes with native Windows binaries.
To see the location of your - by definition Windows-native - ls executable, run where ls, which will probably tell you what product it came with, such as
C:\Program Files (x86)\GnuWin32\bin\ls.EXE.
Note that the Ubuntu on Windows binaries are stored in a user-specific manner in
%LOCALAPPDATA%\lxss\rootfs\bin, but that is a moot point, given that you cannot invoke them from Windows.
In Windows 10, there is a built-in Linux subsystem (one of the greatest features of Windows 10). It gives you almost a complete Linux shell for various distributions, and you can almost do anything with it (user mode).
I bet it is installed on your first computer, and you are using that subsystem. In the latest version of this subsystem, you can run both Linux executables and Windows exe files.

How to install and use "make" in Windows?

I'm following the instructions of someone whose repository I cloned to my machine. I want to use the make command as part of setting up the code environment, but I'm using Windows. I searched online, but I could only find a make.exe file, a make-4.1.tar.gz file (I don't know what to do with it next) and instructions for how to download MinGW (for GNU; but after installing it I didn't find any mention of "make").
How do I use make in Windows without a GNU compiler or related packages?
make is a GNU command so the only way you can get it on Windows is installing a Windows version like the one provided by GNUWin32. Anyway, there are several options for getting that:
The most simple choice is using Chocolatey. First you need to install this package manager. Once installed you simlpy need to install make (you may need to run it in an elevated/admin command prompt) :
choco install make
Other recommended option is installing a Windows Subsystem for Linux (WSL/WSL2), so you'll have a Linux distribution of your choice embedded in Windows 10 where you'll be able to install make, gccand all the tools you need to build C programs.
For older Windows versions (MS Windows 2000 / XP / 2003 / Vista / 2008 / 7 with msvcrt.dll) you can use GnuWin32.
An outdated alternative was MinGw, but the project seems to be abandoned so it's better to go for one of the previous choices.
GNU make is available on chocolatey.
Install chocolatey from here.
Then, choco install make.
Now you will be able to use Make on windows.
I've tried using it on MinGW, but it should work on CMD as well.
The accepted answer is a bad idea in general because the manually created make.exe will stick around and can potentially cause unexpected problems. It actually breaks RubyInstaller: https://github.com/oneclick/rubyinstaller2/issues/105
An alternative is installing make via Chocolatey (as pointed out by #Vasantha Ganesh K)
Another alternative is installing MSYS2 from Chocolatey and using make from C:\tools\msys64\usr\bin. If make isn't installed automatically with MSYS2 you need to install it manually via pacman -S make (as pointed out by #Thad Guidry and #Luke).
If you're using Windows 10, it is built into the Linux subsystem feature. Just launch a Bash prompt (press the Windows key, then type bash and choose "Bash on Ubuntu on Windows"), cd to the directory you want to make and type make.
FWIW, the Windows drives are found in /mnt, e.g. C:\ drive is /mnt/c in Bash.
If Bash isn't available from your start menu, here are instructions for turning on that Windows feature (64-bit Windows only):
https://learn.microsoft.com/en-us/windows/wsl/install-win10
Download make.exe from their official site GnuWin32
In the Download session, click
Complete package, except sources.
Follow the installation instructions.
Once finished, add the <installation directory>/bin/ to the PATH variable.
Now you will be able to use make in cmd.
Install Msys2 http://www.msys2.org
Follow installation instructions
Install make with $ pacman -S make gettext base-devel
Add C:\msys64\usr\bin\ to your path
On windows 10 or 11, you can run the command winget install GnuWin32.Make in the command line or powershell to quickly install it. Than you can use the command cmake.
There is no need to install choco anymore.
The chances are that besides GNU make, you'll also need many of the coreutils. Touch, rm, cp, sed, test, tee, echo and the like. The build system might require bash features, if for nothing else, it's popular to create temp file names from the process ID ($$$$). That won't work without bash. You can get everything with the popular POSIX emulators for Windows:
Cygwin (http://www.cygwin.org/) Probably the most popular one and the most compatible with POSIX. Has some difficulties with Windows paths and it's slow.
GNUWin (http://gnuwin32.sourceforge.net/) It was good and fast but now abandoned. No bash provided, but it's possible to use it from other packages.
ezwinports (https://sourceforge.net/projects/ezwinports) My current favorite. Fast and works well. There is no bash provided with it, that can be a problem for some build systems. It's possible to use make from ezwinports and bash from Cygwin or MSYS2 as a workaround.
MSYS 1.19 abandoned. Worked well but featured very old make (3.86 or so)
MSYS2 (https://www.msys2.org/) Works well, second fastest solution after ezwinports. Good quality, package manager (pacman), all tooling available. I'd recommend this one.
MinGW abandoned? There was usually MSYS 1.19 bundled with MinGW packages, that contained an old make.exe. Use mingw32-make.exe from the package, that's more up to date.
Note that you might not be able to select your environment. If the build system was created for Cygwin, it might not work in other environments without modifications (The make language is the same, but escaping, path conversion are working differently, $(realpath) fails on Windows paths, DOS bat files are started as shell scripts and many similar issues). If it's from Linux, you might need to use a real Linux or WSL.
If the compiler is running on Linux, there is no point in installing make for Windows, because you'll have to run both make and the compiler on Linux. In the same way, if the compiler is running on Windows, WSL won't help, because in that environment you can only execute Linux tools, not Windows executables. It's a bit tricky!
I could suggest a step by step approach.
Visit GNUwin
Download the Setup Program
Follow the instructions and install GNUWin. You should pay attention to the directory where your application is being installed. (You will need it later1)
Follow these instructions and add make to your environment variables. As I told you before, now it is time to know where your application was installed.
FYI: The default directory is C:\Program Files (x86)\GnuWin32\.
Now, update the PATH to include the bin directory of the newly installed program.
A typical example of what one might add to the path is: ...;C:\Program Files (x86)\GnuWin32\bin
Another alternative is if you already installed minGW and added the bin folder the to Path environment variable, you can use "mingw32-make" instead of "make".
You can also create a symlink from "make" to "mingw32-make", or copying and changing the name of the file. I would not recommend the options before, they will work until you do changes on the minGW.
I once had the same problem. But I am surprised not to find one particular solution here.
Installation from GnuWin32 or via winget are good and easy options. But I only found make 3.8.1 there. This version lacks the very important option -O, which handles the output correctly when compiling multithreaded.
choco appears to offer make 4.3, currently. So one could expect recent versions there.
But there is also the option of self compiling. And if you have to install make, which is used for compiling, this should be a valid option.
head to https://www.gnu.org/software/make/ and download a version of your liking
unpack the tar.gz files (use 7zip and unpack the file twice to retrieve the actual content)
navigate to the created directory
open command prompt in that directory
run build_w32.bat gcc This will start the compilation with the gcc compiler, which you would need to install in advance. When running build_w32.bat without any option they try to use the MSVC compiler. Sidenote: I found it surprising that gnu does not use gcc as default but MSVC :-)
ignore the warnings created during compilation. The result should still be fine
retrieve your fresh gnumake.exe from the directoy GccRel (when compiled with gcc)
put this file somewhere where you like and rename to make.exe
add the location to the system variable %PATH%
As others have noted: This manual installation might cause conflicts if you have various make versions installed by other programs as well.
You can also install scoop, then run:
scoop install make
One solution that may helpful if you want to use the command line emulator cmder. You can install the package installer chocately. First we install chocately in windows command prompt using the following line:
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
refreshenv
After chocolatey is installed the choco command can be used to install make. Once installed, you will need add an alias to /cmder/config/user_aliases.cmd. The following line should be added:
make="path_to_chocolatey\chocolatey\bin\make.exe" $*
Make will then operate in the cmder environment.
Install npm
install Node
Install Make
node install make up
node install make
If above commands displays any error then install Chocolatey(choco)
Open cmd and copy and paste the below command (command copied from chocolatey URL)
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command " [System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

UNIX script to run on WINDOWS

I got a couple of questions,
Is there any way to make a UNIX script run under a windows OS without any add-on like CYGWIN?
Is there any way to transform a UNIX script to a windows batch script, so that i can run it in windows cmd ?
I searched for that but i get referred to the UNIX command win2unix or unix2win , the ones that transform a file from/to windows/UNIX format.
Thanks for the help.
I know you don't want an "add on", but if this may help : you can download MobaXterm (or a portable version of it), which will come with many things, including many unix utilities (shell, etc) and lots you can download from their website.
The portable version is the most convenient (and you can carry it on your usb key, for example)
It's quite slower than cygwin/etc (most commands are emulated via some master binary, and many shell "builtins" becomes instead invocations of that binary, for example), but very portable and neat.
Other solutions (converting, etc) probably will also entail a binary of some sort, so I recommand the above, as it's very portable and gives you a kind of "mini unix inside windows"
Another answer for this old question is to install and run light Unix-like emulators. Here are some options:
MinGW -- native Windows port of the GNU Compiler Collection (GCC)
MSYS -- command line terminal called mintty, bash, version control systems like git and subversion, tools like tar and awk and even build systems like autotools
GitBash -- BASH emulation used to run Git from the command line. *NIX users should feel right at home
The above list installs micro environments much lighter than a typical Cygwin install. Also, in my experience most Bash scripts run on par with native Linux environments in these environments.
Yet another option is installing a Linux Subsytem like WSL2.
Yet another option is converting Bash to DOS by hand or with partial assistance of something like Bash-to-BAT converter, which isn't very full featured, and the Advanced Bash-Scripting Guide.

How do we configure SSH using Perl in Windows?

Can anyone suggest a a very simple way to use Net::SSH::Perl in Windows without all those cygwin hacks and all.
Whenever I am trying to install the modules it's taking me to some other dependent modules and the process seemed never ending..
Thanks beforehand
Here is a post on how to do it I found.
I recently had a project that required a script to perform an SSH session to a Cisco device and make some configuration changes. My favourite scripting language is, of course, perl.
I had previously written scripts using the Net::Telnet module that would Telnet to a device, detect various device prompts and send commands to the device to change its configuration. So, I thought that this was going to be a fairly straightforward case of just finding a suitable, similar module that uses SSH instead of Telnet.
The other thing that I need to mention is that I am generally constrained to using Win32 platforms (i.e. Windows 200, 2003, XP) due to the fact that most client sites that I work on these days do not use Unix(or Linux) ..which is a real pity in my opinion, but I don't set the corporate policies of my clients.
An initial glance of the available perl modules revealed a number of modules which seemed to be just what I needed :
Net::Appliance::Session
Net::SSH::W32Perl
Net::SSH
So, I told my boss, 'Yep, no problem' and set about pulling together a script to SSH in to a remote device and send it some commands to change its configuration.
After a day or so of trying various modules, I thought : 'Hmmm, maybe this isn't going to be as easy as I'd thought!'
Each of the modules I'd looked at seemed to have an issue when it came to using it in a Windows environment. To summarise, here are the issues I found with each module :
* Net::Appliance::Session : has a dependency on IO::Pty, which won't ever run on Windows
* Net::SSH::W32Perl : ``getpwuid function is unimplemented'' message`` when building from scratch. Older ppd's found at http://www.soulcage.net/ppds.58 just don't seem to work....even when installed in to the Activestate perl distribution
* Net::SSH : Unix only
So, at this point, I was beginning to think that maybe this just wasn't going to work at all on Windows....
Then, I remembered seeing a posting on perl mongers where someone has mentioned that they had used perl in cygwin to run one of the Net::* modules.
So, although the thought of having to download and install cygwin didn't initially seem too appealing, I thought I'd give it a go as I had no where else to go.
Cygwin
Cygwin is...well, let me quote directly from the cygwin web site :
``Cygwin is a Linux-like environment for Windows. It consists of two parts:
A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality. A collection of tools which provide Linux look and feel.
The Cygwin DLL currently works with all recent, commercially released x86 32 bit and 64 bit versions of Windows, with the exception of Windows CE.``
So, it allows you to run in a Linux-type environment...sounds far more promising for the various Net::* modules that I had been looking at.
Also, once the basic cygwin core is installed, it allows you to download and install a whole host of other goodies, including perl !
So, I set about installing cygwin by downloading the 'setup.exe' file from the cygwin home page and running it on my PC.
Cygwin provides a failrly intuitive GUI to let you select a mirror to download files from, and which packages you would like to download.
Here are the packages that I installed beyond just the basic core cygwin packages that are installed for you :
gcc-core
gnupg
make
ncftpget
openSSH
perl
perl-ExtUtils
wget
zip
You can install others (in addition) if you like, but these did the job for me.
Perl
Once I had cygwin installed (including the perl distribution that I included), I was all set to add in the modules that I wanted to try to use (e.g. Net::SSH::Appliance).
If you are familiar with perl on Unix systems, then you will probably be very familiar with the CPAN shell to add modules into your perl distribution. Under cygwin, the process is exactly the same.
If you are used to using the Activestate version of perl, you are probably used to using the Activestate PPM manager to add new modules to perl. Well, the bad news is that under cygwin, you don't have a PPM manager, and you have to use the CPAN shell, which is a little bit trickier to use if you aren't used to it. The good news however, is that you will have access to far more perl modules !
When you installed cygwin, it will have put an icon somewhere (either on your desktop, quicklauch bar or start menu) so that you can launch the cygwin shell (it looks something like this :
If you click the shell icon, you will get a nice cygwin shell open up where you can type in various commands. You can think of it as a Unix shell to all intents and purposes.
To load in the perl modules you'll need, you need to enter 'cpan' at the command prompt. This will allow you to load new modules in to your perl distribution.
Now, the first time you go in to the CPAN shell, it will aks you lots of rather awkward questions about where various utilities are and which mirror you would like to use. In the main, if you have installed the modules that I recommended for cygwin, you can accept the defaults. (The mirror you will have to figure out for yourself - it depends where in the world you are).
The only setting I would recommend you change from the default is the question about whether you should be 'asked or follow' for pre-requisite modules - I would go for 'follow' to save a lot of hassle.
Once you have your cpan shell open (you can tell, because you now have a 'cpan>' prompt), you need to enter the following commands to load in some perl modules that you will need :
install LWP (accept all defaults to any questions asked)
install Net::Appliance::Session
When you enter these commands, you will see lots of things flying up the screen as the modules are installed for you.
Running Scripts
Well, at this point, we have taken a rather whirlwind tour through getting cygwin and perl instaled on your platform, but you should now be in a position to run some perl scripts.
We installed the Net::Appliance::Session module in to your perl distribution, so that we can run perl scripts that will use it to give us either Telnet or SSH sessions to a target device.
As we are running under the cygwin environment, we can now use this module on a Windows platform - something we couldn't do by just installing Activestate perl, or even by compiling our own version of perl under Windows. So, now, we CAN run perl scripts that will allow us to perform SSH sessions to network devices that only support SSH.
You may be wondering : ``does that mean that I have to run my perl scripts from the cygwin shell every time I need to run them ?''. Well, the good news is that no, you don't..! As long as you call the cygwin perl executable to run your script, it will run fine from a DOS prompt (or system scheduler !). So, this would work fine :
c:\ c:\cygwin\bin\perl.exe myscript.pl
Anyhow, I guess that's enough to let you know how I cracked my particular issue. I hope to cover all of this in a little more detail in future aritcles, as well as providing more informatipon about how to use the incredibly useful Net::Appliance::Session module to create some useful scripts to control and configure your network devices.
http://perlwin32ssh.blogspot.com/2007/07/test_4418.html
For ActiveState Perl, probably you can try for Net::SSH2 module. I tried with couple of online examples and it worked for me.
You can go through following resources to install and run a sample example using Net::SSH2.
Use this repository to install Net::SSH2
http://theoryx5.uwinnipeg.ca/ppms/
couple of examples:
http://www.perlmonks.org/?node_id=569657
Hope this will work for you. I tried it and it worked for me.
The answer about using Perl from within Cygwin then calling it from the Windows command line is the correct answer. THANKS VERY MUCH FOR YOUR EFFORT!
However, this method to call a PERL instance running in Cygwin from the Windows Command Line is not always optimum:
c:\cygwin\bin\perl.exe myscript.pl
That technique will work with some Perl scripts but not all. It was giving me heck trying to use NET:SSH:EXPECT and the login() method. It would abort with strange errors.
A better way to call your Perl instance running in Cygwin from the Windows command prompt is this:
c:\cygwin\bin\bash --login -c 'perl myscript.pl'
This seems to execute the Perl script fully within the Cygwin environment and even complicated Perl scripts or those with many dependencies or not capable of dealing with MSDOS style path names, will still run. You can still return the output of the Perl script back to the Windows command window, for instance using print() from within your Perl script.

Portable unix-like environment for Windows

I am trying to put together a portable set of files/scripts that will enable me to mimic a unix like environment on Windows.
I do not want to install anything. The setup needs to be able to live on a thumbdrive for example. Currently I am using UnxUtils to provide grep, and more. Im adding these to the Windows PATH environment variable in the current console session by
cd <pathToUnxUtils>
path = %PATH%;%CD%
For Vim (my preferred editor) I am using the "Win32 console executable" (http://www.vim.org/download.php#pc) vim.exe. If I have that in a drive such as \vim\vim73\vim.exe then $VIMRUNTIME is \vim\vim73, which is where my vimrc lives.
I am trying to get some syntax highlighting and indenting going next, which I believe I need to add the appropriate .vim scripts to $VIMRUNTIME\syntax and $VIMRUNTIME\indent
but it does not seem to work.
I am using the console executible instead of something like gVim (which probably does more of what I want "out-of-the-box") because I want to be able to send commands to the same shell using the ! command. gVim does not allow that (correct me if I am wrong)
Lastly, has anyone experienced trouble with "tail" from UnxUtils working on Vista?
I know this probably seems like a stupid way to go about things, but I am really trying to make this work. Id be happy with getting these bits of Unix goodness going on Windows.
Thanks for any help
Check out cygwin portable: http://symbiosoft.net/cygwinportable
Or this guide on how to make regular cygwin run on portable devices: http://sites.google.com/site/devinsezer/Home/software/portable-cygwin
The advantage of cygwin over a thin emulation layer like UnxUtils is that it includes a fully working X11 server so you can even run GUI unix apps if you need to (gitk for example, if you're using git)
I've had some troubles with UnxUtils before re currency - they don't seem to be as up to date as the GnuWin32 stuff (for example, TextUtils at 2.1 instead of 5.3).
I've simply downloaded the executables and required libraries for what I've needed (no install needed if you avoid the setup packages, just copy and go).
If you click on the package names on the left of that second link above (not the "Setup" on the right), it allows you to download both the executable plus all dependencies on a single page.
My particular needs for a recent project were met with sed and about four DLL files, no installation, no impinging on the environment or registry. In short, ideal for running from a memory stick or standalone CD.
I must, at some point, put together a CD with the entire suite on it. I used to carry around CygWin but the necessity to install was a pain.
I'm using MobaXterm from Mobatek.
http://mobaxterm.mobatek.net/
It's not a complete envoirement, but is quite suficcient.
Just download and run!
It have an (ba)sh, with X, sed, grep, awk, rsync, wget, sftp, scp; and some extra plugins (standalone files to put in the same dir) to VIM, EMACS, perl python, Gcc, gdb, mplayer, svn, git, lua graphviz...
It still provides many protocols (RDP, VNC, SSH, telnet, rsh, FTP, SFTP and XDMCP).
Either MSYS or CH will do that, there is a specifically portable VIM at portable apps
Cygwin and MSYS provides all you need. I have used both and I think MSYS runs faster than Cygwin on a Windows machine. Cygwin emulates the UNIX environment whereas MSYS is port of the GNU utils to Windows.
Another option to get portable GNU utils is to install Portable MsysGit.
http://www.cygwin.com/ is very popular.
update: oh, never mind - I don't think it can be xcopy deployed.
-Oisin
I've had good luck with running Cygwin on a thumbdrive. I haven't run it on machines where older versions are installed. But I don't expect to have that problem often.
Here is what I did: http://fadedbluesky.com/2011/portable-cygwin/

Resources