Unix Shell - Off-Topic or not?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2006 > Off-Topic or not?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Off-Topic or not?
Huub

2006-09-06, 1:37 pm

Hi,

I have a question about creating a Makefile. Is this OT here or not?

Thanks,

Huub
Barry Margolin

2006-09-07, 1:26 am

In article <44ff00a1$0$4367$e4fe514c@dreader28.news.xs4all.nl>,
Huub <"v.niekerk at hccnet.nl"> wrote:

> Hi,
>
> I have a question about creating a Makefile. Is this OT here or not?


comp.unix.programmer would be more appropriate.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
mailto.anand.hariharan@gmail.com

2006-09-07, 1:26 am


Barry Margolin wrote:
> In article <44ff00a1$0$4367$e4fe514c@dreader28.news.xs4all.nl>,
> Huub <"v.niekerk at hccnet.nl"> wrote:
>
>
> comp.unix.programmer would be more appropriate.
>


He started off the thread originally in alt.comp.lang.learn.c-c++. His
problem has a lot more to do with the command line (back-tick
interpolation) than a dependency issue. I suggested he should post the
problem here.

- Anand

Huub

2006-09-07, 7:43 am

Ok, this is my problem: I want to build C++ code with gtkmm. Everything
needed is installed ok, but when I create a Makefile, it can't find the
headerfiles needed. These files are in gtkmm-2.4/gtkmm/
The Makefile (actually my last attempt to include the required argument
`pkg-config gtkmm-2.4 --cflags --libs`):

CC = g++
CFLAGS = -g
CXXFLAGS = $(shell pkg-config gtkmm-2.4 --cflags --libs)

all: helloworld.o
$(CC) $(CXXFLAGS) -c `pkg-config gtkmm-2.4 --cflags --libs`-o main
helloworld.o

helloworld.o: helloworld.cc
$(CC) -c $(CFLAGS) helloworld.cc

clean:
rm -f *.0 *~ *.bak

I hope you can explain where I should put the CXXFLAGS and why/how. It
just won't find the libraries in gtkmm-2.4/gtkmm/


Thanks for helping out,

Huub
mailto.anand.hariharan@gmail.com

2006-09-07, 7:45 pm


Huub wrote:
> Ok, this is my problem: I want to build C++ code with gtkmm. Everything
> needed is installed ok, but when I create a Makefile, it can't find the
> headerfiles needed. These files are in gtkmm-2.4/gtkmm/
> The Makefile (actually my last attempt to include the required argument
> `pkg-config gtkmm-2.4 --cflags --libs`):
>
> CC = g++
> CFLAGS = -g
> CXXFLAGS = $(shell pkg-config gtkmm-2.4 --cflags --libs)
>
> all: helloworld.o
> $(CC) $(CXXFLAGS) -c `pkg-config gtkmm-2.4 --cflags --libs`-o main
> helloworld.o
>
> helloworld.o: helloworld.cc
> $(CC) -c $(CFLAGS) helloworld.cc
>
> clean:
> rm -f *.0 *~ *.bak
>
> I hope you can explain where I should put the CXXFLAGS and why/how. It
> just won't find the libraries in gtkmm-2.4/gtkmm/
>
>
> Thanks for helping out,
>
> Huub


First get your command line right. Then you can work on getting the
dependency tree set up in your makefile.

Does this work?

g++ -o main helloworld.c `pkg-config gtkmm-2.4 --cflags --libs`

If it does (i.e., it generated an executable called 'main'
successfully), then move on to working on your makefile.

HTH,
- Anand

Huub

2006-09-16, 1:43 pm

> First get your command line right. Then you can work on getting the
> dependency tree set up in your makefile.
>
> Does this work?
>
> g++ -o main helloworld.c `pkg-config gtkmm-2.4 --cflags --libs`
>
> If it does (i.e., it generated an executable called 'main'
> successfully), then move on to working on your makefile.
>
> HTH,
> - Anand
>


This command works:
g++ `pkg-config gtkmm-2.4 --cflags --libs` main.cc -o main helloworld.cc
fischertechnik.cc

Apparently it doesn't matter if the `pkg...` is put in front or at the
back.
Juggling with the Makefile, my latest attempt is this but it still
doesn't work:

CC = g++
CFLAGS = -g
CXXFLAGS = `pkg-config gtkmm-2.4 --cflags --libs`

all: main.o helloworld.o fischertechnik.o
$(CC) $(CXXFLAGS) -o main helloworld.o fischertechnik.o main.o

main.o: main.cc
$(CC) main.cc

helloworld.o: helloworld.cc
$(CC) helloworld.cc

fischertechnik.o: fischertechnik.cc
$(CC) fischertechnik.cc

clean:
rm -f *.o *~ *.bak

These are some of the errors I get when trying to 'make':

$ make
g++ helloworld.cc
In file included from helloworld.cc:1:
helloworld.h:4:26: error: gtkmm/button.h: No such file or directory
helloworld.h:5:26: error: gtkmm/window.h: No such file or directory
helloworld.h:7: error: ‘Gtk’ has not been declared
helloworld.h:7: error: expected `{' before ‘Window’
helloworld.h:7: error: invalid function declaration

So, if you or anyone else please could help me out to get it working? I
expect the error to be with 'all:', but I'm not quite sure.

Thank you for helping out.

Huub
mailto.anand.hariharan@gmail.com

2006-09-21, 7:29 pm


Huub wrote:
>
> This command works:
> g++ `pkg-config gtkmm-2.4 --cflags --libs` main.cc -o main helloworld.cc
> fischertechnik.cc
>
> Apparently it doesn't matter if the `pkg...` is put in front or at the
> back.
> Juggling with the Makefile, my latest attempt is this but it still
> doesn't work:
>


Note that the command line actually accomplishes two things - compiling
and linking. Your 'pkg-config' command generates outputs that are used
for both.

> CC = g++
> CFLAGS = -g
> CXXFLAGS = `pkg-config gtkmm-2.4 --cflags --libs`
>


Arguably, it should suffice just to have --cflags for the CXXFLAGS
variable. Create a new variable called LDFLAGS (or something similar)
that has the --libs flags.

> all: main.o helloworld.o fischertechnik.o
> $(CC) $(CXXFLAGS) -o main helloworld.o fischertechnik.o main.o
>


This is linking, so use the LDFLAGS.

> main.o: main.cc
> $(CC) main.cc
>
> helloworld.o: helloworld.cc
> $(CC) helloworld.cc
>
> fischertechnik.o: fischertechnik.cc
> $(CC) fischertechnik.cc
>


All these are compiling, so use CXXFLAGS. Compilation needs to know
the include paths, so this is essential (which is why it fails to
compile).

> clean:
> rm -f *.o *~ *.bak
>
> These are some of the errors I get when trying to 'make':
>
> $ make
> g++ helloworld.cc
> In file included from helloworld.cc:1:
> helloworld.h:4:26: error: gtkmm/button.h: No such file or directory
> helloworld.h:5:26: error: gtkmm/window.h: No such file or directory
> helloworld.h:7: error: 'Gtk' has not been declared
> helloworld.h:7: error: expected `{' before 'Window'
> helloworld.h:7: error: invalid function declaration
>


Your makefile should capture the dependency to "helloworld.h" -- put it
beside helloworld.cc (for the helloworld.o target).

> So, if you or anyone else please could help me out to get it working? I
> expect the error to be with 'all:', but I'm not quite sure.
>
> Thank you for helping out.
>
> Huub


In general, your problem is not so much regarding makefiles, but the
command line for the compiler.

HTH,
- Anand

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com