LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   gcc compile error (-lmysql: command not found) (http://www.linuxquestions.org/questions/programming-9/gcc-compile-error-lmysql-command-not-found-545561/)

xface66 04-12-2007 04:53 PM

gcc compile error (-lmysql: command not found)
 
hello everyone,

i have a program that uses pcap and mysql libraries.

i have a makefile;

Code:

all:
        LIBS=-L/usr/include/mysql -lmysqlclient -lpcap
        gcc -Wall -pedantic $(LIBS) -o main main.c

when i run make command it gives the error

Code:

LIBS=-L/usr/include/mysql -lmysqlclient -lpcap
/bin/sh: -lmysqlclient: command not found
make: *** [all] Error 127

but when i was using only mysql library ;

Code:

gcc -o main  -L/usr/include/mysql -lmysqlclient main.c
was working.

now how can i compile the source code that uses two libraries?

matthewg42 04-12-2007 05:40 PM

In Makefiles, inside rules tab-indented sections are interpreted like shell commands, and this can include a var=value prefix to a command.

Instead, move the assignment to the LIBS variable out of the rule:

Code:

LIBS = -L/usr/include/mysql -lmysqlclient -lpcap

all:
        gcc -Wall -pedantic $(LIBS) -o main main.c


xface66 04-13-2007 09:00 AM

thanks for your answer.;)


All times are GMT -5. The time now is 08:10 PM.