Hi! i am trying to compile/link a simple application that uses a library called OpenDBX. I have already compiled and installed that library. Now, i am trying to do a simple client of it.

The client (Prueba.c) is just like this:

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <odbx.h>

int main(void) {
	puts("Hello World!!");
	
		int err;
		odbx_t* handle;
	
		if( ( err = odbx_init( &handle, "mysql", "127.0.0.1", "" ) ) < 0 )
		{
		    fprintf( stderr, "odbx_init(): %s\n", odbx_error( handle, err ) );
		    return err;
		}
		
		return EXIT_SUCCESS;
}

When i try to compile that program (Prueba.c), i has this error:

cc -c -o Prueba.o Prueba.c
gcc -O2 -g -Wall -fmessage-length=0 -L/usr/local/lib -L/usr/local/lib/opendbx -L/usr/local/lib/pkgconfig -o Pruebas Prueba.o
Prueba.o: In function `main':
Prueba.c:(.text+0x3c): undefined reference to `odbx_init'
Prueba.c:(.text+0x57): undefined reference to `odbx_error'
collect2: ld returned 1 exit status
make: *** [Pruebas] Error 1


Those functions (odbx_error and odbx_init are both defined in odbx.h (the header of openDBX y need to include).

I have checked that openDBX libraries are okey. There are in /usr/local/lib , /usr/local/lib/opendbx and /usr/local/lib/pkgconfig.

My makefile is like this:

COMPILER = gcc

CCFLAGS =	-O2 -g -Wall -fmessage-length=0 

OBJS =		Prueba.o

LIBS = 

TARGET =	Pruebas

LDFLAGS = -L/usr/local/lib -L/usr/local/lib/opendbx -L/usr/local/lib/pkgconfig

$(TARGET):	$(OBJS)
	${COMPILER} ${CCFLAGS} $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS)

all:	$(TARGET)

clean:
	rm -f $(OBJS) $(TARGET)

So...can someone please tell what does this error mean ? i think that it doesn't found the library asosiated with de odbx.h, but i am not sure.

Very thanks

Mariano

As it's a compile error, I might suspect that gcc has not been made aware of the include path.

It's a linker error, not a compile error.

It's complaining about not being able to find the library, mostly because you didn't name it.
Eg. LIBS = odbx You've told the compiler where to look, but you didn't say what to look for.

hie every one..

this is the error i am getting while building my project


main.o: In function `turn':
main.c:(.text+0x38): undefined reference to " function "


my file is getting compiled but the linker is not establishing to form a executable file..

and i have included my libraries in the makefile also


please help me......its very urgent


included libraries in makefile are

LIBKOREBOT := /home/vinodh/development_k2_v1.0/libkorebot-1.11-kb1/build-korebot-2.6

INCS_ADD := -I $(LIBKOREBOT)/include/korebot

LIBS_ADD := -L $(LIBKOREBOT)/lib


and the header file i am using is located in ...//.../include/korebot

and the header file contains again some more header files in it

so can u tell me whats the problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.