CTI-Demo
# directory
cd /usr/src/freeswitch/libs/esl
# compile
gcc -o testclient testclient.c -pthread -lm -lesl -lcjson -Isrc/include
#
- compile
gcc -o testclient testclient.c -pthread -lm -lesl -L. -Isrc/include
https://freeswitch.org/confluence/display/FREESWITCH/Event+Socket+Library
https://blog.csdn.net/huoyin/article/details/39394189
Errors
- gcc -o testserver testserver.c -lpthread -lm -lesl -lcjson -Isrc/include
admin~: gcc -o testserver testserver.c -lpthread -lm -lesl -lcjson -Isrc/include
//usr/local/lib/libesl.so: undefined reference to `pthread_mutexattr_settype'
//usr/local/lib/libesl.so: undefined reference to `pthread_attr_setstacksize'
//usr/local/lib/libesl.so: undefined reference to `pthread_mutex_trylock'
//usr/local/lib/libesl.so: undefined reference to `pthread_create'
//usr/local/lib/libesl.so: undefined reference to `pthread_mutexattr_init'
//usr/local/lib/libesl.so: undefined reference to `pthread_mutexattr_destroy'
collect2: error: ld returned 1 exit status
# solution
-lpthread change to -pthread
- /usr/bin/ld: cannot find -lesl
# errors
gcc -o testserver testserver.c -lpthread -lm -lesl -lcjson -Isrc/include
/usr/bin/ld: cannot find -lesl
collect2: error: ld returned 1 exit status
# solution
gcc -fPIC -g -c -Wall esl.c -Isrc/include
gcc -fPIC -g -c -Wall esl_buffer.c -Isrc/include
gcc -fPIC -g -c -Wall esl_config.c -Isrc/include
gcc -fPIC -g -c -Wall esl_event.c -Isrc/include
gcc -fPIC -g -c -Wall esl_json.c -Isrc/include
gcc -fPIC -g -c -Wall esl_threadmutex.c -Isrc/include
gcc -shared -Wl,-soname,libesl.so.1 -o libesl.so.1.0.1 esl_buffer.o esl.o esl_config.o esl_event.o esl_json.o esl_threadmutex.o -lm
# [-lm must be at the end of the line]
cp -p /usr/src/freeswitch/libs/esl/src/libesl.so.1.0.1 /usr/local/lib
ln -s /usr/src/freeswitch/libs/esl/src/libesl.so.1.0.1 /usr/local /lib/libesl.so.1
ln -s /usr/src/freeswitch/libs/esl/src/libesl.so.1 /usr/local/lib/libesl.so
echco '/usr/local/lib' > /etc/ld.conf.d/libesl.conf
# run ldconfig
ldconfig
https://stackoverflow.com/questions/28205692/freeswitch-esl-cannot-find-lesl
- /usr/bin/ld: cannot find -lcjson
# error
/usr/bin/ld: cannot find -lcjson
collect2: error: ld returned 1 exit status
# solution
git clone https://github.com/DaveGamble/cJSON.git
cd cJSON/
make && make install
# run ldconfig
ldconfig
https://stackoverflow.com/questions/40857103/cjson-error-while-compiling-and-printing-file
https://www.jianshu.com/p/9aa57961b17b
Reference
https://blog.csdn.net/huoyin/article/details/39394189
https://blog.csdn.net/u011304970/article/details/54944723
来源:https://blog.csdn.net/IDreamsComeTrue/article/details/99290413