Dear friends, I have a question: When adding a custom module in kamailio, I referenced a
third-party library. There was no problem with compilation, but when I ran it, it reported
that the third-party library could not be found. What is the reason?
The current Makefile is as follows:
```
# WARNING: do not run this directly, it should be run by the main Makefile
include ../../Makefile.defs
auto_gen=
NAME=rocketmq.so
THIRDPARTY=/mnt/vdd/kqbi2/3rdparty
ROCKETMQ_ROOT_PATH=${THIRDPARTY}/rocketmq
CXX?=g++
LD?=g++
LIBS+=-L$(LOCALBASE)/lib -L$(ROCKETMQ_ROOT_PATH)/lib/linux/x64 crocketmq.o -lstdc++
-lrocketmq
DEFS+=-I$(LOCALBASE)/include -I${ROCKETMQ_ROOT_PATH}/include
CXXFLAGS=$(CFLAGS:-Wno-deprecated option=)
CXXFLAGS+=-Wno-write-strings -Wno-deprecated -Wno-unused-function -Wno-sign-compare
-Wno-strict-aliasing
include ../../Makefile.modules
crocketmq.o: crocketmq.cpp crocketmq.h
@echo "Compiling $<"
$(CXX) -std=c++11 $(CXXFLAGS) $(CFLAGS) $(C_DEFS) $(DEFS) -c $< -o $@
rocketmq.so: crocketmq.o
modclean:
-@rm -f crocketmq.o crocketmq.d rocketmq_mod.o rocketmq_mod.d
clean clean-modules: modclean
proper realclean distclean maintainer-clean: modclean
```
There is no problem in compiling, but when running, the third-party librocketmq.so library
cannot be found, and various export LD_LIBRARY_LIBRARY also does not work.
```
0(13229) DEBUG: <core> [core/cfg.y:2053]: yyparse(): loading module rocketmq.so
0(13229) DEBUG: <core> [core/sr_module.c:516]: ksr_locate_module(): found module to
load <lib64/kamailio/modules/rocketmq.so>
0(13229) DEBUG: <core> [core/sr_module.c:573]: ksr_load_module(): trying to load
<lib64/kamailio/modules/rocketmq.so>
0(13229) ERROR: <core> [core/sr_module.c:591]: ksr_load_module(): could not open
module <lib64/kamailio/modules/rocketmq.so>: librocketmq.so: cannot open shared
object file: No such file or directory
0(13229) CRITICAL: <core> [core/cfg.y:3900]: yyerror_at(): parse error in config
file /mnt/vdd/kqbi2/install/kamailio/etc/kamailio/kamailio.cfg, line 380, column 12-24:
failed to load module
```
Show replies by date
LIBS This line can be modified LIBS+=-L$(LOCALBASE)/lib
-Wl,-rpath=$(ROCKETMQ_ROOT_PATH)/lib/linux/x64 crocketmq.o -lstdc++ -lrocketmq
This is actually okay
-LStill need to add
LIBS+=-L$(LOCALBASE)/lib -L$(ROCKETMQ_ROOT_PATH)/lib/linux/x64
-Wl,-rpath=$(ROCKETMQ_ROOT_PATH)/lib/linux/x64 crocketmq.o -lstdc++ -lrocketmq