I am trying to link some libraries my g++ code and I am getting the following error:
$ g++ -O myprob.o -o myprob -Wl,-rpath $PATH/lib -L$PATH/lib -lprob7_cpp -lprob7
g++.exe: error: c:\mypath;c:\mypath\lib: Invalid argument
If I try and run this command without the -Wl,-rpath $PATH/lib
part, which I think I should be able to do, then I get this error:
$ g++ -O myprob.o -o myprob -L$PATH/lib -lprob7_cpp -lprob7
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lprob7_cpp
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lprob
collect2.exe: error: ld returned 1 exit status
I have been tinkering with this for hours and can't seem to figure this out.
I have already compiled my .cpp
files successfully with the following command:
$ g++ -O -I$PATH/include -c myProb.cpp -o myProb.o
How can I correct these errors?
prob7_cpp
andprob7
, namelylibprob7_cpp.a
andlibprob7.a
files in library search path set by-L
. Check your configuration and files you aleady built.$PATH
is a variable in linux containing all paths to look for command binaries when calling them by name. You probably were trying to use the path to working directory$PWD
?