imx8: compile time error while cross compiling libwebsocket client/server sample codebase

Showing results for 
Search instead for 
Did you mean: 

imx8: compile time error while cross compiling libwebsocket client/server sample codebase

Contributor III


i am cross compiling libwebsocket based client/server codebase for i.MX8MQ target. Code successfully compiled for ubuntu desktop environment & could run also but the same not compiling for i.MX8 target. Facing undefined reference errors, attaching the Makefile(in txt format, as it was not accepting .make) for reference. Here are the logs:

aarch64-agl-linux-gcc -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/agl-sdk/12.90.0+snapshot-aarch64/sysroots/aarch64-agl-linux -g -Wall -Werror -o client libwebsocket_client.o -I/usr/include/ -L /usr/lib -lpthread -lwebsockets
/opt/agl-sdk/12.90.0+snapshot-aarch64/sysroots/x86_64-aglsdk-linux/usr/libexec/aarch64-agl-linux/gcc/aarch64-agl-linux/9.3.0/real-ld: warning: library search path "/usr/lib" is unsafe for cross-compilation
/opt/agl-sdk/12.90.0+snapshot-aarch64/sysroots/x86_64-aglsdk-linux/usr/libexec/aarch64-agl-linux/gcc/aarch64-agl-linux/9.3.0/real-ld: libwebsocket_client.o: in function `main':
libwebsocket_client.c:(.text+0x3a4): undefined reference to `lws_get_internal_extensions'
/opt/agl-sdk/12.90.0+snapshot-aarch64/sysroots/x86_64-aglsdk-linux/usr/libexec/aarch64-agl-linux/gcc/aarch64-agl-linux/9.3.0/real-ld: libwebsocket_client.c:(.text+0x460): undefined reference to `lws_client_connect'
collect2: error: ld returned 1 exit status
Makefile:15: recipe for target 'client' failed
make: *** [client] Error 1

Any suggestion on this issue will be highly appreciated.


Labels (1)
0 Kudos
2 Replies

NXP TechSupport
NXP TechSupport

Hello vsuneja63,

Hello! I just tried it out using the latest from the warmcat/libwebsockets project and it links fine for me. The functions you mentioned do exist in the latest libwebsockets library. The only difference I noticed was that lws_client_connect is now marked as deprecated so I've replaced it with lws_client_connect_via_info.

Try running pkg-config libwebsockets --libs --cflags and see what you get. I get -I/usr/local/include -L/usr/local/lib -lwebsockets. Maybe pkg-config isn't pointing to your libwebsockets install?

The Makefile is pretty simple, if you've installed libwebsockets somewhere pkg-config doesn't know about you can compile the client / server with:
gcc -I/usr/local/include -L/usr/local/lib -lwebsockets client.c -o client
gcc -I/usr/local/include -L/usr/local/lib -lwebsockets server.c -o server
...replacing the /usr/local paths with your libwebsockets install paths.

This is general Linux Question and not for the MX8M, i guess you can select one of the question from stachoverflow.



0 Kudos

Contributor III



I tried compiling using "pkg-config libwebsockets --libs --cflags" but same issue. Not sure if any other dependency is missing.

Thanks & Regards,

Vipul Kumar

0 Kudos