Opened 2 months ago

Last modified 8 weeks ago

#2607 new defect

How to link custom library to nginx

Reported by: gayathri.shirahatti@… Owned by:
Priority: minor Milestone:
Component: documentation Version: 1.25.x
Keywords: Cc:
uname -a:
nginx -V: 1.15.8.3

Description

I am using openresty package for my webserver needs, where in trying to link custom library (xyz.so) to nginx, facing linker error like undefined reference to xyz.so, i tried using --add-module option, which failed. --with-ld-opt also i couldnot add library. Can you please help me on this

Change History (10)

comment:1 by Roman Arutyunyan, 2 months ago

Normally a well-written nginx module should automatically link the libraries it needs via its config file. If you still need to link a library directly, use --with-ld-opt= while configuring nginx.

comment:2 by gayathri.shirahatti@…, 2 months ago

i tried doing this by --with-ld-opt="-ldl xyz.so" , but i am getting error saying invalid value in --with-ld-opt. Can you please help, if there is something missing here.

comment:3 by gayathri.shirahatti@…, 2 months ago

--with-ld-opt= "-L<path where .so present>" -> this has been added
where do i mention my xyz.so file to link ?

comment:4 by Roman Arutyunyan, 2 months ago

--with-ld-opt="path/to/libxyz.so" or --with-ld-opt="-Lpath/to -lxyz" should work

comment:5 by gayathri.shirahatti@…, 2 months ago

tried both the options, --with-ld-opt="-Lpath/to -lxyz"
getting an error: the invalid value in --with-ld-opt

comment:6 by Roman Arutyunyan, 2 months ago

This can mean that the file is missing.
objs/autoconf.err may have more information.

comment:7 by gayathri.shirahatti@…, 2 months ago

i have verified file path , file is present in this path..
--with-ld-opt="-Lpath/to -lxyz -Lpath/to -labc" both the library exist in the path provided in ld opts path.

comment:8 by gayathri.shirahatti@…, 2 months ago

Yes this worked for me, but it is internally finding other libraries , even though libraries in the same path, build is expecting me to specify libraries one by one, is there a way where i can say "find all dependent libraries under this path" ?

comment:9 by gayathri.shirahatti@…, 8 weeks ago

Thanks a lot Roman, this helped me lot. We can close this case.

comment:10 by gayathri.shirahatti@…, 8 weeks ago

@Roman Arutyunyan
--with-ld-opt="-Wl,-rpath, -L/path1/lib -Wl,-rpath, -L/path2/lib -lpath1_abc.so -l path2_abc.so -lpath2_xyz.so -lpath1_xyz.so" \

This builds and links libraries from 2 different paths, but when i launch nginx binary it throws an error: error while loading shared libraries: path2_abc.so , cannot open shared object file: No such file or directory.

Can you please help me on these querry, which will help me move forward. Thanks in advance

Note: See TracTickets for help on using tickets.