1

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.

3 Answers 3

3

-l (el) should be followed by a library, not a directory. Perhaps you meant -L or -I (eye)

Sign up to request clarification or add additional context in comments.

3 Comments

-L tells the linker a directory to search. It is almost certainly -L.
my bad. I got it now. Can you tell some other place to specify these linker library so that I do not have to include then by doing -L each time (like some path variable which gcc searches every time before linking).
LIBRARY_PATH environment variable
0

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.

Comments

0

-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.