Reputation: 87
I am using other people's makefile and get troubles when trying to compile a 'static' version of the exe
I have printed out the makefile's rules and the error is like this:
g++ Main.or System.or Options.or -Wall -lz --static -o main
/usr/bin/ld: cannot find -lz
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
If I do not include the '--static' option in the above command, it works fine.
The makefile also have rules to generate the static lib:
ar -rcsv lib_release.a Main.or System.or Options.or
r - Main.or
r - System.or
r - Options.or
Making Soft Link: lib_release.a -> lib.a
ln -sf lib_release.a lib.a
Upvotes: 1
Views: 1253
Reputation: 61590
The -static
linkage option instructs the linker to ignore all shared
libaries (libname.so
) that could resolve the -lname
linkage options (both explicit
and default) and accept only static libraries (libname.a
). You have shared libraries installed on
your system that satisfy -lz
, -lstdc++
, -lm
and -lc
but no static ones.
For your linkage to work as it stands you must install the static libraries:
libz.a
(Compression library)libstdc++.a
(The standard C++ library)libm.a
(The math library)libc.a
The standard C libraryby the method that is appropriate to your distro.
Upvotes: 1