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)
Have you looked if the option is in the other compiler options tab?
thanks for your reply, yes i saw in project-build-opotion->other-compiler-option there is nothing
This is text field where you can enter anything you like.
but question is how to find "-fPIC" flag in codebloks compiler settings. hare is screenshot of compiler flags option :
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.
i did it as you said buy it gives same error : -
------------ 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 :-
-------------- 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))
Those logs are from the linker, they are asking you to compile with -fPIC. You must do a clean build after changing compiler options.
Quote from: 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.
You can do this with the menu: Build->Rebuild or Build->Clean and Build->Build
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".