This semester I got this new subject where we get to work with Discovery STM32 F4, and we are still in the phase of setting it up. But I have this problem in the beginning.
When I try to compile this «blink» code I get this error:
So, as I got it so far, we are using this shortcut command «make» to compile code, and we were given instruction to set it up as it’s shown in images below:
Can anyone see what’s the problem here?
Paolo
19.4k6 gold badges35 silver badges65 bronze badges
asked Apr 1, 2016 at 20:59
4
Error 127
means one of two things:
- file not found: the path you’re using is incorrect. double check that the program is actually in your
$PATH
, or in this case, the relative path is correct — remember that the current working directory for a random terminal might not be the same for the IDE you’re using. it might be better to just use an absolute path instead. - ldso is not found: you’re using a pre-compiled binary and it wants an interpreter that isn’t on your system. maybe you’re using an x86_64 (64-bit) distro, but the prebuilt is for x86 (32-bit). you can determine whether this is the answer by opening a terminal and attempting to execute it directly. or by running
file -L
on/bin/sh
(to get your default/native format) and on the compiler itself (to see what format it is).
if the problem is (2), then you can solve it in a few diff ways:
- get a better binary. talk to the vendor that gave you the toolchain and ask them for one that doesn’t suck.
- see if your distro can install the multilib set of files. most x86_64 64-bit distros allow you to install x86 32-bit libraries in parallel.
- build your own cross-compiler using something like crosstool-ng.
- you could switch between an x86_64 & x86 install, but that seems a bit drastic ;).
answered Apr 2, 2016 at 1:02
Mike FrysingerMike Frysinger
2,7991 gold badge21 silver badges26 bronze badges
2
I am trying to teach myself gnuMake after learning the basics of C++
I am running Ubuntu 14.04 equivalent (elementary os)
And I am getting the error (full output of make run):
g++ ./main.o -w -o test
This is a test!
/bin/sh: 1: This: not found
make: *** [exe] Error 127
My Makefile:
CC=g++
SRC=$(shell find -name '*.cpp')
OBJS= $(SRC:.cpp=.o)
EXEC=test
FLAGS= -w
LINKS=
%.o: %.cpp
$(CC) -c $*.cpp -o $*.o
$(EXEC): $(OBJS)
$(CC) $(OBJS) $(FLAGS) $(LINKS) -o $(EXEC)
all: $(EXEC)
exe:
$(shell ./$(EXEC))
run: all exe
clean:
rm -rf *.o $(EXEC)
This is a combination of taking basic make tutorials and reading Makefiles in github
main.cpp:
#include <iostream>
using namespace std;
int main()
{
cout << "This is a test!" << endl;
return 0;
}
Pretty Basic, but will be extending it to help learn to use and extend my Makefile. Now I can see the program compiles and runs, but I get the error after the run.
I searched for Make error 127 and that seems to output that error for many things, but I did not see a definition for the error, or a similar issue to mine.
- Печать
Страницы: [1] Вниз
Тема: Проблемы с makefile (Прочитано 4267 раз)
0 Пользователей и 1 Гость просматривают эту тему.

6epreu
Всем добрый день.
Имеется makefile слудеющего содержания, лежащий вместе с исходными файлами (main.c, list.s, list.h)
PATH=/usr/local
PROGRAM=result
COMPILE=gcc -c
LINK=gcc -o
$(PROGRAM): main.o list.o
$(LINK) $(PROGRAM) main.o list.o
main.o: main.c
$(COMPILE) main.c
list.o: list.c
$(COMPILE) list.c
install:
cp -f $(PROGRAM) $(PATH)
При выполлении команды make в консоли получается следующее:
make: gcc: Команда не найдена
make: *** [main.o] Ошибка 127
В чем собственно дело?

yorik1984
make: gcc: Команда не найдена
вам же все написали. Нет компилятора gcc
sudo apt-get install gcc

wl
лучше ставить build-essential
помимо голого компилятора надо еще библиотеки, заголовки, итдитп.
На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)

6epreu
Прошу прощения, что не упомянул самого главного.
«gcc» со всеми библиотеками стоит.
Пользователь решил продолжить мысль 28 Июня 2011, 14:48:20:
к тому же отдельно компилирую файлы в консоли
gcc -c main.c
Все выполняется и так же линкуется
gcc -o result main.o list.o
« Последнее редактирование: 28 Июня 2011, 14:48:20 от 6epreu »

wl
Тогда такого не может быть.
Проверьте, что там все буквы латинские, нигде русской «эс» не затесалось.
что скажет команда
which gcc
?
что скажет команда
gcc main.c list.c -o result
?
Кстати, в цели install у Вас файл копируется в /usr/local, а надо бы в /usr/local/bin
Ну и выполнять эту цель надо от sudo
sudo make install
Тьфу, бллин!
Ну вот скажите, накой Вам понадобилось PATH переопределять?!
INSTALLDIR = /usr/local
PROGRAM = result
COMPILE = gcc -c
LINK = gcc -o
$(PROGRAM): main.o list.o
$(LINK) $(PROGRAM) main.o list.o
main.o: main.c
$(COMPILE) main.c
list.o: list.c
$(COMPILE) -c list.c
install:
cp -f $(PROGRAM) $(INSTALLDIR)
И все работает!
Вообще говоря, так, как Вы, никто не делает.
Если уж понадобилось определить все в переменных, надо различать компилятор и его ключи.
И стандартные имена переменных для таких случаев тоже есть: $CC, $CXX, $CFLAGS, $CXXFLAGS, $LDFLAGS
« Последнее редактирование: 28 Июня 2011, 15:23:14 от wl »
На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)

6epreu
что скажет команда
Код:
which gcc
?
говорит следующее: /usr/bin/gcc
что скажет команда
Код:
gcc main.c list.c -o result
?
Уже упоминал об этом выше. Если просто компилировать без makefile, то компилятор выполняет свою работу корректно.
Кстати, в цели install у Вас файл копируется в /usr/local, а надо бы в /usr/local/bin
Ну и выполнять эту цель надо от sudo
По поводу пути не особо важно, а выполняю от sudo.
Тьфу, бллин!
Ну вот скажите, накой Вам понадобилось PATH переопределять?!
Вот тут виноват! А собственно за что отвечает PATH?
Объясните пжалуйста, ибо makefile я решил написать чисто для себя, чтобы в чужих makefile ах можно было ковыряться и понимать приблизительно, что там происходит.
Спасибо, за ответ!!! Попробовал у себя makefile с INSTALLDIR = /usr/local тоже все работат)

wl
Тьфу, бллин!
Ну вот скажите, накой Вам понадобилось PATH переопределять?!Вот тут виноват! А собственно за что отвечает PATH?
Переменная окружения PATH задает список директорий, в которых находятся исполняемые файлы.
Попробуйте в командной строке написать
echo $PATH
Пока я не заметил этого, пробовал задать
COMPILE = /usr/bin/gcc
gcc нашелся и запустился, но заявил что не может найти as
Makefiles, кстати, уже почти не пишутся руками. Чаще они генерируются автоматически.
Так что рекомендую ознакомиться с системами build automation.
Наиболее распространенная сейчас — autotools (порождающая здоровенный скрипт configure, тоже, кстати, автогенерированный из configure.ac и Makefile.am). На пятки ей наступает CMake.
В педивикии можно найти более полный список.
« Последнее редактирование: 29 Июня 2011, 11:06:13 от wl »
На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)

6epreu
нет, если писать COMPILE = /usr/bin/gcc то прокатывает.
Про PATH понял, это такой же PATH как и в винде.
А за обзор софта для генерации мэйков — спасибо. Сам под UNIX пока не пишу, но в скором времени предстоит.
В частности написание собственного makefile было нужно, чтобы разобраться в чужом.

RazrFalcon
Про PATH понял, это такой же PATH как и в винде.
Приблизительно

wl
нет, если писать COMPILE = /usr/bin/gcc то прокатывает.
Если в начале задается PATH, а потом COMPILE=/usr/bin/gcc , то прокатывает только вызов gcc.
Сам gcc пытается запустить as, но не находит его и объектного файла не создает.
Про PATH понял, это такой же PATH как и в винде.
1. Отличие в том, что в линуксе в пути не может быть точки (текущей директории).
Точнее, ее можно туда руками добавить, но это неправильно, у меня bash в ответ на каждую команду ругался, мол, у вас там точка в пути.
Если пути не указано, исполняемые файлы ищутся только в директориях, перечисленных в PATH. Чтобы запустить файл из текущей надо писать ./a.out
2. PATH — это только для исполняемых файлов.
Динамические библиотеки, в отличие от винды, ищутся в путях, указанных в /etc/ld.so.conf и в переменной LD_LIBRARY_PATH
Подробности в man ld.so
« Последнее редактирование: 29 Июня 2011, 13:25:59 от wl »
На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)

6epreu
2. PATH — это только для исполняемых файлов.
Динамические библиотеки, в отличие от винды, ищутся в путях, указанных в /etc/ld.so.conf и в переменной LD_LIBRARY_PATH
Подробности в man ld.so
Опять же спасибо, вот этого не знал!
- Печать
Страницы: [1] Вверх
I am trying to install shc on Ubuntu 18.04
wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9b.tgz
tar xvfz shc-3.8.9.tgz
cd shc-3.8.9
make
But receive the following error:
cc -Wall shc.c -o shc
make: cc: Command not found
makefile:31: recipe for target 'shc' failed
make: *** [shc] Error 127
The makefile:
# Makefile
#
INSTALL_PATH = /usr/local
# For SCO
CFLAGS = -b elf -O -D_SVID
# For IRIX
CFLAGS = -xansi -fullwarn -O3 -g0
# For Solaris
CFLAGS = -fast -xO4 -s -v -Xa
# For HPUX
CFLAGS = -Wall -O -Ae
# For OSF1
CFLAGS = -w -verbose -fast -std1 -g0
# For GNU C compiler
CFLAGS = -Wall # -O6 -pedantic
#SHELL = /bin/sh
SHCFLAGS = -v -T # Add -T option to allow binary to be traceable
all: shc ask_for_test
shc: shc.c
$(CC) $(CFLAGS) $@.c -o $@
ask_for_test:
@echo '*** �Do you want to probe shc with a test script?'
@echo '*** Please try... make test'
test: make_the_test ask_for_strings
make_the_test: match.x
@echo '*** Running a compiled test script!'
@echo '*** It must show files with substring "sh" in your PATH...'
./match.x sh
match.x: shc match
@echo '*** Compiling script "match"'
CFLAGS="$(CFLAGS)" ./shc $(SHCFLAGS) -f match
ask_for_strings:
@echo '*** �Do you want to see strings in the generated binary?'
@echo '*** Please try... make strings'
strings: make_the_strings ask_for_expiration
make_the_strings: match.x
@echo '*** Running: "strings -n 5 'match.x'"'
@echo '*** It must show no sensible information...'
strings -n 5 match.x
ask_for_expiration:
@echo '*** �Do you want to probe expiration date?'
@echo '*** Please try... make expiration'
expiration: til_yesterday ask_for_install
til_yesterday: shc match
@echo '*** Compiling "match" to expired date'
CFLAGS="$(CFLAGS)" ./shc $(SHCFLAGS) -vv -e `date "+%d/%m/%Y"` -f match
@echo '*** Running a compiled test script!'
@echo '*** It must fail showing "./match.x: has expired!"'
./match.x
ask_for_install:
@echo '*** �Do you want to install shc?'
@echo '*** Please try... make install'
install: shc
@echo '*** Installing shc and shc.1 on '$(INSTALL_PATH)
@echo -n '*** �Do you want to continue? '; read ANS; case "$$ANS" in y|Y|yes|Yes|YES) ;; *) exit 1;; esac;
install -c -s shc $(INSTALL_PATH)/bin/
install -c -m 644 shc.1 $(INSTALL_PATH)/man/man1/
clean:
rm -f *.o *~ *.x.c
cleanall: clean
rm -f shc *.x
I have no idea how to fix this error. Can anyone help?
slava
3,7679 gold badges30 silver badges65 bronze badges
asked Nov 22, 2018 at 17:24
2
cc is an alias for the GNU C compiler (gcc). You can install it as follows:
sudo apt install gcc
If, for some reason, the gcc compiler is already installed, but the symbolic link /usr/bin/cc
is missing, you can also do:
make CC=gcc
answered Nov 22, 2018 at 18:07
1
sudo apt install build-essential
This will install a C compiler (providing the cc
command) as well as other tools that you may need for building software from source.
answered Nov 22, 2018 at 19:39
moomoo
6656 silver badges14 bronze badges
I’ve installed the newest version of Cygwin on my Windows XP SP3 machine.
I’m using a very simple makefile (see attached). when I execute «make» I get the following output:
rm -f *.0
g++ -c -g main.cpp
make: g++: Command not found
make: *** [main.o] Error 127
I’ve added the bin directory to the systems PATH, and g++ can execute from the command line.
If I type in the makefile’s lines manually, I can compile the .o files and the .exe.
I’m not experienced with Linux, so please don’t assume anything in that regards.
Thank you.
all: P3
P3: removal main.o utility.o
g++ -o P3 main.o utility.o
main.o: main.cpp
g++ -c -g main.cpp
utility.o: utility.cpp
g++ -c -g utility.cpp
removal:
rm -f *.o
Open in new window