Reputation: 4474
I am puzzled how a mere g++ -o testpoco testpoco.cpp -lPocoFoundation
was able to compile successfully in my Cygwin
environment. The complete C++ code is below:
#include <Poco/File.h>
int main (int argc, char *argv[])
{
Poco::File f("/tmp/test.log");
if (f.exists()) {
return 1;
}
return 0;
}
I installed the cygwin Poco development headers and libraries and I verified they are in:
But without specifying those include and library path in g++
how did it was able to compile and produce the exe? I checked the output of g++ -v
and did not see any routes to Poco
.
Upvotes: 1
Views: 284
Reputation: 171413
I checked the output of
g++ -v
and did not see any routes to Poco
The command g++ -v
will just print out some version information about GCC, and how it was configured. Adding the -v
option to your real commands used for compiling and/or linking will show the search paths for headers and libraries.
In other words, instead of just g++ -v
you should try:
g++ -o testpoco testpoco.cpp -lPocoFoundation -v
This will show the search paths that Keith Thompson refers to in his answer.
Upvotes: 1
Reputation: 263617
The compiler has default search paths for include files and for libraries. (Actually the latter applies to the linker, not the compiler, but the g++
command invokes both.)
/usr/include
and /usr/lib
are in those default search paths.
You specified #include <Poco/File.h>
, so the compiler found /usr/include/Poco/File.h
.
You specified -lPocoFoundation
, so the linker found /usr/lib/libPocoFoundation.dll.a
, the file that contains the code implementing the PocoFoundation library under Cygwin.
Upvotes: 2