I have google how to install a gnu make file. And I follow the following steps:
$ ./configure
$ sh ./build.sh
$ ./make check
Unfortunately when I run the second command, my cygwin shell complains:
In file included from c:\qt\tools\mingw48_32\i686-w64-mingw32\include\sys\stat.h :14:0,
from ./makeint.h:71,
from ./ar.c:18:
./makeint.h:525:10: error: conflicting types for 'lseek64'
long int lseek ();
I am aware there is another make utility under the qt mingw, but how can i still proceed to install the new make?
The source distribution of GNU make from the FSF download site is not technically supported on Cygwin. Not that there's any known reason why it shouldn't work, but it's not tested and last I heard the Cygwin guys were maintaining some extra patches to GNU make. So it doesn't surprise me that there are issues.
Remember that you should only use the Cygwin version of GNU make if you're invoking make inside of Cygwin to build Cygwin applications. You should not use the Cygwin version of GNU make to build native Windows content outside of Cygwin. Do not mix them together.
You can build a native version of GNU make for Windows (not cygwin) by following the directions in the README.W32 file that comes with the source code. You can get binary versions by looking for MSYS / MinGW.
If you need a Cygwin version of GNU make, you should get ahold of the source code for GNU make from the Cygwin distribution and use that. If it fails to work, you need to communicate with the Cygwin folks about it.
Related
I develop c++ apps on linux and i use neovim with coc.nvim and coc-clangd plugins.
I want to develop an app for windows but i comfort with linux and neovim so i want to use them for it. But i get some include errors with some windows headers (etc. "windows.h").
I use linux only for writing the code and i'll compile the program on windows. How can i prevent this errors and use windows headers with coc.nvim?
i'll compile the program on windows
You can cross-compile it from Linux. It's only marginally more difficult than getting the code completion to work.
Get the standard library headers (and libraries, if you want to cross-compile) from MinGW.
Your package manager might have those, or you can get them from https://winlibs.com/.
I prefer getting those from MSYS2, and made scripts to automate this (since MSYS2 is otherwise Windows-only):
git clone https://github.com/holyblackcat/quasi-msys2
cd quasi-msys2/
make install _gcc
Figure out the Clang flags needed to cross-compile.
Unlike GCC, which for every target platform requires a separate compiler distribution, Clang is inherently a cross-compiler. You only need a single Clang distribution to compile for any supported platform.
Download Clang from your package manager, and point it to the freshly downloaded headers and libraries.
Following flags work for me: clang++-14 1.cpp --target=x86_64-w64-mingw32 --sysroot=/path/to/quasi-msys2/root/mingw64 -fuse-ld=lld-14 -pthread -stdlib=libstdc++ -femulated-tls -rtlib=libgcc.
--target and --sysroot are crucial. The latter needs to point to the files you've downloaded. The remaining flags are less important.
Running this should produce a.exe, runnable with wine a.exe.
Feed the same flags to Clangd.
There are several ways to set compiler flags for Clangd.
The easiest one is to create a file named compile_flags.txt in your project directory, and put the flags into it, one per line:
--target=x86_64-w64-mingw32
--sysroot=/path/to/quasi-msys2/root/mingw64
-fuse-ld=lld-14
-pthread
-stdlib=libstdc++
-femulated-tls
-rtlib=libgcc
Then Clangd should do the right thing for any source files in this directory.
Apparently, my Quasi-MSYS2 can somewhat automate this.
After running the commands above (make install _gcc and others), run make env/shell.sh, and run your editor from this shell.
Replace compiler_flags.txt with compiler_commands.json with following contents:
[
{
"directory": "/your/sources",
"file": "/your/sources/1.cpp",
"command": "win-clang++ 1.cpp"
}
]
Where win-clang++ is a Clang wrapper I ship, which automatically adds the flags I listed above.
Configure your editor to add following flag to Clangd: --query-driver=/path/to/win-clang++ (use which win-clang++ from quasi-msys2 shell to get the full path).
This makes Clangd obtain the right flags automatically from this wrapper.
You can't use windows.h while you're compiling a Linux native application. If want to make your application platform ready and you're using some kind of OS native cals, then you have to probably use defines like #if _WIN32/__linux__ and so on. At the end, you can cross-compile your application to Windows while you're running on Linux as well.
How do I install the latest version of GCC on my macOS Big Sur. I am using Visual Studio Code, version 1.60 and I want to run C++ programs using it. I tried using homebrew to install GCC but it kept on giving me errors.
E.g.: When I typed in the path as /opt/homebrew/Cellar/gcc/11.2.0/bin
Result: zsh: permission denied: /opt/homebrew/Cellar/gcc/11.2.0/bin
What is wrong with the permission? How will I make it allow.
Firstly, /opt/homebrew/Cellar/gcc/11.2.0/bin is a directory, so you can't run that.
Secondly, homebrew generally makes symbolic links in /usr/local/bin for everything it installs, so you should add that to your PATH, e.g.
export PATH=/usr/local/bin:$PATH
Then you need to look in /usr/local/bin to see what program name you need, e.g.
ls /usr/local/bin/gcc*
and if you see gcc-11 in there, you then need to compile with:
gcc-11 program.c
Note you will need to look for g++* if you actually mean C++ rather than C.
I would like to upgrade my old GCC compiler to v. 4.8.1.
Currently I'm using Code::Blocks IDE (nightly build, svn 8982), and my compiler is GCC 4.4.1.
I downloaded fresh GCC from their site - gcc.gnu.org
From what I've read in documentation, they say that I should first build compiler by myself. Afterwards, they throw something like this:
% mkdir objdir
% cd objdir
% srcdir/configure [options] [target]
However, I completly have no idea what to do with these lines.
And even if I did, afterwards come maaany lines with some additional options, where I am even more lost then before.
I don't know if there is any easy way of installing it, but from what I've read here, I can download MSYS from MinGW and it will do everything(I hope?) for me. However, from what I see there, it says that MinGW comes with already built version of GCC, meaning I won't be able to use mine anyway. Am I right? If yes, what should I do to build and use GCC? If not, then will I be able to easily install GCC after downloading MSYS?
Thanks in advance.
I can download MSYS from MinGW
YOu can.
and it will do everything(I hope?) for me.
It won't. MSys provides environment for building software that requires unix-like environment. To be more precise - autotools. If you aren't familiar with *nix build process (configure script), Mingw won't really help you.
However, from what I see there, it says that MinGW comes with already built version of GCC,
Yes, version 4.7.2 at the moment.
meaning I won't be able to use mine anyway. Am I right?
No. If you don't add Mingw/MSys to your PATH, you can keep multiple different installations on the same machine. It also SHOULD be possible to use multiple different versions of gcc within the same installation of mingw, but things can get messy here. (gcc3 and gcc4 should be able to exist, not sure about 4.7.2 and 4.8.1)
If yes, what should I do to build and use GCC?
You should search for precompiled binaries provided by somebody else. Compiling gcc yourself is possible, but for you (i.e. if you aren't arleady familiar with msys) it might not be worth the effort.
Either you could try http://mingw-w64.sourceforge.net/ or mingw-nuwen. Mingw provided by nuwen is 32bit only, but is very easy to install. The problem is that standard mingw distribution includes update tool (with "mingw uppdate" and "mingw upgrade" you can upgrade installed packages to their latest version), bug "mingw-nuwen" doesn't have such tool.
Because you say
However, I completly have no idea what to do with these lines.
You should either use precompiled mingw provded by somebody else, or use another compiler. If you don't really need bleeding-edge C++11 support ON WINDOWS, use visual studio express.
I am trying to compile a 32-bit version (MinGW) of a program I wrote using zlib. Until now, I've never has to compile for 32-bit so the version of zlib I compiled from source (libz.a) is 64-bit. I tried to rerun the makefile in the zlib-1.2.5 directory but it only compiles a 64bit version of libz.a.
I can't seem to find an option to build 32-bit.
Does anyone know how to do this?
Thanks!
Jeffrey Kevin Pry
Checking the configure file, you can see some env.
On 64bit debian, following command line will build the 32bit version of libz
CFLAGS=-m32 ./configure
It turns out I had to get the 32bit version of MinGW and compile it with that. I was using MinGW64.
Using CFLAGS=-32 won't do it for me, configure script still shouts out telling me to use win32/Makefile.gcc instead all the time.
The recent version of zlib is 1.2.11, so it should be minimal gap of difference up until today. Without any context on system, the following might be useful for other users facing this similar problem these days.
I cross compile on Linux (Ubuntu 18.04), and target 32-bit version of zlib to be produced. What I did is as follows.
./configure (this is just to let us have required file to building process, we will be using different Makefile though)
Modify win32/Makefile.gcc for its PREFIX=i686-w64-mingw32- (for 64-bit you change it to PREFIX=x86_64-w64-mingw32-.
make -fwin32/Makefile.gcc
Install to your desire location via make install -fwin32/Makefile.gcc SHARED_MODE=1 INCLUDE_PATH=/tmp/zlib-win32/include LIBRARY_PATH=/tmp/zlib-win32/lib BINARY_PATH=/tmp/zlib-win32/bin. Notice that you need to specify INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH. BINARY_PATH will contains result .dll file.
I've gone to http://sourceforge.net/project/showfiles.php?group_id=2435, downloaded the Automated MinGW Installer for MinGW 5.1.4 and at the same time the GNU Source-Level Debugger Release Candidate: GDB 6.8-3. I've then installed MinGW base tools into C:\MinGW. No problem so far.
However when I come to install the gdb debugger it has a lot of files and folders with the same names as some already installed but the files are different to those already installed. e.g C:\MinGW\include\bfd.h is 171 KB but gdb-6.8-mingw-3\include\bfd.h is 184 KB.
How do I add gdb to MinGW without breaking what's already installed?
In a command prompt I browsed to C:\MinGW\bin and ran:
mingw-get.exe install gdb
That fixed it for me. Not sure if it matters but I have C:\MinGW\bin in my path (guess I probably didn't need to browse to C:\MinGW\bin).
The Current Release (5.2.1) version of gdb at the project files page has always worked for me. The download is a stand-alone .exe, you don't need anything else.
But I'll bet the .exe in the 6.8 package will work, too. I'd try using just the .exe, and then if there are problems, try extracting the other files from the 6.8 package. (Though that may cause problems with the rest of the MinGW installation.)
Update: There seems to be a 7.something version. I haven't tested it thoroughly, but it seems to work, even with gcc 3.
Get Wascana Desktop Developer. It combines MinGW, gcc, Eclipse and gdb in one package.
You can safely overwrite the files prepackaged with MinGW with the (newer) ones from the gdb tarball. You can also choose not to overwrite them - just make sure to pick either one set, i.e. avoid mixing files from the older and the newer package.
Most of the offending files are probably not really relevant to you anyway. For example, the files belonging to the libbfd library aren't required for gdb's day to day operation, they're used if you want to extend the debugger or write debugging tools yourself.
At any rate, make a backup of the mingw directory before untarring the new release. It's very easy since MinGW is self-contained in that directory. That way, if anything should malfunction, you can just delete the directory and restore from the backup.
Usually for installing gdb in windows, You have to 2 ways to install:
1) use ready-made binaries that were build and compiled from GNU gdb by some provider (easy to install)
use TDM-GCC binaries provided from the following URL and that is including inturn the gcc complier and also gdb debugger.
http://tdm-gcc.tdragon.net/
use Equation package inside which GNU GDB was already compiled and built.
http://www.equation.com/servlet/equation.cmd?fa=gdb
2) use minimal mingw or cygwin package then after install gdb inside it.
Install either mingw or cygwin inside which GDB is already shipped
Open cygwin or mingw terminal and just type the following to make sure it is already installed
$ gdb --version
Hint: if you did not find gdb installed, simply open the cygwin or mingw package installer and make sure you already check gdb
Hint: getting and installing a debug build of the OHRRPGCE is providing useful information about crashes.
From cygwin or mingw terminal, Start gdb using the following
c:\mingw\bin\gdb.exe program_to_debug.exe
REF: http://rpg.hamsterrepublic.com/ohrrpgce/GDB_on_Windows
The TDM GCC/MinGW32 builds installer includes gdb. It's gcc 4.4.x with all the core binary packages required for basic Windows development, and is widely used without any unusual problems.