When running "make" with the CMakeLists.txt, use instead "VERBOSE=1 make" and you can see the commands to g++. This may help answer your questions.
- Noel On 17 November 2013 22:56, Nicolas Cheron <nicolas.cheron.bou...@gmail.com> wrote: > Hello, > > I want to give an update of my problem in case other people face it in the > future. I solved it only partially. Here is what I did, after installing on > Virtualbox a clean Ubuntu Gnome 13.10 64bits system, and downloading the > openbabel source (I tried with 2.3.1 and 2.3.2 the same procedure): > > tar zxf openbabel-2.3.2.tar.gz > sudo apt-get install g++ cmake wx-common wx2.8-headers libwxbase2.8-dev > libxml2-dev zlib1g-dev libeigen2-dev libcairo2-dev python-dev libperl-dev > mkdir Programs > mkdir Programs/Openbabel_2.3.2 > cd openbabel-2.3.2/ > cmake -DCMAKE_INSTALL_PREFIX=/home/nicolas/Programs/Openbabel_2.3.2 > -DBUILD_GUI=OFF > make > make install > make test > > The "make test" output was: "100% tests passed, 0 tests failed out of 58". I > tried "obabel Aspirin.smi -O Aspirin.png --gen2D" (where Aspirin.smi is a > file with only "O=C(Oc1ccccc1C(=O)O)C Aspirin") and I get the good png > scheme. So the installation of openbabel was successfull and is not the > problem. > > I copied the Quickstart example found here > http://openbabel.org/docs/current/UseTheLibrary/CppExamples.html in an > example.cpp file. > > 1) I then created a "Makefile" file with : > ************ > CC = g++ > CFLAGS = -c -I /home/nicolas/Programs/Openbabel_2.3.1/include/openbabel-2.0 > LDFLAGS = -lopenbabel -L /home/nicolas/Programs/Openbabel_2.3.1/lib > > all: example > > example: example.o > $(CC) $(LDFLAGS) example.o -o example > > example.o: example.cpp > $(CC) $(CFLAGS) $(LDFLAGS) example.cpp > > clean: > rm -rf example.o example > ************ > > After typing "make", the compilation fails with the error previously > reported : > > /tmp/cc2kfqde.o: In function `main': > example.cpp:(.text+0x120): undefined reference to > `OpenBabel::OBConversion::OBConversion(std::istream*, std::ostream*)' > example.cpp:(.text+0x139): undefined reference to > `OpenBabel::OBConversion::SetInAndOutFormats(char const*, char const*)' > example.cpp:(.text+0x165): undefined reference to > `OpenBabel::OBConversion::Convert()' > example.cpp:(.text+0x19e): undefined reference to > `OpenBabel::OBConversion::~OBConversion()' > example.cpp:(.text+0x1e1): undefined reference to > `OpenBabel::OBConversion::~OBConversion()' > collect2: error: ld returned 1 exit status > > 2) I created a "CMakeLists.txt" file with: > ************ > cmake_minimum_required(VERSION 2.6) > add_executable(example example.cpp) > target_link_libraries(example > /home/nicolas/Programs/Openbabel_2.3.1/lib/libopenbabel.so) > include_directories(/home/nicolas/Programs/Openbabel_2.3.1/include/openbabel-2.0) > ************ > > After typing "cmake" then "make", the file compiles. So I can compile and > use the openbabel library for my project. However, I don't understant why it > doesn't work directly with Makefile (and I would prefer use Makefile instead > of cmake). Does anyone have an idea of why, and how to modify the Makefile > to make it work? > > Thank you > > Nicolas > > > > > > -- > View this message in context: > http://forums.openbabel.org/Problem-for-compiling-the-example-files-tp4656837p4656869.html > Sent from the General discussion mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Shape the Mobile Experience: Free Subscription > Software experts and developers: Be at the forefront of tech innovation. > Intel(R) Software Adrenaline delivers strategic insight and game-changing > conversations that shape the rapidly evolving mobile landscape. Sign up now. > http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk > _______________________________________________ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss ------------------------------------------------------------------------------ Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss