Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

[Help needed] Setting Visual Studio Linker Flags in C++ Code::Blocks Project

(1/2) > >>

Grashek:
Hello C::B Community,

I have been using C::B for quite a while now.
Recently I have been asked to recompile my projects with the following linker flags (security compliance reasons):

/DYNAMICBASE
/NXCOMPAT
/GS
/SAFESEH

I have been using the GNU GCC Compiler using -std=c++11
I attached my compiler settings as PNG picture.


Now my question is:
How can I recompile my projects using these linker settings?

Could you guide me how to do it within Code::Blocks or within terminal please.


Thank you

~~Grashek


P.S.: I ran multiple google search queuries for hours and did not find any solution to my problem.

sodev:
These are MSVC linker flags, they can't be used for GCC (directly). Not sure if you should quickly switch to MSVC or tell your compliance department that you are using GCC ;D.

Anyway for the first two flags there are equivalent GCC switches, these are -Wl,--dynamicbase and -Wl,--nxcompat, you set these as Other linker options in CodeBlocks, either in the project specific settings or global compiler settings. The other two are more tricky. According to the docs /SAFESEH only applies to x86 builds and afaik GCC on windows supports SEH only in x86_64 builds so this flag does not apply to you. For the /GS flag you have to search if GCC supports something similar and how to enable it.

Grashek:
Thank you @sodev These were good pointers. May I ask a follow-up question please.

I attached another image showing the following compiler error now:


--- Quote ---ld.exe||cannot find dynamicbase: No such file or directory|
ld.exe||cannot find nxcompat: No such file or directory|
||error: ld returned 1 exit status|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 3 second(s)) ===|
--- End quote ---

My understanding is, that I need to be able to tell Code::Blocks where the library is,
that allows to linker to understand what it should be doing.

Now where can I get these libraries?
Where can I download them?

Grashek:
With the linker flag " -L " I got rid of the error in regards to DYNAMICBASE. (ref: https://sourceware.org/binutils/docs/ld/Options.html)

However I still get the error for nxcompat:

--- Quote ---ld.exe||cannot find nxcompat: No such file or directory|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
--- End quote ---

stahta01:
Those are linker options! They are not linker libraries.

You likely need to enter them in the extra or other linker settings.

Tim S.

Navigation

[0] Message Index

[#] Next page

Go to full version