Skip to content
Advertisement

/usr/bin/ld cannot find -l

I have written a few programs and while trying to compile them using g++,as thus,

$ g++ minIni.c device_datum.cpp fanuc_axis.cpp fanuc_path.cpp service.cpp condition.cpp cutting_tool.cpp string_buffer.cpp logger.cpp client.cpp server.cpp adapter.cpp fanuc_adapter.cpp FanucAdapter.cpp -L/usr/local/lib/ -lfwlib32 -lpthread -o adapter

I keep getting the following error:

/usr/bin/ld: cannot find -lfwlib32
collect2: error: ld returned 1 exit status

fwlib32.h is the library I am trying to include. The shared object file libfwlib32.so is present in /usr/local/lib as well as /usr/lib. But I am unable link to it. I have tried all the solutions offered by similar questions including

$ export LIBRARY_PATH=/usr/local/lib/

$ export LD_LIBRARY_PATH=/usr/local/lib

I have done the above for /usr/lib as well, but still the same error. I have tried using the -L option in the command line but I still get the error.

I even created a new folder called lib, pasted libfwlib32.so.1.0.1 into it and ran

$ ln -s ~/lib/libfwlib32.so.1.0.1 ~/lib/libfwlib32.so

on the console to create a new .so file and gave ~/lib as argument to -L option on the command line. It made no difference. I am at the point of tearing my hair out so any help will be appreciated.

Thanks alot!

Advertisement

Answer

You should put -l option in the very last as:

$ g++ minIni.c device_datum.cpp fanuc_axis.cpp fanuc_path.cpp service.cpp condition.cpp cutting_tool.cpp string_buffer.cpp logger.cpp client.cpp server.cpp adapter.cpp fanuc_adapter.cpp FanucAdapter.cpp -L/usr/local/lib/ -o adapter -lfwlib32 -lpthread 

Note: Please make sure that all the header and source file are in the same folder.

Advertisement