How to compile wine 32 bit on mac using gcc - c++

I am trying to compile the 32 bit version of wine on mac. When I do
./configure --with-wine64=../wine64
I get the error "Cannot build a 32-bit program, you need to install 32-bit development libraries.".
I think this is because xcode stopped supporting 32 bit libraries (I have version 10). When I do which gcc I get /usr/bin/gcc, therefore I think my gcc is came with xcode.
I also installed gcc using brew install gcc, but when I do ls /usr/local/bin/ | grep gcc I get
gcc-8
gcc-ar-8
gcc-nm-8
gcc-ranlib-8
x86_64-apple-darwin17.7.0-gcc-8
x86_64-apple-darwin17.7.0-gcc-8.2.0
x86_64-apple-darwin17.7.0-gcc-ar-8
x86_64-apple-darwin17.7.0-gcc-nm-8
x86_64-apple-darwin17.7.0-gcc-ranlib-8
so I thought I could install a gcc with libraries related with 32 bit support and compile wine like that. But now when I do ./configure CC="gcc-8" --with-wine64=../wine64, I get
checking whether we are cross compiling... configure: error:
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
How can I find a workaround to compile 32 bit wine (version 3.21)

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?

How to get "g++ -mx32" to work on RHEL 7.2

I am new to x64_86, but forced to use it because RedHat dropped its 32-bit OS support in RHEL 7.x. I have to complile a lot of code, and am not ready to jump to x64 yet (because I do not need 64-bit addresses and do not want to face all related porting issues). So I have considered using -m32 and -mx32, and decided that -mx32 is the best route for me. However, while -m32 works fine on my build machine, when I use -mx32, I get this error:
In file included from /usr/include/features.h:399:0,
from /usr/include/string.h:25,
from zz.cpp:1:
/usr/include/gnu/stubs.h:13:28: fatal error: gnu/stubs-x32.h: No such file or directory
# include <gnu/stubs-x32.h>
^
compilation terminated.
I searched the web for solutions and some links indicate that I have to install some mysterious "multilib" rpms for g++ and gcc, however, I cannot find these anywhere. Others suggest that I have to install Linux in the x32 mode and build libgcc for x32, which sound extreme. Any ideas or leads? Did someone actually try g++ -mx32? Maybe it is not even supported on the RH platform... Thanks!
P.S. In order to get the "-m32" option to work I had to install:
yum install glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 ncurses-devel.i686
This one fails (yum cannot find these RPMs) - allegedly these are required for -mx32 to work:
yum install gcc-multilib g++-multilib
:(
Multilib is indeed your answer, but do not know why your repo does not support it. I installed mine via apt-get:
sudo apt-get install gcc-multilib
Although it uses 64-bit instructions, it uses the 32-bit ABI so annoyingly will not run under WSL (Windows Linux subsystem), which only supports the 64-bit one.

OpenMP on Mac not working anymore

I had OpenMP compiling and executing in C/C++ on my Mac but then I formatted and reinstalled a fresh copy of OS X. I believe the only difference in the setup was that I had Xcode 5 before the format, and now I have Xcode 6.
Now I get fatal error: 'omp.h' file not found
I read this has something to do with clang and gcc, but, my confusion lies with why did it work before and now its not working?
After some research I seem to have found an answer.
GCC included in the latest version of Xcode (Xcode 6) is only a symbolic link to clang. Since clang does not support OpenMP at this time, you need to install a different version of GCC. The easiest way to do this would be to use Homebrew or MacPorts.
Keep in mind that even when you do this you will probably need to alter your $PATH to have /usr/local come before /usr/bin. This is because Homebrew will have placed your newly installed GCC in /usr/local. Also, some implementations may name the command gcc-49 instead of plain gcc.
Mac OSX uses clang.The gcc compiler in OS X does not support OpenMP. To use this feature a new gcc compiler needs to be installed.
Go to Terminal, if you have not installed Hombrew, install it:
/usr/bin/ruby -e "$(curl -fsSL https://`enter code here`raw.githubusercontent.com/Homebrew/install/master/install)"
then install new version of gcc
brew reinstall gcc --without-multilib
This will not make changes to the existing gcc compiler installed by Xcode as we are reinstalling it.
After running the command given below compile the files using the new version of gcc using the syntax : gcc-version -fopenmp filename.c
To find the version type gcc and then press tab. This will list out all the possible variants of gcc. The version number can be found out from this. For example : gcc-6, gcc-4.9,etc

Building gcc-4.8

I'm trying to compile gcc/g++ 4.8 on a 64-bit Fedora 17 server. I'm configuring the build process wit
./configure --prefix=/opt/gcc-4.8 --with-cpu=x86-64 --enable-languages=c,c++ --disable-multiarch
I then run make. The build chunks along for a while and then fails when it can't find crti.o. I noticed that the compile steps prior to the failure use -m32 option which means the compile is being performed for a 32-bit architecture. When I searched for crti.o, I found it in the /usr/lib64 path, not the /usr/lib path, which typically is for 32-bits. I only want to compile for 64-bit, which is why I included the with-cpu argument to configure. Obviously, this isn't enough.
What arguments do I need to include in configure so that only 64-bit compiles are made of the source and only 64-bit system libraries and similar files are linked?
I am also using 64-bit fc17 and have crti.o:
$ locate crti.o
/usr/lib/crti.o
/usr/lib64/crti.o
$ rpm -qf /usr/lib/crti.o
glibc-devel-2.15-58.fc17.i686
$ rpm -qf /usr/lib64/crti.o
glibc-devel-2.15-58.fc17.x86_64
Try to explicitly install the 32-bit version of glibc-devel:
yum install glibc-devel.i686

How to compile for Windows on Linux with gcc/g++?

I have written some effects in C++ (g++) using freeglut on Linux, and I compile them with
g++ -Wall -lglut part8.cpp -o part8
So I was wondering if it is possible to have g++ make static compiled Windows executables that contains everything needed?
I don't have Windows, so it would be really cool, if I could do that on Linux :)
mingw32 exists as a package for Linux. You can cross-compile and -link Windows applications with it. There's a tutorial here at the Code::Blocks forum. Mind that the command changes to x86_64-w64-mingw32-gcc-win32, for example.
Ubuntu, for example, has MinGW in its repositories:
$ apt-cache search mingw
[...]
g++-mingw-w64 - GNU C++ compiler for MinGW-w64
gcc-mingw-w64 - GNU C compiler for MinGW-w64
mingw-w64 - Development environment targeting 32- and 64-bit Windows
[...]
Suggested method gave me error on Ubuntu 16.04: E: Unable to locate package mingw32
===========================================================================
To install this package on Ubuntu please use following:
sudo apt-get install mingw-w64
After install you can use it:
x86_64-w64-mingw32-g++
Please note!
For 64-bit use: x86_64-w64-mingw32-g++
For 32-bit use: i686-w64-mingw32-g++
One option of compiling for Windows in Linux is via mingw. I found a very helpful tutorial here.
To install mingw32 on Debian based systems, run the following command:
sudo apt-get install mingw32
To compile your code, you can use something like:
i586-mingw32msvc-g++ -o myApp.exe myApp.cpp
You'll sometimes want to test the new Windows application directly in Linux. You can use wine for that, although you should always keep in mind that wine could have bugs. This means that you might not be sure that a bug is in wine, your program, or both, so only use wine for general testing.
To install wine, run:
sudo apt-get install wine
Install a cross compiler, like mingw64 from your package manager.
Then compile in the following way: instead of simply calling gcc call i686-w64-mingw32-gcc for 32-bit Windows or x86_64-w64-mingw32-gcc" for 64-bit Windows. I would also use the --static option, as the target system may not have all the libraries.
If you want to compile other language, like Fortran, replace -gcc with -gfortran in the previous commands.
I've used mingw on Linux to make Windows executables in C, I suspect C++ would work as well.
I have a project, ELLCC, that packages clang and other things as a cross compiler tool chain. I use it to compile clang (C++), binutils, and GDB for Windows. Follow the download link at ellcc.org for pre-compiled binaries for several Linux hosts.
From: https://fedoraproject.org/wiki/MinGW/Tutorial
As of Fedora 17 it is possible to easily build (cross-compile) binaries for the win32 and win64 targets. This is realized using the mingw-w64 toolchain: http://mingw-w64.sf.net/. Using this toolchain allows you to build binaries for the following programming languages: C, C++, Objective-C, Objective-C++ and Fortran.
"Tips and tricks for using the Windows cross-compiler": https://fedoraproject.org/wiki/MinGW/Tips
For Fedora:
# Fedora 18 or greater
sudo dnf group install "MinGW cross-compiler"
# Or (not recommended, because of its deprecation)
sudo yum groupinstall -y "MinGW cross-compiler"