[SOLVED] Compilation error regarding GNU ld.

Kernels & Hardware, configuring network, installing services

[SOLVED] Compilation error regarding GNU ld.

Postby NoobProgrammer » 2017-08-05 00:16

My first post here.

I am trying to compile Poschengband and I got this error:

Code: Select all
/usr/bin/ld: -r and -pie may not be used together
collect2: error: ld returned 1 exit status


So I went to the Makefile and removed the -r option; nevertheless, I get errors:

Code: Select all
/usr/bin/ld: cannot find : No such file or directory
collect2: error: ld returned 1 exit status


I have no idea how to get rid of the -pie option. I found out that Debian Stretch intentionally forces the -pie option by default. Any help is appreciated.

I just have one question for you people: WHY, just WHY, is -pie a forced option for ld???? I just wanted to get Poschengband working a few hours ago without going through this hassle.
Last edited by NoobProgrammer on 2017-08-06 02:55, edited 1 time in total.
NoobProgrammer
 
Posts: 6
Joined: 2017-08-04 23:42

Re: Compilation error regarding GNU ld.

Postby stevepusser » 2017-08-05 01:25

It's standard because it "hardens" the finished binary and makes it more resistant to many common cracking attacks:

https://en.wikipedia.org/wiki/Position-independent_code

It looks like the missing file that it can't find is just a whitespace, so maybe just another minor edit of the Makefile to get rid of a whitespace could fix it. I also think you could try compiling with the flag -fPIC instead of PIE...are you sure PIE is not a standard version of your version of gcc and not exclusive to Debian? Such as the code dating from back in gcc-4.X days and now we have gcc-6?

Yeah, that looks like it. Lots of packages in the Stretch repository have required patches to build with gcc-6, this is just another example of one that built fine with gcc-4.X, but needs some massaging for gcc-6.

I do have gcc-4.9 packages in my Stretch OBS Pale Moon repository, since the PM developers say that's what it has to be built against, and I know the flags that make a program compile against the older gcc, if you're interested in that option.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.1.0, Pale Moon 27.5.0, Liquorix kernel 4.12-10, mpv 0.27.0, Kodi 17.3, 0ad 0.0.22, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8809
Joined: 2009-10-06 05:53

Re: Compilation error regarding GNU ld.

Postby NoobProgrammer » 2017-08-05 01:52

So... how do I switch to gcc4.x?

That -pie option needs to go away in my case.

The -pie option is nowhere to be found in any of the makefiles.


EDIT: I added -fPIC to my Makefile and I get

Code: Select all
Entering directory src
/usr/bin/ld: cannot find : No such file or directory
collect2: error: ld returned 1 exit status
Makefile:30: recipe for target 'poschengband.o' failed
make[3]: *** [poschengband.o] Error 1
../mk/buildsys.mk:110: recipe for target 'all' failed
make[2]: *** [all] Error 2
mk/buildsys.mk:117: recipe for target 'subdirs' failed
make[1]: *** [subdirs] Error 2
mk/buildsys.mk:110: recipe for target 'all' failed
make: *** [all] Error 2
NoobProgrammer
 
Posts: 6
Joined: 2017-08-04 23:42

Re: Compilation error regarding GNU ld.

Postby stevepusser » 2017-08-05 20:07

I have gcc-4.9 in my Stretch OBS Palemoon repository: https://build.opensuse.org/project/show ... evenpusser

You can add the repo and its key by becoming root in a terminal (sudo users can do this with "sudo -i") and running

Code: Select all
echo 'deb http://download.opensuse.org/repositories/home:/stevenpusser/Debian_9.0/ /' > /etc/apt/sources.list.d/gcc-4.9.list


Then as a regular user, delete any possible previously downloaded keys, then download the key for that repo:

Code: Select all
rm -f Release.key
wget -nv http://download.opensuse.org/repositories/home:stevenpusser/Debian_9.0/Release.key -O Release.key


Then, back as root, install the key, update the package database, and install the build tools:

Code: Select all
apt-key add - < Release.key
apt-get update
apt-get install gcc-4.9 g++-4.9 cpp-4.9


Then in the same terminal as you are building your program, you set the environment to use those tools to build the program before starting your build:

Code: Select all
export CC=gcc-4.9
export CXX=g++-4.9
export CPP=cpp-4.9
export LD=gcc-4.9


At least, that's what's working for Pale Moon. Though it's built using gcc-4.9, the resulting Pale Moon binary runs just fine on the gcc-6 runtime libraries, so you may not need any of those gcc-4.9 packages you installed after you build the program.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.1.0, Pale Moon 27.5.0, Liquorix kernel 4.12-10, mpv 0.27.0, Kodi 17.3, 0ad 0.0.22, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8809
Joined: 2009-10-06 05:53

Re: Compilation error regarding GNU ld.

Postby NoobProgrammer » 2017-08-05 20:53

I followed your instructions, I got this error:

Code: Select all
Reading package lists... Done
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
NoobProgrammer
 
Posts: 6
Joined: 2017-08-04 23:42

Re: Compilation error regarding GNU ld.

Postby stevepusser » 2017-08-05 21:19

Which command gives that error? You have to be precise if you want us to be able to troubleshoot what's going wrong.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.1.0, Pale Moon 27.5.0, Liquorix kernel 4.12-10, mpv 0.27.0, Kodi 17.3, 0ad 0.0.22, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8809
Joined: 2009-10-06 05:53

Re: Compilation error regarding GNU ld.

Postby NoobProgrammer » 2017-08-05 21:39

Gahh.... I just realized I pasted the wrong chunk of text. It's this one after typing make:

Code: Select all
Entering directory src
/usr/bin/ld: cannot find : No such file or directory
collect2: error: ld returned 1 exit status
Makefile:30: recipe for target 'poschengband.o' failed
make[3]: *** [poschengband.o] Error 1
../mk/buildsys.mk:110: recipe for target 'all' failed
make[2]: *** [all] Error 2
mk/buildsys.mk:117: recipe for target 'subdirs' failed
make[1]: *** [subdirs] Error 2
mk/buildsys.mk:110: recipe for target 'all' failed
make: *** [all] Error 2
NoobProgrammer
 
Posts: 6
Joined: 2017-08-04 23:42

Re: Compilation error regarding GNU ld.

Postby stevepusser » 2017-08-05 21:53

That's the linker, but gcc-4.9 is supposed to be providing it per that command that sets that in the environment:

export LD=gcc-4.9

Let me fire a up a Stretch virtual machine and try this mess myself.

Are there any forums for this package where anyone has tried to build it on a recent Linux? Maybe it's in the Arch AUR or something.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.1.0, Pale Moon 27.5.0, Liquorix kernel 4.12-10, mpv 0.27.0, Kodi 17.3, 0ad 0.0.22, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8809
Joined: 2009-10-06 05:53

Re: Compilation error regarding GNU ld.

Postby stevepusser » 2017-08-05 22:14

This seems like the same problem, with a possible solution: https://github.com/poschengband/poschengband/issues/38
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.1.0, Pale Moon 27.5.0, Liquorix kernel 4.12-10, mpv 0.27.0, Kodi 17.3, 0ad 0.0.22, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8809
Joined: 2009-10-06 05:53

Re: Compilation error regarding GNU ld.

Postby NoobProgrammer » 2017-08-06 01:19

I added the -no-pie option, I get this error on linking:

Code: Select all
Successfully compiled main-gcu.c
      LINK poschengband.o     
Successfully compiled main-x11.c
gcc: error: poschengband.o: No such file or directory
Makefile:23: recipe for target 'poschengband' failed
make[3]: *** [poschengband] Error 1
../mk/buildsys.mk:110: recipe for target 'all' failed
make[2]: *** [all] Error 2
mk/buildsys.mk:117: recipe for target 'subdirs' failed
make[1]: *** [subdirs] Error 2
mk/buildsys.mk:110: recipe for target 'all' failed
make: *** [all] Error 2


EDIT: never mind. I followed the instructions on angband.oook.cz, successful compilation
NoobProgrammer
 
Posts: 6
Joined: 2017-08-04 23:42

Re: [SOLVED] Compilation error regarding GNU ld.

Postby stevepusser » 2017-08-06 19:32

I'm glad to see you resolved it. Ideally, the developer would fix the compilation problem in the code so it will work with gcc-6. The build process seems a bit off to me, too--ordinarily, a program where you have to run a configure step uses that to generate a custom Makefile, but this one ships with one in the root of the source, and I don't see it getting modified. Maybe it's generating one or more in a subdirectory.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: AzPainter 2.1.0, Pale Moon 27.5.0, Liquorix kernel 4.12-10, mpv 0.27.0, Kodi 17.3, 0ad 0.0.22, Mesa 13.0.6
User avatar
stevepusser
 
Posts: 8809
Joined: 2009-10-06 05:53


Return to System configuration

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable
cron