sub :- error: ld returned 1 exit status
hi to all, I've centos7.5 and codeblocks17.12 in VM. I am building a simple shared library file. but having following problem:-
header file:-
-------------
singlyll.h
Code:
#ifndef SINGLYLL_H_INCLUDED
#define SINGLYLL_H_INCLUDED
#include <iostream>
#include <cstdlib>
class linklist
{
struct node
{
int data;
node *link;
};
node *start, *p;
public:
void display( linklist * pll );
};
#endif // SINGLYLL_H_INCLUDED
implementation file :-
---------------------
singlyll.cpp
Code:
#include "singlyll.h"
using namespace std;
void linklist::display( linklist *pll)
{
if(pll->start == NULL)
{
cout << "list is empty\n";
return;
}
cout << "List : ";
node *p = pll->start;
for(; p != NULL; p = p->link)
{
cout << p->data <<"\t";
}
cout <<"\n\n";
}
build message :-
Code:
error: ld returned 1 exit status
-------------- Build: Debug in singlyll (compiler: GNU GCC Compiler)---------------
Code:
g++ -shared obj/Debug/singlyll.o -o bin/Debug/libsinglyll.so
/usr/bin/ld: obj/Debug/singlyll.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))