Linker flags are arguments passed to a linker to specify options, for instance to link the code with a certain library, etc
Questions tagged [linker-flags]
125 questions
25
votes
3 answers
Appending to CMAKE_C_FLAGS
I'm using CMake for a project that comes in two versions, one of which requires -lglapi and the other does not.
So far the lines we used look like that:
SET(CMAKE_C_FLAGS "-O3 -xSSE3 -restrict -lpthread -lX11 -ldrm")
SET(CMAKE_CXX_FLAGS "-O3…

TobiSF
- 253
- 1
- 3
- 5
18
votes
4 answers
Xcode how to exclude FOLDERS from compilation?
I saw this and answers in stackO, but didn't find how to exclude folders.
I have 3 folders with a lot of .h , .m and .mm and i need to exclude them temporary, but not to remove references. How can i do that?

Nike Kov
- 12,630
- 8
- 75
- 122
15
votes
1 answer
Other Linker Flags missing in Xcode Build Settings
As the title reads, I go into my Build Settings for my app, and search for "Other Linker Flags", nothing is returner. If I even search simply "Other", there is no "Other Linker Flags" section. I've seen other instances of this happening online, but…

B.A.S. Apps
- 735
- 1
- 5
- 8
14
votes
3 answers
What are gcc linker map files used for?
What are the ".map" files generated by gcc/g++ linker option "-Map" used for ?
And how to read them ?

Monku
- 2,440
- 4
- 33
- 57
13
votes
1 answer
Setting LD_LIBRARY_PATH from inside R
I have installed an R package but, in order to load it via library, the LD_LIBRARY_PATH needs to be set to the path where one of the libraries, called libhts.so.2 is located. The loading only works when editing the LD_LIBRARY_PATH before going into…

kgui
- 4,015
- 5
- 41
- 53
13
votes
2 answers
How does the -u option for ld work and when is it useful?
I'm copy-pasting a section from the man of ld :-
-u symbol
--undefined=symbol
Force symbol to be entered in the output file as an undefined symbol. Doing this
may,for example, trigger linking of additional modules from standard libraries.
`-u'…

owagh
- 3,428
- 2
- 31
- 53
13
votes
1 answer
How to make CMake append linker flags instead of prepending them?
CMake seems to prepend linker flags at the front of a GCC compilation command, instead of appending it at the end. How to make CMake append linker flags?
Here is a simple example to reproduce the problem.
Consider this C++ code that uses…

Ashwin Nanjappa
- 76,204
- 83
- 211
- 292
11
votes
1 answer
How to wrap functions with the `--wrap` option correctly?
The man page of gcc 6.3 says:
--wrap=symbol
Use a wrapper function for symbol. Any undefined reference to
symbol will be resolved to "__wrap_symbol". Any undefined
reference to "__real_symbol" will be resolved to…

eDeviser
- 1,605
- 2
- 17
- 44
10
votes
1 answer
Difference between Build Phases -> Link Binary with Libraries or Build Settings -> Linker Flags
What's the difference between Build Phases -> Link Binary with Libraries or Build Settings -> Linker Flags?
The former does not seem to allow you to specify between Debug vs Release, and the frameworks specified within it also don't seem to match up…

Boon
- 40,656
- 60
- 209
- 315
10
votes
2 answers
CMAKE for /DEF and /NODEFAULTLIB
How do I add linker-flags "DEF" and "NODEFAULTLIB" to vs2012 project via CMAKE?

etwas77
- 514
- 1
- 6
- 17
9
votes
2 answers
How to link the library with "-force_load" in Xcode?
My other libraries not allow me to set -ObjC or all_load flags.
So I need to use -force_load to link my library.
I have "GoogleOpenSource.framework" & "GooglePlus.framework" under my project, so how can I map those correctly to work.
I have set…

RJ168
- 1,006
- 2
- 12
- 22
8
votes
2 answers
Can you compile a shared object to prefer local symbols even if it's being loaded by a program compiled with -rdynamic?
I am building a shared library in C that is dynamically loaded by a program that I do not have source access to. The target platform is a 64-bit Linux platform and we're using gcc to build. I was able to build a reproduction of the issue in ~100…

TheGeneral
- 165
- 1
- 7
8
votes
2 answers
Gcc hide visibility of symbols coming from included static library
I have:
a shared library, say libShared.so, which contains a class Bar, with a method int Bar::do(int d) const
a static library, say libStatic.a, which contains a class Foo, with a method int Foo::act(int a) const.
The code of Bar is something…

Mauro
- 113
- 1
- 5
7
votes
1 answer
CMake - How to avoid CMAKE_CXX_FLAGS in linker command-line
I'm having a problem with cmake / gcc / Linux.
No matter what I try, I cannot get rid of CMAKE_CXX_FLAGS on my linker line. CMake keeps passing them when invoking g++ in link mode.
I have -fopenmp in my CMAKE_CXX_FLAGS and it must not be present on…

Alexander
- 692
- 6
- 17
7
votes
0 answers
Rationale and intended use behind 'library-path', 'rpath', and 'rpath-link'
I noticed many people, including me, do not accurately know the rationale and intended use behind the linker's search paths: 'library-path', 'rpath', and 'rpath-link'. Could someody explain this to us?
Context
After all my reading I am inclined to…

Bart
- 179
- 1
- 9