[Ur] -static not linking in some libraries

Daniel Patterson dbp at dbpmail.net
Mon Mar 18 19:23:36 EDT 2013


Hi Adam,

The gcc command that urweb used was:

gcc -Werror  -pthread   /usr/local/lib/liburweb_cgi.a
/usr/local/lib/liburweb.a /tmp/webapp.o -lm -lcrypto -lssl  -o
/path/to/binary.exe -g


And what I needed to get it to be linked statically is:

 gcc -static -Werror  -pthread   /usr/local/lib/liburweb_cgi.a
/usr/local/lib/liburweb.a /tmp/webapp.o -lm -lcrypto -lssl  -ldl -lz
-o /path/to/binary.exe -g

The difference being the -static flag and having to explicitly include
-ldl and -lz (which are dependencies of libcrypto or libssl).

Now I get a happy binary:

$ ldd binary.exe
not a dynamic executable

Thanks!
Daniel

On Mon, Mar 18, 2013 at 4:52 PM, Adam Chlipala <adamc at csail.mit.edu> wrote:
> On 03/18/2013 01:47 PM, Daniel Patterson wrote:
>>
>> I'm trying to put a cgi application on a shared host, and am getting
>> shared library errors - particularly libcrypto. The server has
>> libcrypto, but a different version than my development machine.
>>
>> Is there a way to _really_ link things statically? ie, include
>> everything that it needs, so I can just drop the binary on hosts and
>> have it work as long as they are the same platform/architecture?
>>
>
>
> I've been a bit perplexed by GCC linking in the past; this isn't the first
> time the issue has come up.
>
> Could you perhaps run 'urweb' with the '-debug' flag, look at the linker
> line that is printed, and let me know which changes are called for?  Thanks!
>
>
> _______________________________________________
> Ur mailing list
> Ur at impredicative.com
> http://www.impredicative.com/cgi-bin/mailman/listinfo/ur



More information about the Ur mailing list