Author Topic: -fPIC flag is not showing in list  (Read 4193 times)

Offline Rahul

  • Multiple posting newcomer
  • *
  • Posts: 25
-fPIC flag is not showing in list
« on: January 13, 2019, 01:58:30 pm »
hi to all, I've centos 6.4 in VM and codeblocks 16. I developed shared library project before ( i installed in previous VM of centos due to some reason i  removed that centos and installed new). After that i installed codeblocks 16 in new centos. But having problem with codeblocks it is not showing -fPIC flag for shared lib project  and  that page is not showing.  this is  image of previous  centos and codeblocks :
 (i don't know how to upload images) 

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: -fPIC flag is not showing in list
« Reply #1 on: January 13, 2019, 02:07:25 pm »
Have you looked if the option is in the other compiler options tab?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Rahul

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: -fPIC flag is not showing in list
« Reply #2 on: January 14, 2019, 11:46:29 am »
thanks for your reply,  yes i saw in project-build-opotion->other-compiler-option there is nothing

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: -fPIC flag is not showing in list
« Reply #3 on: January 14, 2019, 07:10:06 pm »
This is text field where you can enter anything you like.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Rahul

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: -fPIC flag is not showing in list
« Reply #4 on: January 15, 2019, 11:11:07 am »
but question is how to find "-fPIC" flag in codebloks compiler settings. hare is screenshot of compiler flags option :

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: -fPIC flag is not showing in list
« Reply #5 on: January 15, 2019, 11:26:54 am »
The answer is (and obfuscated tried to tell you) You can add any option, that is not present in "compiler flags" to the text filed in "other compiler flags"
So if you need to add "-fPIC" you simply add this in the "other compiler flags" control. One flag per line would be the default.

Offline Rahul

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: -fPIC flag is not showing in list
« Reply #6 on: January 15, 2019, 03:44:30 pm »
i did it as you said buy it gives same error : -
Code
------------ Build: Debug in datemanip (compiler: GNU GCC Compiler)---------------

g++ -shared  obj/Debug/Adddays.o obj/Debug/Addmonths.o obj/Debug/Addyears.o obj/Debug/Cmpdate.o obj/Debug/Datefmt.o obj/Debug/Diffdays.o obj/Debug/Diffymd.o obj/Debug/Julian.o obj/Debug/Leap.o obj/Debug/Subdays.o obj/Debug/Submonths.o obj/Debug/Subyears.o obj/Debug/Valid.o obj/Debug/Weekday.o  -o bin/Debug/libdatemanip.so  -lfPIC
/usr/bin/ld: obj/Debug/Datefmt.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
obj/Debug/Datefmt.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

i also added a flag in compiler flags
 bujtist gives same error :-
Code

-------------- Build: Debug in datemanip (compiler: GNU GCC Compiler)---------------

g++ -shared  obj/Debug/Adddays.o obj/Debug/Addmonths.o obj/Debug/Addyears.o obj/Debug/Cmpdate.o obj/Debug/Datefmt.o obj/Debug/Diffdays.o obj/Debug/Diffymd.o obj/Debug/Julian.o obj/Debug/Leap.o obj/Debug/Subdays.o obj/Debug/Submonths.o obj/Debug/Subyears.o obj/Debug/Valid.o obj/Debug/Weekday.o  -o bin/Debug/libdatemanip.so -fPIC  -lfPIC
/usr/bin/ld: obj/Debug/Datefmt.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
obj/Debug/Datefmt.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

« Last Edit: January 15, 2019, 03:51:29 pm by Rahul »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1557
Re: -fPIC flag is not showing in list
« Reply #7 on: January 15, 2019, 04:16:55 pm »
Those logs are from the linker, they are asking you to compile with -fPIC. You must do a clean build after changing compiler options.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: -fPIC flag is not showing in list
« Reply #8 on: January 15, 2019, 06:47:29 pm »
Those logs are from the linker, they are asking you to compile with -fPIC. You must do a clean build after changing compiler options.
You can do this with the menu: Build->Rebuild or Build->Clean and Build->Build

Offline Rahul

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: -fPIC flag is not showing in list
« Reply #9 on: January 16, 2019, 12:26:21 pm »
i did as you said. and found  it is working but not showing in intellisense. And Also not in  #include directive  as : should be "#inlcude "main.h".