Questions tagged [ldflags]

LDFLAGS is a variable used in Makefiles. Specifically its value is added to linker command lines when the linker is invoked by an implicit rule.

LDFLAGS is a variable used in Makefiles. Specifically its value is added to linker command lines when the linker is invoked by an implicit rule.

64 questions
90
votes
4 answers

How to use LDFLAGS in makefile

I am new to Linux OS. I am trying to compile a .c file using a makefile. The math library has to be linked. My makefile looks like this: CC=gcc CFLAGS=-Wall -lm all:client .PHONY: clean clean: rm *~ *.o client When I run make, I get the…
user1802785
  • 1,013
  • 1
  • 8
  • 8
76
votes
5 answers

How to set the LDFLAGS in CMakeLists.txt?

I set the CFLAGS in CMake by CMAKE_C_FLAGS. Is something like this to set LDFLAGS?
hich9n
  • 1,578
  • 2
  • 15
  • 32
20
votes
1 answer

How to specify RPATH in a makefile?

I'm trying to specify rpath in my binary. My makefile looks like this- CC=gcc CFLAGS=-Wall LDFLAGS= -rpath='../libs/' main: main.c gcc -o main main.c clean: rm -f main main.o But when I query rpath using command readelf -a ./main |…
user837208
  • 2,487
  • 7
  • 37
  • 54
11
votes
2 answers

How to use a relative path for LDFLAGS in golang

I am trying to build a golang program which uses a static lib (.a file) the directory struct for my project as below └─testserver ├─bin ├─pkg └─src ├─logging └─testserver ├─libtest.a └─test.go the…
catric mia
  • 1,137
  • 2
  • 9
  • 8
7
votes
2 answers

what's the difference between DLDFLAGS and LDFLAGS

A quick question. I found both "DLDFLAGS" and "LDFLAGS" in a sample Makefile. The compiler used is gcc. It looks like they are both used for linkers. I'm wondering what's the difference between them.
user1101096
  • 699
  • 2
  • 6
  • 7
5
votes
0 answers

Why `build` with ldflag `-X` works only when the filename is specified?

I have the file playground.go: package main import ( "fmt" ) var GitCommit string func main() { fmt.Printf("Hello world, version: %s\n", GitCommit) } why the behavior of the build ldflag -X depends on specifying the source filename?: # CASE…
Marcus
  • 5,104
  • 2
  • 28
  • 24
5
votes
2 answers

Yocto fido ->morty update dnsmasq NO GNU_HASH

So, I was given the task to upgrade our yocto based system from fido to morty. I have very little experience with yocto, I have been struggling with it and trying to understand it for almost a week now. I have managed to fix some issues, but now I'm…
Ou Tsei
  • 470
  • 7
  • 24
5
votes
2 answers

What is the signification of LDFLAGS

I'm trying to compile AODV for ARM linux. I use a SabreLite as a board with kernel version 3.0.35_4.1.0. It's worth mention that i'm using openembedded to create my Linux Distribution for my board. The AODV source code…
scof007
  • 415
  • 2
  • 9
  • 15
4
votes
1 answer

How do I pass -ldflags to exec.Command with multiple arguments

I have a fairly simple go file which builds several internal tools written in go. It worked well until I decided to add -ldflags to my build command. The following is the snippet which formats the go build command. var cmd *exec.Cmd file :=…
Uberswe
  • 1,038
  • 2
  • 16
  • 36
4
votes
1 answer

Correctly building local python3, with bz2 support

I am trying to build a local version of python3 (specifically python3.7, but same issue with 3.6.6), but am running into problems with linking to some C libraries and/or headers (at least that is what I think the problem is). I am able to build…
djmac
  • 827
  • 5
  • 11
  • 27
4
votes
1 answer

How to set LDFLAGS for a "noinst" kind of library with Automake?

Suppose I have developed libfoo.a as an intermediate step in my compilation process. Here is the line for it in Makefile.am: noinst_LIBRARIES = libfoo.a This lib depends on other libs. To prevent me from getting undefined reference errors, I need…
ivarec
  • 2,542
  • 2
  • 34
  • 57
3
votes
1 answer

Set Go variable with ldflags conflicts with vendor folder

I'm currently developing a small Go app and I want to set a specific variable (like Version, GitCommit, BuildID...etc.) at build or runtime (with go build or go run) by using the -ldflags option. Because in my company we have several projects with…
Lebowski
  • 588
  • 7
  • 21
3
votes
3 answers

invalid flag #cgo LDFLAGS break build with go lang

I'm new to the go-lang. I want to use go command to build a binary named cryptogen (hyperledger/fabric tool). I download the source code from github and type the following command accroding to readme: CGO_CFLAGS=" "…
louis
  • 63
  • 1
  • 4
3
votes
2 answers

Why is gcc failing with 'unrecognized command line option "-L/lusr/opt/mpfr-2.4.2/lib"'?

My sysadmin recently installed a new version of GCC, in /lusr/opt/gcc-4.4.3. I tested it as follows: mike@canon:~$ cat test.c int main(){ return 0; } mike@canon:~$ gcc test.c /lusr/opt/gcc-4.4.3/libexec/gcc/i686-pc-linux-gnu/4.4.3/cc1: error while…
Mike
  • 23,892
  • 18
  • 70
  • 90
3
votes
1 answer

Get C/CXX FLAGS set by commands add_definitions() and add_compile_options()

In my CMakeLists.txt, global C and CXX flags are set using commands add_definitions() and add_compile_options. Many attempts to retrieve the C/CXX flags: ${CMAKE_C_FLAGS} and ${CMAKE_CXX_FLAGS} are empty ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}} is the…
oHo
  • 51,447
  • 27
  • 165
  • 200
1
2 3 4 5