Opened 9 years ago
Closed 9 years ago
#726 closed enhancement (fixed)
Compiling '[GEOS_root]/doc/example.cpp' with cmake project
Reported by: | ladelobe | Owned by: | mloskot |
---|---|---|---|
Priority: | major | Milestone: | 3.5.0 |
Component: | Build/Install (cmake) | Version: | main |
Severity: | Unassigned | Keywords: | cmake example.cpp link problem |
Cc: |
Description
Hello,
I'm really unsure about where to ask this question, so please be kind if I'm mistaking in posting here.
I have successfully installed two days ago the most recent version of the GEOS trunk (commit 5feba83f888d840e3d7e5f6eaa90ab6e9c9f2efa).
I have successfully manually compiled without errors/warnings the doc/example file with the following shell command :
g++ example.cpp -o example /usr/local/lib/libgeos.so.3.5.0dev
I have thus tried to compile with a cmake project file :
cmake_minimum_required(VERSION 2.8) project(GEOS_Example) add_executable(GEOS_Example example.cpp) set(CMAKE_EXE_LINKER_FLAGS "/usr/local/lib/libgeos.so.3.5.0dev")
I generated the project structure by a call to "cmake" :
$ cmake ../Geos_example_cmake/ -- The C compiler identification is GNU 4.8.2 -- The CXX compiler identification is GNU 4.8.2 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /data/projects/Libraries/Geos_example_build
Then I tried to launch "make" :
$ make Scanning dependencies of target GEOS_Example [100%] Building CXX object CMakeFiles/GEOS_Example.dir/example.cpp.o Linking CXX executable GEOS_Example CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « WKBtest(std::vector<geos::geom::Geometry*, std::allocator<geos::geom::Geometry*> >*) »: example.cpp:(.text+0x82): référence indéfinie vers « geos::io::WKBWriter::WKBWriter(int, int, bool) » example.cpp:(.text+0xec): référence indéfinie vers « geos::io::WKBWriter::write(geos::geom::Geometry const&, std::ostream&) » example.cpp:(.text+0x11b): référence indéfinie vers « geos::io::WKBReader::read(std::istream&) » example.cpp:(.text+0x206): référence indéfinie vers « geos::io::WKBReader::printHEX(std::istream&, std::ostream&) » example.cpp:(.text+0x231): référence indéfinie vers « geos::io::WKTWriter::WKTWriter() » example.cpp:(.text+0x251): référence indéfinie vers « geos::io::WKTWriter::write(geos::geom::Geometry const*) » example.cpp:(.text+0x2ae): référence indéfinie vers « geos::io::WKTWriter::write(geos::geom::Geometry const*) » example.cpp:(.text+0x2fa): référence indéfinie vers « geos::io::WKTWriter::~WKTWriter() » example.cpp:(.text+0x366): référence indéfinie vers « geos::io::WKBWriter::~WKBWriter() » example.cpp:(.text+0x3d0): référence indéfinie vers « geos::io::WKTWriter::~WKTWriter() » example.cpp:(.text+0x3e4): référence indéfinie vers « geos::io::WKBWriter::~WKBWriter() » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « wkt_print_geoms(std::vector<geos::geom::Geometry*, std::allocator<geos::geom::Geometry*> >*) »: example.cpp:(.text+0x453): référence indéfinie vers « geos::io::WKTWriter::WKTWriter() » example.cpp:(.text+0x493): référence indéfinie vers « geos::io::WKTWriter::write(geos::geom::Geometry const*) » example.cpp:(.text+0x516): référence indéfinie vers « geos::io::WKTWriter::~WKTWriter() » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_point(double, double) »: example.cpp:(.text+0x5a8): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x5be): référence indéfinie vers « geos::geom::GeometryFactory::createPoint(geos::geom::Coordinate const&) const » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_ushaped_linestring(double, double, double) »: example.cpp:(.text+0x5f7): référence indéfinie vers « geos::geom::CoordinateArraySequence::CoordinateArraySequence() » example.cpp:(.text+0x646): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x6a2): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x6fb): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x753): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x779): référence indéfinie vers « geos::geom::GeometryFactory::createLineString(geos::geom::CoordinateSequence*) const » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_square_linearring(double, double, double) »: example.cpp:(.text+0x7d1): référence indéfinie vers « geos::geom::CoordinateArraySequence::CoordinateArraySequence() » example.cpp:(.text+0x820): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x87c): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x8d5): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x92d): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x988): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x9ae): référence indéfinie vers « geos::geom::GeometryFactory::createLinearRing(geos::geom::CoordinateSequence*) const » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_square_polygon(double, double, double) »: example.cpp:(.text+0xadf): référence indéfinie vers « geos::geom::GeometryFactory::createPolygon(geos::geom::LinearRing*, std::vector<geos::geom::Geometry*, std::allocator<geos::geom::Geometry*> >*) const » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_simple_collection(std::vector<geos::geom::Geometry*, std::allocator<geos::geom::Geometry*> >*) »: example.cpp:(.text+0xb2a): référence indéfinie vers « geos::geom::GeometryFactory::createGeometryCollection(std::vector<geos::geom::Geometry*, std::allocator<geos::geom::Geometry*> > const&) const » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_circle(double, double, double) »: example.cpp:(.text+0xb66): référence indéfinie vers « geos::util::GeometricShapeFactory::GeometricShapeFactory(geos::geom::GeometryFactory const*) » example.cpp:(.text+0xbc4): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0xbda): référence indéfinie vers « geos::util::GeometricShapeFactory::setCentre(geos::geom::Coordinate const&) » example.cpp:(.text+0xbfc): référence indéfinie vers « geos::util::GeometricShapeFactory::setSize(double) » example.cpp:(.text+0xc08): référence indéfinie vers « geos::util::GeometricShapeFactory::createCircle() » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_ellipse(double, double, double, double) »: example.cpp:(.text+0xc82): référence indéfinie vers « geos::util::GeometricShapeFactory::GeometricShapeFactory(geos::geom::GeometryFactory const*) » example.cpp:(.text+0xce0): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0xcf6): référence indéfinie vers « geos::util::GeometricShapeFactory::setCentre(geos::geom::Coordinate const&) » example.cpp:(.text+0xd18): référence indéfinie vers « geos::util::GeometricShapeFactory::setHeight(double) » example.cpp:(.text+0xd3a): référence indéfinie vers « geos::util::GeometricShapeFactory::setWidth(double) » example.cpp:(.text+0xd46): référence indéfinie vers « geos::util::GeometricShapeFactory::createCircle() » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_rectangle(double, double, double, double) »: example.cpp:(.text+0xdc0): référence indéfinie vers « geos::util::GeometricShapeFactory::GeometricShapeFactory(geos::geom::GeometryFactory const*) » example.cpp:(.text+0xe1e): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0xe34): référence indéfinie vers « geos::util::GeometricShapeFactory::setBase(geos::geom::Coordinate const&) » example.cpp:(.text+0xe56): référence indéfinie vers « geos::util::GeometricShapeFactory::setHeight(double) » example.cpp:(.text+0xe78): référence indéfinie vers « geos::util::GeometricShapeFactory::setWidth(double) » example.cpp:(.text+0xe89): référence indéfinie vers « geos::util::GeometricShapeFactory::setNumPoints(int) » example.cpp:(.text+0xe95): référence indéfinie vers « geos::util::GeometricShapeFactory::createRectangle() » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_arc(double, double, double, double, double, double) »: example.cpp:(.text+0xf1f): référence indéfinie vers « geos::util::GeometricShapeFactory::GeometricShapeFactory(geos::geom::GeometryFactory const*) » example.cpp:(.text+0xf7d): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0xf93): référence indéfinie vers « geos::util::GeometricShapeFactory::setBase(geos::geom::Coordinate const&) » example.cpp:(.text+0xfb5): référence indéfinie vers « geos::util::GeometricShapeFactory::setHeight(double) » example.cpp:(.text+0xfd7): référence indéfinie vers « geos::util::GeometricShapeFactory::setWidth(double) » example.cpp:(.text+0x100f): référence indéfinie vers « geos::util::GeometricShapeFactory::createArc(double, double) » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « create_sinestar(double, double, double, int, double) »: example.cpp:(.text+0x10f4): référence indéfinie vers « geos::geom::Coordinate::Coordinate(double, double, double) » example.cpp:(.text+0x110a): référence indéfinie vers « geos::util::GeometricShapeFactory::setCentre(geos::geom::Coordinate const&) » example.cpp:(.text+0x112c): référence indéfinie vers « geos::util::GeometricShapeFactory::setSize(double) » example.cpp:(.text+0x1147): référence indéfinie vers « geos::util::GeometricShapeFactory::setNumPoints(int) » example.cpp:(.text+0x1193): référence indéfinie vers « geos::geom::util::SineStarFactory::createSineStar() const » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « do_all() »: example.cpp:(.text+0x125f): référence indéfinie vers « geos::geom::PrecisionModel::PrecisionModel(double, double, double) » example.cpp:(.text+0x128a): référence indéfinie vers « geos::geom::GeometryFactory::GeometryFactory(geos::geom::PrecisionModel const*, int) » example.cpp:(.text+0x12a5): référence indéfinie vers « geos::geom::PrecisionModel::~PrecisionModel() » example.cpp:(.text+0x3348): référence indéfinie vers « geos::geom::Geometry::Union(geos::geom::Geometry const*) const » example.cpp:(.text+0x3a06): référence indéfinie vers « geos::operation::linemerge::LineMerger::LineMerger() » example.cpp:(.text+0x3a1f): référence indéfinie vers « geos::operation::linemerge::LineMerger::add(std::vector<geos::geom::Geometry*, std::allocator<geos::geom::Geometry*> >*) » example.cpp:(.text+0x3a2e): référence indéfinie vers « geos::operation::linemerge::LineMerger::getMergedLineStrings() » example.cpp:(.text+0x3bb7): référence indéfinie vers « geos::operation::polygonize::Polygonizer::Polygonizer() » example.cpp:(.text+0x3bd0): référence indéfinie vers « geos::operation::polygonize::Polygonizer::add(std::vector<geos::geom::Geometry*, std::allocator<geos::geom::Geometry*> >*) » example.cpp:(.text+0x3bdf): référence indéfinie vers « geos::operation::polygonize::Polygonizer::getPolygons() » example.cpp:(.text+0x3e0e): référence indéfinie vers « geos::operation::polygonize::Polygonizer::~Polygonizer() » example.cpp:(.text+0x3e1d): référence indéfinie vers « geos::operation::linemerge::LineMerger::~LineMerger() » example.cpp:(.text+0x4a0b): référence indéfinie vers « geos::operation::polygonize::Polygonizer::~Polygonizer() » example.cpp:(.text+0x4a1f): référence indéfinie vers « geos::operation::linemerge::LineMerger::~LineMerger() » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « main »: example.cpp:(.text+0x4a4b): référence indéfinie vers « geos::geom::jtsport() » example.cpp:(.text+0x4a57): référence indéfinie vers « geos::geom::geosversion() » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « geos::io::WKBReader::WKBReader(geos::geom::GeometryFactory const&) »: example.cpp:(.text._ZN4geos2io9WKBReaderC2ERKNS_4geom15GeometryFactoryE[_ZN4geos2io9WKBReaderC5ERKNS_4geom15GeometryFactoryE]+0x2d): référence indéfinie vers « geos::io::ByteOrderDataInStream::ByteOrderDataInStream(std::istream*) » example.cpp:(.text._ZN4geos2io9WKBReaderC2ERKNS_4geom15GeometryFactoryE[_ZN4geos2io9WKBReaderC5ERKNS_4geom15GeometryFactoryE]+0x52): référence indéfinie vers « geos::io::ByteOrderDataInStream::~ByteOrderDataInStream() » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « geos::geom::util::SineStarFactory::SineStarFactory(geos::geom::GeometryFactory const*) »: example.cpp:(.text._ZN4geos4geom4util15SineStarFactoryC2EPKNS0_15GeometryFactoryE[_ZN4geos4geom4util15SineStarFactoryC5EPKNS0_15GeometryFactoryE]+0x1f): référence indéfinie vers « geos::util::GeometricShapeFactory::GeometricShapeFactory(geos::geom::GeometryFactory const*) » CMakeFiles/GEOS_Example.dir/example.cpp.o: dans la fonction « geos::io::WKBReader::~WKBReader() »: example.cpp:(.text._ZN4geos2io9WKBReaderD2Ev[_ZN4geos2io9WKBReaderD5Ev]+0x29): référence indéfinie vers « geos::io::ByteOrderDataInStream::~ByteOrderDataInStream() » example.cpp:(.text._ZN4geos2io9WKBReaderD2Ev[_ZN4geos2io9WKBReaderD5Ev]+0x3e): référence indéfinie vers « geos::io::ByteOrderDataInStream::~ByteOrderDataInStream() » collect2: error: ld returned 1 exit status make[2]: *** [GEOS_Example] Erreur 1 make[1]: *** [CMakeFiles/GEOS_Example.dir/all] Erreur 2 make: *** [all] Erreur 2
After checking that the geos library is linked against the source in the linker step (VERBOSE=1), I see no reason why the link process would fail with cmake and succeed with g++ command line.
So, is it possible to find a way to compile the "example.cpp" file with geos using "cmake" tool ?
Compiler Infos :
$ cmake --version cmake version 2.8.12.2 $ g++ --version g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.