Linux g++ compiling error: /usr/bin/ld: cannot fin

2019-08-15 06:38发布

问题:

I am working on a project in which protobuf and zmq are involved. I have finished it on VS2010 and now want to make it work under Linux. I just installed protobuf and zmq on our Linux server and the Makefile looks like this:

g++ -c  -D_DEBUG TestTDFAPI_v2.cpp -I ../
g++ -c  -D_DEBUG Platform.cpp
g++ -c  -D_DEBUG PathHelper.cpp                                                                                                    
g++ -c  -D_DEBUG MyStruct.pb.cpp            
g++ -c  -D_DEBUG MyStruct.cpp
g++ -o Test_TDFAPI_v2 Platform.o PathHelper.o MyStruct.pb.o MyStruct.o TestTDFAPI_v2.o -l /usr/local/include -L /usr/local/lib -L../ -L../linux/ -lTDFAPI_v2 -lWHNetWork -lpthread -lprotobuf

After make, I got the following error:

/usr/bin/ld: cannot find -l/usr/local/include
collect2: ld returned 1 exit status

Anyone has any clue?

回答1:

-l (minus ell) is for library files to search for resolving references, you want -I (minus eye) to specify include directories.