Reputation: 8737
I run the following command to link the different files in my project.
/opt/gcc-4.7-cilkplus/bin/gcc -g -Wall -l /opt/gcc-4.7-cilkplus/lib64/ -o exec main.o \
mysql-client.o databaseConnection-common.o murmurhash3.o bloom-filter.o
`mysql_config --cflags --libs\` -lcilkrts
Note the option -l /opt/gcc-4.7-cilkplus/lib64/
When I run this command I get this error:
/usr/bin/ld: cannot find -l/opt/gcc-4.7-cilkplus/lib64/
but this directory is present in my system. Can anyone please tell the mistake.
Upvotes: 1
Views: 210
Reputation: 47493
-Lpath/to/lib -lname
is the syntax (without spaces after -L
and -l
). If linking to a static library for example, this means that link should be done with path/to/lib/libname.a
Also, note that the order of arguments to linker is important. That is, if object A
uses library B
, B
should be written after it. If B
itself uses C
, then first A
should be mentioned, then B
and then C
.
Your command therefore would probably look like this:
/opt/gcc-4.7-cilkplus/bin/gcc -g -Wall -o exec main.o mysql-client.o \
databaseConnection-common.o murmurhash3.o bloom-filter.o \
`mysql_config --cflags --libs\` -L/opt/gcc-4.7-cilkplus/lib64/ -lcilkrts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Used -L and moved here
Upvotes: 0
Reputation: 1384
You are using -l
where you should be using -L
. The option -l
specifies a library, whereas -L
specifies a directory in which to look for libraries.
Note also that there is no space between -l
or -L
and its respective value.
Upvotes: 0
Reputation: 11896
-l (el) should be followed by a library, not a directory. Perhaps you meant -L or -I (eye)
Upvotes: 3