Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

debian make install: cannot create regular file

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
oehqoehfo
Posts: 2
Joined: 2022-05-23 21:26

debian make install: cannot create regular file

#1 Post by oehqoehfo »

Hi,
I am following https://www.debian.org/doc/manuals/debm ... 04.en.html to start with Debian
I am running Debian in linux which is being running with VirtualMachine

In the section of 4.5 of the link which I posted, I see such makefile code

Code: Select all

 $ cat debhello-0.0/Makefile
prefix = /usr/local

all: src/hello

src/hello: src/hello.c
        @echo "CFLAGS=$(CFLAGS)" | \
                fold -s -w 70 | \
                sed -e 's/^/# /'
        $(CC) $(CPPFLAGS) $(CFLAGS) $(LDCFLAGS) -o $@ $^

install: src/hello
        install -D src/hello \
                $(DESTDIR)$(prefix)/bin/hello

clean:
        -rm -f src/hello

distclean: clean

uninstall:
        -rm -f $(DESTDIR)$(prefix)/bin/hello

.PHONY: all install clean distclean uninstall

This is a makefile which I have:

Code: Select all

prefix = /usr/local
all: electrotest


electrotest: electrotest_standalone.c
	gcc -o electrotest_standalone electrotest_standalone.c -lm
install:electrotest
	install -D electrotest_standalone \
	$(DESTDIR)$(prefix)/bin/electrotest_standalone
clean:
	-rm -f electrotest_standalone

distclean:clean
uninstall:
	-rm -f $(DESTDIR)$(prefix)/bin/electrotest_standalone
	
Since makefile and electrotest_standalone are under same folder, electroest works just fine. Problem is inside install. I see this error when I run make install
gcc -o electrotest_standalone electrotest_standalone.c -lm
install -D electrotest_standalone \
/usr/local/bin/electrotest_standalone
install: cannot create regular file '/usr/local/bin/electrotest_standalone': Permission denied
makefile:8: recipe for target 'install' failed
make: *** [install] Error 1
What am I doing wrong here? I heard sudo make install should fix the problem, but I am not sure if it is safe to run the command with sudo in this situation...

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: debian make install: cannot create regular file

#2 Post by Head_on_a_Stick »

Root permissions are required to install to /usr/local/bin/ but you could install to (for example) "$HOME"/bin/ instead:

Code: Select all

make prefix="$HOME" install
deadbang

Post Reply