generating 64 bit code on 32bit debian system - linux

Could you please describe that how have you installed gcc-multilib and g++-multilib on 32bit debian machine to generate 64 bit code?
I installed gcc-4.7.2 on my 32bit debian system(and also installed binutils-2.23). When i try to compile a simple hello world program with -m64 flag as
# gcc -m64 hello.c
I am getting following error message:
"hello.c:1:0: sorry, unimplemented: 64-bit mode not compiled in" .
Please tell me the steps to generate the 64bit code on 32bit debian system.

You need to re-install gcc with this option in the configure.

Related

Problems with sfml function in linux

I have a sfml c++ project. In this project, if I use the "sf::Mouse::setPosition" sfml method, the program crashes in 2-3 seconds after launch. If i don't use the "sf::Mouse::setPosition" sfml method, the runs successfully.
OS: Kubuntu 22.10 x64,
Kernel: 5.19.0-28-generic,
Video card: GT 730,
Compiler: gcc version 12.2.0 (Ubuntu 12.2.0-3ubuntu1),
SFML has installed by apt, libsfml-dev version 2.5.1+dfsg-2.
Makefile:
`
compile:./main.cpp
g++ -c main.cpp
g++ main.o -o app -lsfml-graphics -lsfml-window -lsfml-system
run:
./app
`
I've tried to use legacy nvidia-driver-390, xserver-xorg-video-nouveau but it doesn't work. Maybe I should compile sfml source code for better compatibility, but i don't know how to do this. Also the problem might be in gcc version (maybe sfml 2.5.1 doesn't support 12.2.0).

Compile an old Linux kernel on Ubuntu 16.04 LTS

I tried to compile the Linux kernel 3.10.31 on Ubuntu 16.04 LTS.
I used to compile the exact same kernel on Ubuntu 12.04 LTS, and everything works well.
On Ubuntu 16.04, the gcc version is gcc-5;
On Ubuntu 12.04, the gcc version is gcc-4.6.
It seems that the Linux kernel kernel before 3.18 cannot compile with the gcc-5. The kernel 3.10.31 reports the following error when it is compiled by make
fatal error: linux/compiler-gcc5.h: No such file or directory
I tried to install gcc-4.7 onto Ubuntu 16.04 and change the /usr/bin/gcc to point to the gcc-4.7. This could solve the above error. However, it leads to new issues after I run make
$linux/arch/x86/Makefile:98: stack protector enabled but no compiler support
make[1]: Nothing to be done for 'all'.
make[1]: Nothing to be done for 'relocs'.
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CC kernel/bounds.s
gcc-4.7.real: error: unrecognized command line option ‘-no-pie’
linux/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:835: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
My question is:
Is there a neat way to use the old compiling chain to compile the old kernel 3.10.31 on Ubuntu 16.04?
Thank you very much for your help! Any advice is really appreciated.
I think I figured out a solution.
We don't have to install the old version gcc. We only need to copy the file compiler-gcc5.h from here or from here into include/linux/. It will solve the compilation issue.
Ubuntu 16.04 now still supports gcc-4.7 so you can install it and then you can choose the version of gcc before using it by update-alternatives.
For examples:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50
sudo update-alternatives --config gcc # here you choose by hint
If you directly download compiler-gcc5.h, you may meet problems like arch/x86/kvm/svm.c error invalid character that I met when compiling 3.3.8 in Ubuntu 16.04.3 x64.
Open the Makefile, look for CFLAGS_EXTRA and add the following option to it -fno-pie.
See, https://askubuntu.com/questions/851433/kernel-doesnt-support-pic-mode-for-compiling.

GCC keeps saying -mfpu=neon is an unrecognoized command

I am compiling code to run on an arm neon and the make files have the following command line included.
-mcpu=cortex-a9 -march=armv7 -mfpu=neon -DARM_NEON
The details of GCC version are as follows:
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
However when I try to compile, gcc keeps throwing the following error:
gcc: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
gcc: error: unrecognized command line option '-mfpu=neon'
I am pretty sure that the code could be compiled previously. Though a long time ago. Could it be changes in version of GCC? or is it do with 32 bit and 64 bit compilers?
I was trying to cross compile for an arm processor on my intel x86_64 Ubuntu machine. I needed to add the configuration for the host in the makefiles and use arm-linux-gnueabihf-gcc instead of gcc.

unable to build kernel driver - Debian Jessie stackprotector

We have one Debian Jessie installation into which I am attempting to install a kernel driver.
Basically, upon build the makefile drops out with :
Cannot use CONFIG_CC_STACKPROTECTOR_REGULAR: -fstack-protector not supported by compiler.
We're on kernel 3.16 with gcc 4.9.1
I'm fairly sure that 4.9.1 supports -fstack-protector so I'm stumped.
Would very much appreciate some help getting this built.

Gcc compile hello.c for c6x

I compiled hello.c program for c6x architecture:
gcc-4.8 -o hello -march='c64x' hello.c
But It got an error: error: bad value (c64x) for -march= switch
Seem gcc can't recognize c64x architecture!
I am using Ubuntu 12.04 LTS & gcc-4.8 version.
Thank you!
-march=name
This specifies the name of the target architecture.
But in your case target is TI (c64x) board i.e its arm architecture. to compile your program for arm architecture you need cross-compiler. But you trying to compile on x86gcc native-compiler with option -march which is different from target target. i.e "gcc" is a native compiler. In your case it appears you are not working on an ARM host, thus "gcc" will not compile for ARM on x86.
so download the cross-compiler tool chain and then compile your program with your options.
cross compiler for ubuntu is here
http://www.filewatcher.com/m/gcc-c6x-linux-gnu-4.7.1-0.1.20120606.fc18.1.i686.rpm.10801432-0.html

Resources