Srt: test-c-server example. undefined reference to `srt_startup', `srt_create_socket' and other

Created on 9 Sep 2019  路  16Comments  路  Source: Haivision/srt

Hello, can you help me please? When I am compiling test-c-server, from examples, I am getting an error:
gcc fork2.c -o fork
/tmp/ccqhZ97y.o: In functionmain': fork2.c:(.text+0x76): undefined reference to srt_startup'
fork2.c:(.text+0x8c): undefined reference tosrt_create_socket' fork2.c:(.text+0xa4): undefined reference to srt_getlasterror_str'
fork2.c:(.text+0x167): undefined reference tosrt_setsockflag' fork2.c:(.text+0x18f): undefined reference to srt_bind' fork2.c:(.text+0x1a7): undefined reference to srt_getlasterror_str'
fork2.c:(.text+0x1ed): undefined reference tosrt_listen'
fork2.c:(.text+0x205): undefined reference tosrt_getlasterror_str' fork2.c:(.text+0x261): undefined reference to srt_accept'
fork2.c:(.text+0x2ab): undefined reference tosrt_recvmsg' fork2.c:(.text+0x2c3): undefined reference to srt_getlasterror_str'
fork2.c:(.text+0x331): undefined reference tosrt_close' fork2.c:(.text+0x349): undefined reference to srt_getlasterror_str'
fork2.c:(.text+0x37f): undefined reference tosrt_cleanup'`
collect2: error: ld returned 1 exit status

So what I did. I added a path to #include "srt/srt.h", because without it I got an fatal error. Also I tried to use <> insteed "", full path, nothing works...
I installed srt on ubuntu 18 via git clone and make.
sudo apt-get install tclsh pkg-config cmake libssl-dev build-essential
git clone https://github.com/Haivision/srt
./configure
make
sudo make install
Thank you in advance

Question

All 16 comments

This command you showed doesn't look like compiling test-c-server.

@UnderOverCovered
The best way to build examples is to use cmake.
cmake ./ -DENABLE_EXAMPLES=ON
cmake --build ./
Or similar with configure:
./configure --enable-examples
make

And the message "undefined reference to srt_startup',srt_create_socket' and other" means that SRT library is not linked to the example application.

This command you showed doesn't look like compiling test-c-server

I copied test-c-server code in my own file, for test. I planned to modify it for my own goals. Sorry for confusion, fork2.c file is a full copy of test-c-server with include correction (#include"srt/srt.h")

@maxlovic thank you, I will try it

If so, then please make an installation package of SRT library first, then install it, and then use pkg-config to obtain appropriate cflags and libs for apps that depend on it.

Kinda

gcc fork2.c -o fork $(pkg-config --cflags --libs srt)

@ethouris thank you, i'll try

@ethouris Maybe I missed something, gcc made compilation successful, but when I am running code, it returns an error: ./fork: error while loading shared libraries: libsrt.so.1: cannot open shared object file: No such file or directory

Also, I do not touched the code (#include "srt" like in test-c-server example)

Well, did you install the library? If so, do you have the path to your library in the ld.so configuration or LD_LIBRARY_PATH variable?

O, yes I got it. -- Install configuration: "Release" -- Up-to-date: /usr/local/lib/libsrt.so.1.3.4

Ok, I will add it by LD_LIBRARY_PATH

About ld.so... I don't know where it is, sorry

Ok, I have done this:
export LD_LIBRARY_PATH="/usr/local/lib/libsrt.so.1.3.4"

and this:
export LD_LIBRARY_PATH="/usr/local/lib/libsrt.so.1"
It doesn't helps

Response to this largely exceeds the scope of the SRT library or associated applications.

Excuse me, maybe it is language barrier, so can't understand correctly. So, you mean, that SRT can't work with custom c codes?

Use export LD_LIBRARY_PATH="/usr/local/lib/

@maxlovic Thank you! That works! @ethouris Thank you too! Now we can close that issue. Good luck, SRT is the best!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newbeewan picture newbeewan  路  6Comments

amukhsimov picture amukhsimov  路  3Comments

oviano picture oviano  路  6Comments

Svyatk0 picture Svyatk0  路  5Comments

boxerab picture boxerab  路  5Comments