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

 

 

 

[SOLVED] Compilation error regarding GNU ld.

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
NoobProgrammer
Posts: 6
Joined: 2017-08-04 23:42

[SOLVED] Compilation error regarding GNU ld.

#1 Post by NoobProgrammer »

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.

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compilation error regarding GNU ld.

#2 Post by stevepusser »

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.
MX Linux packager and developer

NoobProgrammer
Posts: 6
Joined: 2017-08-04 23:42

Re: Compilation error regarding GNU ld.

#3 Post by NoobProgrammer »

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

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compilation error regarding GNU ld.

#4 Post by stevepusser »

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.
MX Linux packager and developer

NoobProgrammer
Posts: 6
Joined: 2017-08-04 23:42

Re: Compilation error regarding GNU ld.

#5 Post by NoobProgrammer »

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)

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compilation error regarding GNU ld.

#6 Post by stevepusser »

Which command gives that error? You have to be precise if you want us to be able to troubleshoot what's going wrong.
MX Linux packager and developer

NoobProgrammer
Posts: 6
Joined: 2017-08-04 23:42

Re: Compilation error regarding GNU ld.

#7 Post by NoobProgrammer »

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

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compilation error regarding GNU ld.

#8 Post by stevepusser »

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.
MX Linux packager and developer

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compilation error regarding GNU ld.

#9 Post by stevepusser »

This seems like the same problem, with a possible solution: https://github.com/poschengband/poschengband/issues/38
MX Linux packager and developer

NoobProgrammer
Posts: 6
Joined: 2017-08-04 23:42

Re: Compilation error regarding GNU ld.

#10 Post by NoobProgrammer »

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

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: [SOLVED] Compilation error regarding GNU ld.

#11 Post by stevepusser »

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.
MX Linux packager and developer

Post Reply