You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to compile and static link with libmicrohttpd. with the following command, I am getting "undefined reference to" error, If I compile without -static flag, it works perfectly. did I do anything wrong? the test.c is just a copy of one of example, I add #include stdlib.h, stdio and string.h.
Strange behavior, same thing happen to me, here is how I solve it.
undefined reference, frequently refers to a misplacement of arguments in the gcc command.
Same error as you happen to me while having the arguments as: g++ -Wall -static -lmicrohttpd -I ./lib/include/ ./main.cpp -o ./build/main.o
Solve by changing the order to: g++ -Wall -static -I ./lib/include/ ./main.cpp -lmicrohttpd -o ./build/main.o
Hi Richard,
I am trying to compile and static link with libmicrohttpd. with the following command, I am getting "undefined reference to" error, If I compile without -static flag, it works perfectly. did I do anything wrong? the test.c is just a copy of one of example, I add #include stdlib.h, stdio and string.h.
gcc -static -DHAVE_CONFIG_H -ggdb -std=gnu99 -o test -I/opt/bigdatalab/usrlib/libmicrohttpd/include/ -L /opt/bigdatalab/usrlib/libmicrohttpd/lib -lmicrohttpd test.c -lrt
/tmp/ccaFAFRr.o: In function
answer_to_connection': test.c:27: undefined reference to
MHD_lookup_connection_value'test.c:31: undefined reference to
MHD_create_response_from_buffer' test.c:39: undefined reference to
MHD_queue_response'test.c:41: undefined reference to
MHD_queue_response' test.c:43: undefined reference to
MHD_destroy_response'/tmp/ccaFAFRr.o: In function
main': test.c:62: undefined reference to
MHD_start_daemon'test.c:69: undefined reference to `MHD_stop_daemon'
The text was updated successfully, but these errors were encountered: