Building zlib libz.a for 32 bit - c++

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.

Related

Build 64bit GNU GMP for GCC

Many of links I have tried have said to follow the same steps,
install MSYS2
install GCC
run ./configure
run make
run make install
run make check
in the directory of the GMP files. I have tried this and it has never worked.
The only thing that has worked for me was installing MSYS (not MSYS2) and selecting a MinGW compiler from CodeBlocks to then run the above instructions. It has worked then for 32bit programs, however I don't know how to get it working for 64bit programs.
On my latest attempt, I tried running ./configure "CFLAGS=-m64" "CXXFLAGS=-m64" "LDFLAGS=-m64" && make and then the remaining steps. This still ended me up in the same place as running just ./configure.
I thought if the above didn't work for 64bit, then surely it would work for 64bit (the ./configure solution), however it doesn't.
On 32bit, I get these errors:
undefined reference to __gmpz_init
... more of the above but for different gmp functions
and on 64bit I get these errors (this is what I am trying to compile for):
undefined reference to `__getreent`
and this ^ repeats a lot of times.
I can't find any guides online about installing GMP-64bit, rather 32bit and that uses MSYS, which is what I had working initially, however that is only for 32bit and an outdated compiler.
How can I install 64bit GMP to use in a CodeBlocks Project using a MinGW 64bit compiler?

Error relating another make utility in one system

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.

Install libcurl for C++ in Windows

this is my first time trying to install a library, and I have next-to-no idea as to how I'd do that. I'm using GCC in codeblocks. Do I download the MinGW64 binary or development build? From there where do/should I extract it to. After that, I believe I have to link it to GCC, how do I accomplish that? Is there anything else after that? I found results on Google, but all they did for me was confuse me.
Downloading MinGW binaries for windows should be sufficient. Dev build from source is only necessary if you want to contribute to the GCC toolchain itself, or change build parameters for it (which is unlikely for the context you're asking for).
When you have installed your MinGW GCC toolchain properly, you should be able to download libcurl as source distribution and compile it with this toolchain.

How to build and install GCC on Windows 7, ver. 4.8.1

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.

How to compile C++ programs in codeblocks for 32bit computers with the dual targets MinGw compiler [duplicate]

I've downloaded MinGW with mingw-get-inst, and now I've noticed that it cannot compile for x64.
So is there any 32-bit binary version of the MinGW compiler that can both compile for 32-bit Windows and also for 64-bit Windows?
I don't want a 64-bit version that can generate 32-bit code, since I want the compiler to also run on 32-bit Windows, and I'm only looking for precompiled binaries here, not source files, since I've spent countless hours compiling GCC and failing, and I've given up for a while. :(
AFAIK mingw targets either 32 bit windows or 64 bit windows, but not both, so you would need two installs. And the latter is still considered beta.
For you what you want is either mingw-w64-bin_i686-mingw or mingw-w64-bin_i686-cygwin if you want to compile for windows 64. For win32, just use what you get with mingw-get-inst.
See http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure for an explanation of file names.
I realize this is an old question. However it's linked to the many times the question has been repeated.
I have found, after lots of research that, by now, years later, both compilers are commonly installed by default when installing mingw from your repository (i.e. synaptic).
You can check and verify by running Linux's locate command:
$ locate -r "mingw32.*[cg]++$"
On my Ubuntu (13.10) install I have by default the following compilers to choose from... found by issuing the locate command.
/usr/bin/amd64-mingw32msvc-c++
/usr/bin/amd64-mingw32msvc-g++
/usr/bin/i586-mingw32msvc-c++
/usr/bin/i586-mingw32msvc-g++
/usr/bin/i686-w64-mingw32-c++
/usr/bin/i686-w64-mingw32-g++
/usr/bin/x86_64-w64-mingw32-c++
/usr/bin/x86_64-w64-mingw32-g++
Finally, the least you'd have to do on many systems is run:
$ sudo apt-get install gcc-mingw32
I hope the many links to this page can spare a lot of programmers some search time.
for you situation, you can download multilib (include lib32 and lib64) version for Mingw64:
Multilib Toolchains(Targetting Win32 and Win64)
By default it is compiled for 64bit.You can add -m32 flag to compile for 32bit program.
But sadly,no gdb provided,you ought to add it manually.
Because according to mingw-64's todo list, gcc multilib version is done,but gdb
multilib version is still in progress,you could use it maybe in the future.
Support of multilib build in configure and in gcc. Parts are already present in gcc's 4.5 version by using target triplet -w64-mingw32.
gdb -- Native support is present, but some features like multi-arch support (debugging 32-bit and 64-bit by one gdb) are still missing features.
mingw-64-todo-list