Reputation: 28707
Using Eclipse CDT, I am trying to link a single library (.lib) file into my project.
During compilation, as a result of the space character in the file path, the path is split around the space, causing the file to not be found, and preventing compilation from executing successfully. This execution string is generated by Eclipse.
g++ -static-libgcc -static-libstdc++ -o "Test.exe" "src\\Test.o" -lC:/Program Files/Java/jdk1.7.0_15/lib/jvm.lib
g++: error: Files/Java/jdk1.7.0_15/lib/jvm.lib: No such file or directory
Overall, it has trouble constructing the library option for compilation:
-lC:/Program Files/Java/jdk1.7.0_15/lib/jvm.lib
I've tried both surrounding the path in quotes and adding the path's directory as a library path, yet the -l
option is malformed in both cases.
How can I successfully add a library with a space in its path into Eclipse CDT?
Upvotes: 3
Views: 3374
Reputation: 12557
You should enclose your path, that has spaces, with qoutes.
You probably should specify only library name (that is jvm
) at the Libraries tab. Then specify "C:/Program Files/Java/jdk1.7.0_15/lib"
at the Library Paths tab.
The point is that "-lC:/Program Files/Java/jdk1.7.0_15/lib/jvm.lib"
is valid option formation, as command interpreter will treat it as a single option but drop quotations.
So, when you type g++ "-lC:/Program Files/Java/jdk1.7.0_15/lib/jvm.lib"
in cmd, argument passed to g++ will be -lC:/Program Files/Java/jdk1.7.0_15/lib/jvm.lib
without quotes.
However, -l<path-to-library-file>
is invalid option for gcc
itself. You can either use
g++ <path-to-library-file>
or g++ -L<path-to-library-dir> -l<library-name>
.
So, valid options would be
g++ <..> "src\\Test.o" "-LC:/Program Files/Java/jdk1.7.0_15/lib" -ljvm
Upvotes: 2