Thread: Relocation error against undefined symbol

  1. #1
    Registered User
    Join Date
    Sep 2019
    Posts
    15

    Relocation error against undefined symbol

    Hi, When building a certain software, I receive this error message during the link stage:

    Code:
    /usr/bin/ld: _obj/device/r4300/x86_64/dyna_start.o: relocation R_X86_64_PC32 against undefined symbol `g_dev' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value
    I followed the advice and added -fPIC to all the the standard building rules, except one that uses nasm instead gcc or g++. However, the error message persisted.

    So I am open to suggestions.

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    A little inaccuracy saves tons of explanation. - H.H. Munro

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Context post here Relocation error against undefined symbo - C++ Forum

    Have you read the NASM manual?
    NASM - The Netwide Assembler

    In particular
    NASM - The Netwide Assembler

    In assembler, you have to do all the grunt work yourself.
    There's no magic wand you can just wave at the command line, and voila, position independent code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Sep 2019
    Posts
    15
    Quote Originally Posted by Salem View Post
    Context post here Relocation error against undefined symbo - C++ Forum

    Have you read the NASM manual?
    NASM - The Netwide Assembler

    In particular
    NASM - The Netwide Assembler

    In assembler, you have to do all the grunt work yourself.
    There's no magic wand you can just wave at the command line, and voila, position independent code.
    Keep in mind that the code is not mine, I am building the program and end facing this error. I read the last link, but that will not be enough for me to solve the error. I can post the assembly code from the file, that is around 80 lines of code, and probably less than 60 lines would be relevant to the issue.

    Quote Originally Posted by john.c View Post
    Does not seem to be the case. On the link he was having trouble to generate a shared library from a static one that was compiled without -fPIC.
    Last edited by colt; 01-16-2024 at 06:30 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 08-28-2015, 07:48 AM
  2. Replies: 14
    Last Post: 02-09-2015, 12:34 AM
  3. Linking Error: Undefined Symbol
    By viclapurga in forum C++ Programming
    Replies: 2
    Last Post: 09-25-2005, 05:45 AM
  4. Undefined symbol error??
    By Jedijacob in forum C Programming
    Replies: 10
    Last Post: 03-18-2005, 04:46 PM
  5. Undefined Symbol error
    By Eavan Hyde in forum C++ Programming
    Replies: 3
    Last Post: 05-06-2004, 03:39 AM

Tags for this Thread