Leso_KN Leso_KN - 2 months ago 21x
C++ Question

g++: as fails to determine which assembler to run

Today I wanted to recompile one of my projects. Compiling this project had already worked on my machine, but this time an error occured.

The compiler output goes:

fatal error: as: unknown host architecture (can't determine which assembler to run)`

for the line:

g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../../.vscode -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I../../.vscode -I. -o Main.o ../../Main.cpp

I tried to compile some other projects, but realized, that I wouldn't be able to compile anything using any c++ compiler, so I looked it up.

The only fitting thread I found was this one but the solution 'reinstalling binutils' didn't work for me (tried
sudo apt-get install --reinstall binutils
as well as
--reinstall gcc

One possible reason for this problem that comes to my mind is the iOS-toolchain I installed yesterday - I had to install some different clang versions - but I actually didn't change anything on the system's assembler...

If someone's got an idea; any help would be appreciated :)

Additional info:

Ubuntu 16.04 LTS 64bit

AMD FX(tm)-6300 Six-Core Processor × 6

uname -m


gcc -march=native -v -E - 2>&1 <<<'' | grep "cc1" | egrep -o -e $'-m(arch|tune)=[^ "\']+'


already tried
gcc [...] -march
and other architectures

g++ -v -c HelloWorld.cpp
gives me: http://pastebin.com/Ks2be0hL

type -a as

as is /usr/local/bin/as
as is /usr/bin/as

as --version
sadly just show's me the error again, but
info as
tells me it's
from 2016-08-07

dpkg -S /usr/bin/as
binutils: /usr/bin/as


type -a as says as is /usr/local/bin/as. This is what gcc is running, not /usr/bin/as, because /usr/local/bin/as is found first in your $PATH search order. This is why re-installing packages and so on is having no effect: something else you installed (probably manually) installed a non-standard as.

Have a look at /usr/local/bin/as and figure out where it came from, and what to do with it. For now you can just rename it to as.unknown or something, and then everything will use the normal system assembler (/usr/bin/as).