C++ Linker error "undefined reference to `mg_websocket_write'"

230 views
Skip to first unread message

Shane Maloney

unread,
Dec 5, 2013, 8:40:22 AM12/5/13
to mongoos...@googlegroups.com
Firstly if this really simple/obvious I apologies in advance. When ever I try to compile the websocket example I get a linker error undefined reference to `mg_websocket_write'. The simple example works fine, I have tried both 4.1 tag and master releases with the same problem. I tried switching the order in the linker command to no avail, new to C++ dev so not even sure if it matters.

Below are my system details and output from make:

System details: Ubuntu 12.04 LTS amd64, g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, Eclipse C/C++ : 8.1.2.201302132326

make all
Building file: ../src/SimpleHTTPserver.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/SimpleHTTPserver.d" -MT"src/SimpleHTTPserver.d" -o "src/SimpleHTTPserver.o" "../src/SimpleHTTPserver.cpp"
Finished building: ../src/SimpleHTTPserver.cpp
 
Building file: ../src/mongoose.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/mongoose.d" -MT"src/mongoose.d" -o "src/mongoose.o" "../src/mongoose.cpp"
Finished building: ../src/mongoose.cpp
 
Building target: SimpleHTTPServer
Invoking: GCC C++ Linker
g++ -L"/home/shane/MobiPV/workspace/SimpleHTTPServer/src" -o "SimpleHTTPServer"  ./src/SimpleHTTPserver.o ./src/mongoose.o   -ldl -lpthread
./src/SimpleHTTPserver.o: In function `websocket_ready_handler':
/home/shane/MobiPV/workspace/SimpleHTTPServer/Debug/../src/SimpleHTTPserver.cpp:15: undefined reference to `mg_websocket_write'
./src/SimpleHTTPserver.o: In function `websocket_data_handler':
/home/shane/MobiPV/workspace/SimpleHTTPServer/Debug/../src/SimpleHTTPserver.cpp:25: undefined reference to `mg_websocket_write'
collect2: ld returned 1 exit status
make: *** [SimpleHTTPServer] Error 1

Sergey Lyubka

unread,
Dec 5, 2013, 8:45:37 AM12/5/13
to mongoose-users
Add -DUSE_WEBSOCKET to your compilation flags


--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.

Message has been deleted

Shane Maloney

unread,
Dec 5, 2013, 9:36:15 AM12/5/13
to mongoos...@googlegroups.com
Thanks, I should have figured that out myself, hangs head in shame.

Sergey Lyubka

unread,
Dec 5, 2013, 9:37:11 AM12/5/13
to mongoose-users
Actually, my fault, that should be in the documentation.
Will add, thanks for reporting!
Reply all
Reply to author
Forward
0 new messages