You are not logged in.

#1 2010-06-02 15:07:23

Maximalminimalist
Member
Registered: 2009-09-20
Posts: 112

[Solved] How do I use and include these C++ libraries?

Hi!

I'm studying physics in the first year and I have one course in C++. They gave use libraries for it but I couldn't make it work on arch linux. It is supposed to work out-of-the-box after unpacking and "make install" it. But that's not the case. When I try to compile something that uses X-libs it doesn't work.
(I went through the semester without these libs because they are not that important but I think I'll take a look before the exam in August. wink )

Warning: If you make install it, it overwrites '~/.emacs'. (make install is in progs/libraries)

Here's the link of the site (german):
http://www.ti.inf.ethz.ch/ew/courses/In … rball.html

Here's the tarball to use:
http://www.ti.inf.ethz.ch/ew/courses/In … _Linux.tgz

I'd be really happy if somebody would take a look or give me a link to make this work.

(BTW: If someone is bored/interested, he can take a look at the lindenmayer-challenge I couldn't do because I couldn't use these libs. sad  )

Thanks in advance :-) ,

Maximalminimalist

Last edited by Maximalminimalist (2010-06-02 17:42:13)

Offline

#2 2010-06-02 15:24:53

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: [Solved] How do I use and include these C++ libraries?

You should try to be more clear when you say "it doesn't work.", like what error messages are you getting? You probably just need to install the development libraries it needs, but you'll have to figure out what those are.

Offline

#3 2010-06-02 16:36:12

Maximalminimalist
Member
Registered: 2009-09-20
Posts: 112

Re: [Solved] How do I use and include these C++ libraries?

You're probably right. wink Sorry. smile

One example: There's lindenmayer.cpp

// Prog: lindenmayer.cpp
// Draw turtle graphics for the Lindenmayer system with
// production F -> F+F+ and initial word F.

#include <iostream>
#include <IFM/turtle>

// POST: the word w_i^F is drawn
void f (const unsigned int i) {
  if (i == 0) 
    ifm::forward();  // F
  else {
    f(i-1);          // w_{i-1}^F
    ifm::left(90);   // +
    f(i-1);          // w_{i-1}^F
    ifm::left(90);   // +
  }
}

int main () {
  std::cout << "Number of iterations =? ";
  unsigned int n;
  std::cin >> n;

  // draw w_n = w_n(F)
  f(n); 

  return 0;
}

Compiling:

g++ lindenmayer.cpp 
lindenmayer.cpp:6:22: fatal error: IFM/turtle: No such file or directory
compilation terminated.

The turtle lib is (I think) in

~/progs/libraries/include/IFM/turtle

They also say that the xorg-dev package is needed. Here in Arch Linux 'base-devel' is the one I need (and already have)?

Offline

#4 2010-06-02 16:45:15

m0nhawk
Member
Registered: 2010-01-15
Posts: 25

Re: [Solved] How do I use and include these C++ libraries?

Set full path to the library?

Offline

#5 2010-06-02 16:52:32

eirika
Member
From: New York
Registered: 2009-09-14
Posts: 65

Re: [Solved] How do I use and include these C++ libraries?

Maximalminimalist wrote:

The turtle lib is (I think) in

~/progs/libraries/include/IFM/turtle

This is not in the standard search path. judging from the error message,
I think you need to specify the path of the library using -I when compiling
and -L when linking in g++.

Offline

#6 2010-06-02 17:35:38

Atragor
Member
Registered: 2009-02-28
Posts: 59

Re: [Solved] How do I use and include these C++ libraries?

You can just use

make lindenmayer

or manually set the required compiler flags:

g++ -I ~/IFMP/libwindow/include -L ~/IFMP/libwindow/lib/ lindenmayer.cpp -lturtle -lwindow -lX11

P.S. Of course I haven't noticed your warning. Fortunately I use vim and therefore I haven't lost a thousand lines of elisp code  smile

Offline

#7 2010-06-02 17:38:24

Maximalminimalist
Member
Registered: 2009-09-20
Posts: 112

Re: [Solved] How do I use and include these C++ libraries?

Thanks for your help. smile I'll try to deal with what you told me.

EDIT: Haven't seen Atragor's post. You're my new god. big_smile Thanks a lot! You made me save a lot of time. wink
(Now you can play with lindenmayer. big_smile )

P.S. I'm using vim too. wink

Last edited by Maximalminimalist (2010-06-02 17:42:52)

Offline

#8 2010-06-11 10:15:32

justinwood
Member
Registered: 2010-06-11
Posts: 4

Re: [Solved] How do I use and include these C++ libraries?

i think eirika is correct. The way chosen is the correct way and it almost works. Hope everyone here is satisfied with that reply.

Offline

Board footer

Powered by FluxBB