skip to Main Content

Hello I’m learning <CSE 251 Programming in C> from webside https://www.cse.msu.edu/~cse251/project2.html.
I obtain the project and do the command ‘make elevator64’ in Ubuntu terminal.
But it failed. The error is below:

g++ -o elevator elevator.o -lm libElevatorLib64.a `wx-config --libs`
/usr/bin/ld: libElevatorLib64.a(ElevatorLib.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: libElevatorLib64.a(CApp.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: libElevatorLib64.a(CFrame.o): relocation R_X86_64_32 against symbol `_ZN6CFrame13sm_eventTableE' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: 最后的链结失败: 输出不可表示的节
collect2: error: ld returned 1 exit status
Makefile:14: recipe for target 'elevator64' failed
make: *** [elevator64] Error 1

What happens?
Can anyone help me?

2

Answers


  1. Chosen as BEST ANSWER

    I had finally builded the environment for CSE-251-Programming-in-C labs and projects. Here's my share: https://github.com/elivon2000/CSE-251-Programming-in-C


  2. What happens?

    You are trying to link your project with some pre-built library libElevatorLib64.a, which was built without -fPIE.

    But your GCC is configured to produce PIE binaries by default, and can’t use such a library.

    To fix, ask your GCC to produce a non-PIE binary:

    g++ -no-pie -o elevator elevator.o libElevatorLib64.a `wx-config --libs`
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search