Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static link with libmicrohttpd issue #2

Open
devsunny opened this issue Dec 22, 2015 · 1 comment
Open

static link with libmicrohttpd issue #2

devsunny opened this issue Dec 22, 2015 · 1 comment

Comments

@devsunny
Copy link

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 toMHD_lookup_connection_value'
test.c:31: undefined reference to MHD_create_response_from_buffer' test.c:39: undefined reference toMHD_queue_response'
test.c:41: undefined reference to MHD_queue_response' test.c:43: undefined reference toMHD_destroy_response'
/tmp/ccaFAFRr.o: In function main': test.c:62: undefined reference toMHD_start_daemon'
test.c:69: undefined reference to `MHD_stop_daemon'

@savethebeesandseeds
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants