Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Rahul on January 13, 2019, 01:58:30 pm

Title: -fPIC flag is not showing in list
Post by: Rahul 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 :
 (http://)(i don't know how to upload images) 
Title: Re: -fPIC flag is not showing in list
Post by: oBFusCATed on January 13, 2019, 02:07:25 pm
Have you looked if the option is in the other compiler options tab?
Title: Re: -fPIC flag is not showing in list
Post by: Rahul 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
Title: Re: -fPIC flag is not showing in list
Post by: oBFusCATed on January 14, 2019, 07:10:06 pm
This is text field where you can enter anything you like.
Title: Re: -fPIC flag is not showing in list
Post by: Rahul 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 :
Title: Re: -fPIC flag is not showing in list
Post by: BlueHazzard 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.
Title: Re: -fPIC flag is not showing in list
Post by: Rahul 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))
 

Title: Re: -fPIC flag is not showing in list
Post by: Miguel Gimenez 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.
Title: Re: -fPIC flag is not showing in list
Post by: BlueHazzard 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
Title: Re: -fPIC flag is not showing in list
Post by: Rahul 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".