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
Related
I am writing a program in QT Creator, for the x86 architecture, using Debian 9 x86. The program will use GNU Readline library [8.0]. Also, my program must be statically built (QT is already statically built). For this I downloaded Readline from here.
Then performed the configuration for the static assembly:
./configure —prefix=/home/out/readlinelibs/ —enable-static —with-curses
then i performed the construction:
make
and installing libraries
make install
In QT's pro file I added the path to the libraries:
LIBS += -L/home/out/readlinelibs/lib -static -lreadline -ltinfo
When compiling the program I get the following error in QT:
error: cannot find -ltinfo
How to build readline in static mode? Thanks.
P.S.: in Debian x64 I also built readline and everything works well.
It was the lack of a tinfo library, as mbieren advised. I performed the installation on a 64-bit system as follows:
Added ability to install 32-bit packages:
sudo dpkg --add-architecture i386
I scanned the package and found that i need. You can do the scan so:
sudo apt-cache search tinfo
Finally i installed that i need:
sudo apt-get install lib32tinfo5 lib32tinfo-dev
Now the compilation of my program for 32-bit architecture is completed successfully!
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)
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.
Using
gcc -m32 myprog.c
should compile in 32 bit version the file myprog.c.
Unfortunately I get this error:
In file included from /usr/include/stdio.h:27:0,
from myprog.c:1:
/usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
#include <sys/cdefs.h>
How could I fix this?
If I don't use -m32 it works but uses 64 bit instructions.
To compile 32 bit binaries on 64 bit Linux version, you have to Install libx32gcc development package and 32 bit GNU C Library
try this
sudo apt-get install libx32gcc-4.8-dev
and
sudo apt-get install libc6-dev-i386
You need gcc multilib support. Install the package gcc-multilib. E.g.:
sudo apt-get install gcc-multilib
I encountered to this same problem. when I was trying to build 32 bit so file while i'm in 64 bit ubuntu version.
you can build by switching your lib version into 64 bit
in netbeans
(-> project properties -> C compiler -> additional options) set to
-shared -m64
To fix the issue we first need to know which package will provide the file sys/cdefs.h
In CentOs/RHEL based system you can find it by running below command
yum provides '*sys/cdefs.h'
Similarly, in Debian/Ubuntu systems you can find it by running
apt-file search 'sys/cdefs.h'
Note: If apt-file package is not already present on the system install it with command
apt-get install apt-file
Both above commands will scan the respective package management systems database i.e RPM/Apt and tells the name of the package which supplies the file ending with "sys/cdefs.h".
Install the appropriate package from the packages listed by the commands.
Like
On CentOs/RHEL:
yum install glibc-headers
On Debian/Ubuntu
apt-get install libc6-dev
This approach is not only useful for this particular issue but any similar issue which is reporting some required file being provided by some package being not present.
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"