I am trying to connect to rabbitmq in c and it is failing every single time. Here is how I did it.
Downloaded rabbitmq-c
Installed it (make && make install
) just to make sure dependencies are satisfied.
Modified connection variables in amqp_sendstring.c
Rebuilt using make
, ran ./amqp_sendstring
and it worked
Then I started creating my own files and compiling them through gcc using:
gcc -lrabbitmq -o j_test test.c
Ironically it fails to link against librabbitmq with the errors below:
/tmp/cc63IlXq.o: In function `main':
test.c:(.text+0xa): undefined reference to `amqp_new_connection'
test.c:(.text+0x1a): undefined reference to `amqp_destroy_connection'
collect2: ld returned 1 exit status
I removed everything starting with ampq_*. Voila! It was successfully built. That's to me an indicator that gcc is able to find the headers but not the lib.
Here is test.c source code:
#include <amqp.h>
#include <amqp_framing.h>
int main(int argc, char const * const *argv) {
amqp_connection_state_t conn;
conn = amqp_new_connection();
amqp_destroy_connection(conn);
return 0;
}
Would someone please point me to the right direction?
Edit: I forgot to mention that I am on an ubuntu box (12.04). Think it is implicitly implied in the statements above though.