Re: Make Q's

2009-09-18 Thread Derek Atkins
Joshua Judson Rosen roz...@geekspace.com writes:

 project_SOURCES = file1.c file2.c \
   file3.cpp file4.cpp file5.cpp file6.cpp file7.cpp
 # (NOTE: project_SOURCES should also include
 #  any corresponding header-files)

Actually, no, you should use:

project_HEADERS = file1.h file2.h ...

-derek

-- 
   Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
   Member, MIT Student Information Processing Board  (SIPB)
   URL: http://web.mit.edu/warlord/PP-ASEL-IA N1NWH
   warl...@mit.eduPGP key available
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread bruce . labitt
Here is a copy of my makefile.  It is a lot easier for someone to help, if 
they can see what I'm doing...
I just noticed the CC and lack of CXX, I'll fix that.

# Makefile for tcp_fft_server
# Date: Fri 18 Sep 2009 10:13:54 AM EDT 
# Author: Bruce Labitt  bruce.lab...@autoliv.com

# Dependencies
# myserver needs = myfft, memcpy_cell, getflops, pack, savewisdom, fftw3
# myfft.cpp depends on memcpy_cell
# memcpy_cell.c depends on - 
# getflops.cpp needs fftw3.h
# pack.c depends on -
# savewisdom.cpp needs fftw3.h

CC=g++
C=gcc
INCLUDES=-I/usr/local/include -I/usr/lib/gcc/ppu/4.1.1/include 
-I/usr/lib/gcc/spu/4.1.1/include -I./include
LIBS=-L/usr/local/lib -lfftw3 -lm 
CCOPTS=-O3 -m64 -mcpu=970 -mtune=970 -D_FILE_OFFSET_BITS=64 -fopenmp -Wall 
-Wcast-qual
OBJECTS=pack.o getflops.o memcpy_cell.o myfft.o savewisdom.o myserver.o
vpath %.h ./include

all: server

server: $(OBJECTS)
$(CC) -oserver $(CCOPTS) $(LIBS) $(INCLUDES) $(OBJECTS)

pack.o: pack.c pack.h
$(C) -c pack.c $(CCOPTS) $(INCLUDES)

getflops.o: getflops.cpp getflops.h
$(CC) -c getflops.cpp $(CCOPTS) $(INCLUDES)

myserver.o: myserver.cpp getflops.h myfft.h savewisdom.h pack.h 
memcpy_cell.h /usr/local/include/fftw3.h 
$(CC) -c myserver.cpp $(CCOPTS) $(INCLUDES)

memcpy_cell.o:  memcpy_cell.c memcpy_cell.h
$(C)  -c memcpy_cell.c $(CCOPTS) $(INCLUDES)

myfft.o:myfft.cpp myfft.h memcpy_cell.h memcpy_cell.c
$(CC) -c myfft.cpp $(CCOPTS) $(INCLUDES) 

savewisdom.o:   savewisdom.cpp savewisdom.h /usr/local/include/fftw3.h
$(CC) -c savewisdom.cpp $(CCOPTS) $(INCLUDES) 

clean:
rm -rf *o server


Not automated, but, it should work, I hope...

But, this is what I get as output.  Everything seems to compile ok... 
Linking seems to be an issue...

g++ -oserver -O3 -m64 -mcpu=970 -mtune=970 -D_FILE_OFFSET_BITS=64 -fopenmp 
-Wall -Wcast-qual -L/usr/local/lib -lfftw3 -lm  -I/usr/local/include 
-I/usr/lib/gcc/ppu/4.1.1/include -I/usr/lib/gcc/spu/4.1.1/include 
-I./include pack.o getflops.o myfft.o memcpy_cell.o savewisdom.o 
myserver.o
myfft.o:(.text+0x198): undefined reference to `memcpy_cell(void*, void 
const*, unsigned long)'
myfft.o:(.text+0x1ac): undefined reference to `memcpy_cell(void*, void 
const*, unsigned long)'
myfft.o:(.text+0x1c0): undefined reference to `memcpy_cell(void*, void 
const*, unsigned long)'
myserver.o:(.text+0xd58): undefined reference to `pack(unsigned char*, 
char*, ...)'
myserver.o:(.text+0xe90): undefined reference to `pack(unsigned char*, 
char*, ...)'
myserver.o:(.text+0xf74): undefined reference to `unpack(unsigned char*, 
char*, ...)'
myserver.o:(.text+0x1018): undefined reference to `unpack(unsigned char*, 
char*, ...)'
myserver.o:(.text+0x1154): undefined reference to `unpack(unsigned char*, 
char*, ...)'
myserver.o:(.text+0x1270): undefined reference to `unpack(unsigned char*, 
char*, ...)'
myserver.o:(.text+0x1378): undefined reference to `unpack(unsigned char*, 
char*, ...)'
myserver.o:(.text+0x14a0): more undefined references to `unpack(unsigned 
char*, char*, ...)' follow
collect2: ld returned 1 exit status
make: *** [server] Error 1

myfft.cpp has the following includes:
#include memcpy_cell.h

myserver.cpp has includes of:
#include fftw3.h
#include getflops.h
#include myfft.h
#include savewisdom.h
#include pack.h

If someone could help me out, I would greatly appreciate it!  I've 
successfully used fftw before, along with getflops.cpp, myfft.cpp, 
savewisdom.cpp, and memcpy_cell.c in another project I created and used 6 
months ago.

Help!
-Bruce







**
Neither the footer nor anything else in this E-mail is intended to or 
constitutes an brelectronic signature and/or legally binding agreement in the 
absence of an brexpress statement or Autoliv policy and/or procedure to the 
contrary.brThis E-mail and any attachments hereto are Autoliv property and 
may contain legally brprivileged, confidential and/or proprietary 
information.brThe recipient of this E-mail is prohibited from distributing, 
copying, forwarding or in any way brdisseminating any material contained 
within this E-mail without prior written brpermission from the author. If you 
receive this E-mail in error, please brimmediately notify the author and 
delete this E-mail.  Autoliv disclaims all brresponsibility and liability for 
the consequences of any person who fails to brabide by the terms herein. br
**

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread Derek Atkins
bruce.lab...@autoliv.com writes:

[snip]
 myfft.o:(.text+0x198): undefined reference to `memcpy_cell(void*, void 
 const*, unsigned long)'
[snip]
 myserver.o:(.text+0xd58): undefined reference to `pack(unsigned char*, 
 char*, ...)'
[snip]
 myserver.o:(.text+0xf74): undefined reference to `unpack(unsigned char*, 
 char*, ...)'
[snip]

 If someone could help me out, I would greatly appreciate it!  I've 
 successfully used fftw before, along with getflops.cpp, myfft.cpp, 
 savewisdom.cpp, and memcpy_cell.c in another project I created and used 6 
 months ago.

Where are these three functions defined?

Perhaps you need an 'extern C' in there so C++ knows how to call the C
functions?

 Help!
 -Bruce

-derek

-- 
   Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
   Member, MIT Student Information Processing Board  (SIPB)
   URL: http://web.mit.edu/warlord/PP-ASEL-IA N1NWH
   warl...@mit.eduPGP key available
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread Kevin D. Clark

Derek Atkins writes:

 Perhaps you need an 'extern C' in there so C++ knows how to call the C
 functions?

To cut to the chase, Bruce probably should make sure that all of his C
functions are declared in C-specific header files that have the
following pattern:



#ifndef UTIL_H
#define UTIL_H

#ifdef __cplusplus
extern C {
#endif


void some_function_with_c_linkage();

#ifdef __cplusplus
}
#endif

#endif  /* UTIL_H */


Bruce will also want to make sure that his C functions are compiled by
an actual C compiler.

This advice is a little bit of my opinion and a little bit of an
inflexible you must do this if you want this to work.

Regards,

--kevin

Keywords:  name-mangling


-- 
GnuPG ID: B280F24EGod, I loved that Pontiac.
alumni.unh.edu!kdc-- Tom Waits
http://kdc-blog.blogspot.com/ 
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread Joshua Judson Rosen
Derek Atkins warl...@mit.edu writes:

 Joshua Judson Rosen roz...@geekspace.com writes:
 
  project_SOURCES = file1.c file2.c \
  file3.cpp file4.cpp file5.cpp file6.cpp file7.cpp
  # (NOTE: project_SOURCES should also include
  #  any corresponding header-files)
 
 Actually, no, you should use:
 
 project_HEADERS = file1.h file2.h ...

Actually, while there *is* a `_HEADERS' primary in Automake,
that's not what it means--listing things in project_HEADERS
means `these are headers that will be installed into ${projectdir}
by make install', while project_SOURCES establishes the headers
as source-files that contribute to building the `project' binary
(and they explicitly become part of its list of dependencies).

Any `public' headers that are part of a library's public interface
should be listed in ${include_HEADERS} (or ${pkginclude_HEADERS}, or
something in the same vein); any *private* headers should usually go
into ${project_SOURCES}, though you might want to put them into
${noinst_HEADERS} if the they aren't directly associated with
(`owned by') any particular built object. The Automake manual says:

   Usually, only header files that accompany installed libraries need
to be installed.  Headers used by programs or convenience
libraries are not installed.  The `noinst_HEADERS' variable can be
used for such headers.  However when the header actually belongs
to one convenient library or program, we recommend listing it in
the program's or library's `_SOURCES' variable (*note Program
Sources::) instead of in `noinst_HEADERS'.  This is clearer for
the `Makefile.am' reader.  `noinst_HEADERS' would be the right
variable to use in a directory containing only headers and no
associated library or program.

There's /is/ also the matter of ensuring that everything necessary
gets into the tarballs genertated by `make dist', and including files
in *any* of these lists will accomplish that.

-- 
Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr.
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread bruce . labitt
Derek Atkins warl...@mit.edu wrote on 09/18/2009 11:55:27 AM:

 bruce.lab...@autoliv.com writes:
 
 [snip]
  myfft.o:(.text+0x198): undefined reference to `memcpy_cell(void*, void 

  const*, unsigned long)'
 [snip]
  myserver.o:(.text+0xd58): undefined reference to `pack(unsigned char*, 

  char*, ...)'
 [snip]
  myserver.o:(.text+0xf74): undefined reference to `unpack(unsigned 
char*, 
  char*, ...)'
 [snip]
 
  If someone could help me out, I would greatly appreciate it!  I've 
  successfully used fftw before, along with getflops.cpp, myfft.cpp, 
  savewisdom.cpp, and memcpy_cell.c in another project I created and 
used 6 
  months ago.
 
 Where are these three functions defined?
 

memcpy_cell.c for memcpy_cell, pack.c for pack and unpack

 Perhaps you need an 'extern C' in there so C++ knows how to call the C
 functions?
 
  Help!
  -Bruce
 
 -derek
 
 -- 
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board  (SIPB)
URL: http://web.mit.edu/warlord/PP-ASEL-IA N1NWH
warl...@mit.eduPGP key available


**
Neither the footer nor anything else in this E-mail is intended to or 
constitutes an brelectronic signature and/or legally binding agreement in the 
absence of an brexpress statement or Autoliv policy and/or procedure to the 
contrary.brThis E-mail and any attachments hereto are Autoliv property and 
may contain legally brprivileged, confidential and/or proprietary 
information.brThe recipient of this E-mail is prohibited from distributing, 
copying, forwarding or in any way brdisseminating any material contained 
within this E-mail without prior written brpermission from the author. If you 
receive this E-mail in error, please brimmediately notify the author and 
delete this E-mail.  Autoliv disclaims all brresponsibility and liability for 
the consequences of any person who fails to brabide by the terms herein. br
**

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread Michael ODonnell


As an experiment, can you link a helloWorld-style object (that needs
the symbols in question) against the libs in question?

In other words, arrange for that memcpy_cell(void*,blah,blah) to be
unresolved in your helloWorld object and then link it against the object
or lib you think should be providing it.

You can use readelf to provide more info than you'll ever need about
the various objectslibs in question; try this:

   readelf --all yourObjectOrLibHere

...and then look for the symbol table info to confirm that your symbol
is provided/requested where you think it should be.
 
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread bruce . labitt
gnhlug-discuss-boun...@mail.gnhlug.org wrote on 09/18/2009 12:16:15 PM:

 
 Derek Atkins writes:
 
  Perhaps you need an 'extern C' in there so C++ knows how to call the 
C
  functions?
 
 To cut to the chase, Bruce probably should make sure that all of his C
 functions are declared in C-specific header files that have the
 following pattern:
 
 
 
 #ifndef UTIL_H
 #define UTIL_H
 
 #ifdef __cplusplus
 extern C {
 #endif
 
 
 void some_function_with_c_linkage();
 
 #ifdef __cplusplus
 }
 #endif
 
 #endif  /* UTIL_H */
 
 

Could you explain why this is necessary, and what it does?  What is 
necessary to use this?

 Bruce will also want to make sure that his C functions are compiled by
 an actual C compiler.
 

My makefile did that.  The C files are compiled with gcc, the C++ files 
with g++.

 This advice is a little bit of my opinion and a little bit of an
 inflexible you must do this if you want this to work.
 

I've not seen this type of code before.  I wonder why all of my previous 
code even works.  Surely it is a way to do it.  Is there a simpler way? 
(Not that the above is hard by any means.)


Cheers,
-Bruce


 Regards,
 
 --kevin
 


**
Neither the footer nor anything else in this E-mail is intended to or 
constitutes an brelectronic signature and/or legally binding agreement in the 
absence of an brexpress statement or Autoliv policy and/or procedure to the 
contrary.brThis E-mail and any attachments hereto are Autoliv property and 
may contain legally brprivileged, confidential and/or proprietary 
information.brThe recipient of this E-mail is prohibited from distributing, 
copying, forwarding or in any way brdisseminating any material contained 
within this E-mail without prior written brpermission from the author. If you 
receive this E-mail in error, please brimmediately notify the author and 
delete this E-mail.  Autoliv disclaims all brresponsibility and liability for 
the consequences of any person who fails to brabide by the terms herein. br
**

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread Peter Dobratz
 #ifndef UTIL_H
 #define UTIL_H

 #ifdef __cplusplus
 extern C {
 #endif


 void some_function_with_c_linkage();

 #ifdef __cplusplus
 }
 #endif

 #endif  /* UTIL_H */


 Could you explain why this is necessary, and what it does?  What is
 necessary to use this?

C compilers do not name mangle symbols in the way that C++ compilers do.

http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B#Linking_C_and_C.2B.2B_code

Basically, C++ supports function overloading (two functions with the
same name that differ only in argument lists).  The actual name of the
function that is used by the linker has an encoded version of both the
function name and its argument types in it.  However, C does not need
the same kind of name changing behavior because it doesn't support
function overloading.

--Peter

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread Joshua Judson Rosen
bruce.lab...@autoliv.com writes:

 gnhlug-discuss-boun...@mail.gnhlug.org wrote on 09/18/2009 12:16:15 PM:
  
  Derek Atkins writes:
  
   Perhaps you need an 'extern C' in there so C++ knows how to
   call the C functions?
  
  To cut to the chase, Bruce probably should make sure that all of his C
  functions are declared in C-specific header files that have the
  following pattern:
  
  #ifndef UTIL_H
  #define UTIL_H
  
  #ifdef __cplusplus
  extern C {
  #endif
  
  void some_function_with_c_linkage();
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif  /* UTIL_H */
 
 Could you explain why this is necessary, and what it does?  What is 
 necessary to use this?

There are actually two distinct things going on, here:

* The multiple-#include guard:
  #ifndef UTIL_H
  #define UTIL_H
  [...stuff you actually care about ...]
  #endif

This makes it safe for a given header to be `#include'd multiple
times in the same file, which can become a common occurrence if
someone puts an #include yourfile.h directive into another
header-file, which may in turn be `#include'd by other headers-files.

Without this guard, multiple successive `#include's of your
header would effectively result in the contained definitions
being written multiple times, which may make your compiler throw a
`X is multiply defined' error.


* The `extern C {...}' C++ linkage guard:

This is actually C++ code, which tells the C++ compiler to avoid
mangling the names of functions/variables/constants used in the
code that it's compiling; mangling is, in fact, a technical
term. Here's a Wikipedia article on it:

http://en.wikipedia.org/wiki/Name_mangling

The #ifdef __cplusplus is using a condition that will be true if the
code is being compiled by a C++ compiler (__cplusplus will be defined),
and should be false otherwise.

Some people consider this `embedding C++ code that is normally
filtered-out by the preprocessor' trick as being an ugly hack
that would more rightly be handled by the people trying to use
the C library from C++, and may even say that the right way
of consuming a C library from C++ is to write an opaque shim
C++ library.

Others `suck it up and do the polite thing' (this is the `opinion'
aspect of Kevin's recommendation), bending to the facts that there are
a lot of C++ programmers who think that C++ compilers can `also just
compile C code', and the fact that writing an opaque shim /is/
actually some amount of work.

In reality, C++ *is* `backward compatible with C'... to some extent,
but in a way that's technical and pedantic enough that `backward
compatible with C' doesn't mean what most people would naively
interpret it as meaning (this is the `inflexible you must do this if
you want this to work' part).

You should also avoid using the word class in your C headers
(do not be tempted into naming a struct-member class, for example),
because C++ compilers will likely fail when they see it in a context
that looks nonsensical to them, even if it *is* wrapped in an `extern C'
construct. There are probably some other things of which you should be wary
when writing C headers for use in C++ programs, but the the above issues
are the big ones.

-- 
Don't be afraid to ask (Lf.((Lx.xx) (Lr.f(rr.
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread Kevin D. Clark

bruce.labitt writes:

 I've not seen this type of code before.  I wonder why all of my
 previous code even works.  Surely it is a way to do it.  Is there a
 simpler way?  (Not that the above is hard by any means.)

Can you tell us, which books on C and C++ do you have in
your work area right now?

Thanks,

--kevin
-- 
GnuPG ID: B280F24EGod, I loved that Pontiac.
alumni.unh.edu!kdc-- Tom Waits
http://kdc-blog.blogspot.com/ 
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread bruce . labitt
peter.dobr...@gmail.com wrote on 09/18/2009 02:52:40 PM:

  #ifndef UTIL_H
  #define UTIL_H
 
  #ifdef __cplusplus
  extern C {
  #endif
 
 
  void some_function_with_c_linkage();
 
  #ifdef __cplusplus
  }
  #endif
 
  #endif  /* UTIL_H */
 
 
  Could you explain why this is necessary, and what it does?  What is
  necessary to use this?
 
 C compilers do not name mangle symbols in the way that C++ compilers 
do.
 
 http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%
 2B#Linking_C_and_C.2B.2B_code
 
 Basically, C++ supports function overloading (two functions with the
 same name that differ only in argument lists).  The actual name of the
 function that is used by the linker has an encoded version of both the
 function name and its argument types in it.  However, C does not need
 the same kind of name changing behavior because it doesn't support
 function overloading.
 
 --Peter

Thanks everyone!  That was helpful.  Now on to debugging my python-client 
/ C++-server application.  At least the sockets parts works.  Too bad I'm 
reading the data from la-la land.  Got to fix that...

Oh yeah, and I have to go back to some of my old apps and put this in. 
Don't know why I was lucky then...

-Bruce




**
Neither the footer nor anything else in this E-mail is intended to or 
constitutes an brelectronic signature and/or legally binding agreement in the 
absence of an brexpress statement or Autoliv policy and/or procedure to the 
contrary.brThis E-mail and any attachments hereto are Autoliv property and 
may contain legally brprivileged, confidential and/or proprietary 
information.brThe recipient of this E-mail is prohibited from distributing, 
copying, forwarding or in any way brdisseminating any material contained 
within this E-mail without prior written brpermission from the author. If you 
receive this E-mail in error, please brimmediately notify the author and 
delete this E-mail.  Autoliv disclaims all brresponsibility and liability for 
the consequences of any person who fails to brabide by the terms herein. br
**

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread bruce . labitt
gnhlug-discuss-boun...@mail.gnhlug.org wrote on 09/18/2009 03:23:14 PM:

 
 bruce.labitt writes:
 
  I've not seen this type of code before.  I wonder why all of my
  previous code even works.  Surely it is a way to do it.  Is there a
  simpler way?  (Not that the above is hard by any means.)
 
 Can you tell us, which books on C and C++ do you have in
 your work area right now?
 

That's easy.  Nada.  I do have a copy of KR C book at home.  Someone here 
has some C++ books, though I haven't looked at them. 

I look up a lot of stuff at www.cplusplus.com

For the most part, I have found C++ rather opaque.  Read that to mean most 
books that I looked at were terrible.  Put me to sleep in less than 5 
minutes - really boring.  Although, to be fair, maybe I wasn't 'ready' to 
take on OOP and C++ at the same time.

Now that I have some (ok, a little) object oriented experience in python, 
tackling C++ doesn't quite seem as bad.  Many of the concepts transfer 
over.  Though I have to admit, C++ makes for much crappier reading code 
and you have to work a lot harder at it...  Jeesh, freaking friends...

If people know of some readable C++ texts, let me know.  It wouldn't hurt 
to have a good book around!

Regards,
Bruce




**
Neither the footer nor anything else in this E-mail is intended to or 
constitutes an brelectronic signature and/or legally binding agreement in the 
absence of an brexpress statement or Autoliv policy and/or procedure to the 
contrary.brThis E-mail and any attachments hereto are Autoliv property and 
may contain legally brprivileged, confidential and/or proprietary 
information.brThe recipient of this E-mail is prohibited from distributing, 
copying, forwarding or in any way brdisseminating any material contained 
within this E-mail without prior written brpermission from the author. If you 
receive this E-mail in error, please brimmediately notify the author and 
delete this E-mail.  Autoliv disclaims all brresponsibility and liability for 
the consequences of any person who fails to brabide by the terms herein. br
**

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-18 Thread Kevin D. Clark

bruce.lab...@autoliv.com writes:
 Kevin Clark wrote:
  bruce.labitt writes:
  
   I've not seen this type of code before.  I wonder why all of my
   previous code even works.  Surely it is a way to do it.  Is there a
   simpler way?  (Not that the above is hard by any means.)
  
  Can you tell us, which books on C and C++ do you have in
  your work area right now?
 
 That's easy.  Nada.  I do have a copy of KR C book at home.  Someone here 
 has some C++ books, though I haven't looked at them. 

*plonk*

--kevin
-- 
GnuPG ID: B280F24EGod, I loved that Pontiac.
alumni.unh.edu!kdc-- Tom Waits
http://kdc-blog.blogspot.com/ 
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-17 Thread Lloyd Kvam
On Wed, 2009-09-16 at 23:28 -0400, Kevin D. Clark wrote:
 Look, I could write a big writeup here, giving you a complete example
 of a Makefile that is similar to what I know you are looking for, but
 in actuality let me just tell you that I happen to be a big fan of the
 GNU Make manual.  I think that in 20 minutes of skimming you'll be
 well on your way.

I also like the GNU Make manual, but I found it vary hard to use when
first learning make.  Once you have a bit of feel for what you are doing
the manual is clear and concise.
http://www.gnu.org/software/make/

The art of UNIX Programming (in the library thanks to Ted Roche) has a
section in the tools chapter on make, but that's a higher level
discussion and not a tutorial.  Eric Raymond recommends studying the
fetchmail make file as a useful example.

Years ago, Jason Stephenson and Dave Johnson were very helpful to me
when I posted a request for help writing a makefile.  I'm sure you'll
get some good advice here.

-- 
Lloyd Kvam
Venix Corp
DLSLUG/GNHLUG library
http://dlslug.org/library.html
http://www.librarything.com/catalog/dlslug
http://www.librarything.com/rsshtml/recent/dlslug
http://www.librarything.com/rss/recent/dlslug

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-17 Thread bruce . labitt
 On Wed, 2009-09-16 at 23:28 -0400, Kevin D. Clark wrote:
  Look, I could write a big writeup here, giving you a complete example
  of a Makefile that is similar to what I know you are looking for, but
  in actuality let me just tell you that I happen to be a big fan of the
  GNU Make manual.  I think that in 20 minutes of skimming you'll be
  well on your way.
 
 Lloyd Kvam
 I also like the GNU Make manual, but I found it vary hard to use when
 first learning make.  Once you have a bit of feel for what you are doing
 the manual is clear and concise.
 http://www.gnu.org/software/make/
 

It is hard to 'skim' 182 pages. :0

Nonetheless, allow me to ask for a critique (do I dare?) for this 
construct:

CC=g++
CCOPTS=
INCLUDES=
DEPS=

%.o: %.cpp $(DEPS)
$(CC) -c $ $(CCOPTS) $(INCLUDES)

This will process all .cpp files with the rule?

Can I just add this?

%.o: %.c $(DEPS)
gcc -c $ $(CCOPTS) $(INCLUDES)



 The art of UNIX Programming (in the library thanks to Ted Roche) has a
 section in the tools chapter on make, but that's a higher level
 discussion and not a tutorial.  Eric Raymond recommends studying the
 fetchmail make file as a useful example.
 

I'll try to find it.

 Years ago, Jason Stephenson and Dave Johnson were very helpful to me
 when I posted a request for help writing a makefile.  I'm sure you'll
 get some good advice here.
 

I need it!

-Bruce


**
Neither the footer nor anything else in this E-mail is intended to or 
constitutes an brelectronic signature and/or legally binding agreement in the 
absence of an brexpress statement or Autoliv policy and/or procedure to the 
contrary.brThis E-mail and any attachments hereto are Autoliv property and 
may contain legally brprivileged, confidential and/or proprietary 
information.brThe recipient of this E-mail is prohibited from distributing, 
copying, forwarding or in any way brdisseminating any material contained 
within this E-mail without prior written brpermission from the author. If you 
receive this E-mail in error, please brimmediately notify the author and 
delete this E-mail.  Autoliv disclaims all brresponsibility and liability for 
the consequences of any person who fails to brabide by the terms herein. br
**

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-17 Thread Derek Atkins
bruce.lab...@autoliv.com writes:

 On Wed, 2009-09-16 at 23:28 -0400, Kevin D. Clark wrote:
  Look, I could write a big writeup here, giving you a complete example
  of a Makefile that is similar to what I know you are looking for, but
  in actuality let me just tell you that I happen to be a big fan of the
  GNU Make manual.  I think that in 20 minutes of skimming you'll be
  well on your way.
 
 Lloyd Kvam
 I also like the GNU Make manual, but I found it vary hard to use when
 first learning make.  Once you have a bit of feel for what you are doing
 the manual is clear and concise.
 http://www.gnu.org/software/make/
 

 It is hard to 'skim' 182 pages. :0

 Nonetheless, allow me to ask for a critique (do I dare?) for this 
 construct:

 CC=g++
 CCOPTS=
 INCLUDES=
 DEPS=

 %.o: %.cpp $(DEPS)
 $(CC) -c $ $(CCOPTS) $(INCLUDES)

 This will process all .cpp files with the rule?

But it would also process all .c files with g++ which probably isn't
what you want.

 Can I just add this?

 %.o: %.c $(DEPS)
 gcc -c $ $(CCOPTS) $(INCLUDES)

You could, but why not just use:

CXX=g++
CC=gcc

???

-derek

-- 
   Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
   Member, MIT Student Information Processing Board  (SIPB)
   URL: http://web.mit.edu/warlord/PP-ASEL-IA N1NWH
   warl...@mit.eduPGP key available
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-17 Thread bruce . labitt
Derek Atkins warl...@mit.edu wrote on 09/17/2009 10:25:44 AM:

 bruce.lab...@autoliv.com writes:
 
 
  Nonetheless, allow me to ask for a critique (do I dare?) for this 
  construct:
 
  CC=g++
  CCOPTS=
  INCLUDES=
  DEPS=
 
  %.o: %.cpp $(DEPS)
  $(CC) -c $ $(CCOPTS) $(INCLUDES)
 
  This will process all .cpp files with the rule?
 
 But it would also process all .c files with g++ which probably isn't
 what you want.
 
  Can I just add this?
 
  %.o: %.c $(DEPS)
  gcc -c $ $(CCOPTS) $(INCLUDES)
 
 You could, but why not just use:
 
 CXX=g++
 CC=gcc
 

I am confused by your confusion... Perhaps, I've not framed the situation 
properly.
There are two files that need to be compiled with gcc, and five with g++.

One could set up two objects lists,

OBJ1=file1.o file2.o== use gcc
OBJ2=file3.o file4.o file5.o file6.o file7.o== use g++
SRC1=file1.c file2.c
SRC2=file3.cpp file4.cpp file5.cpp file6.cpp file7.cpp
CXX=g++
CC=gcc
CCOPTS=
INCLUDES=
DEPS=

I'm trying, quite unsucessfully, I may add, to design a rule that compiles 
things appropriately.

Might this work?

project: $(OBJS1) $(OBJ2)
$(CXX) -o project $(OBJ1) $(OBJ2) $(LIBS)

$(OBJ1): $(SRC1) $(DEPS)
$(CC) -c $ $(CCOPTS) $(INCLUDES)

$(OBJ2): $(SRC2) $(DEPS)
$(CXX) -c $ $(CCOPTS) $(INCLUDES)


 ???
 
 -derek
 
 -- 
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board  (SIPB)
URL: http://web.mit.edu/warlord/PP-ASEL-IA N1NWH
warl...@mit.eduPGP key available


**
Neither the footer nor anything else in this E-mail is intended to or 
constitutes an brelectronic signature and/or legally binding agreement in the 
absence of an brexpress statement or Autoliv policy and/or procedure to the 
contrary.brThis E-mail and any attachments hereto are Autoliv property and 
may contain legally brprivileged, confidential and/or proprietary 
information.brThe recipient of this E-mail is prohibited from distributing, 
copying, forwarding or in any way brdisseminating any material contained 
within this E-mail without prior written brpermission from the author. If you 
receive this E-mail in error, please brimmediately notify the author and 
delete this E-mail.  Autoliv disclaims all brresponsibility and liability for 
the consequences of any person who fails to brabide by the terms herein. br
**

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-17 Thread Kevin D. Clark

bruce.lab...@autoliv.com writes:

 There are two files that need to be compiled with gcc, and five with g++.

(completely un-tested)

MYFLAGS=-g -Werror -Wall -Wcast-qual
CFLAGS=$(MYFLAGS)
CXXFLAGS=$(MYFLAGS)

# we define _XOPEN_SOURCE because
# we define _GNU_SOURCE because 
# modify to suit to your situation
CPPFLAGS=-D_XOPEN_SOURCE=500 -D_GNU_SOURCE

# file1 and file2 are C files, the rest are C++ files
OBJS=file1.o file2.o file3.o file4.o file5.o file6.o file7.o

.PHONY: all clean war

all: myproject

clean: $(RM) $(OBJS) myproject.o

myproject: myproject.o $(OBJS)
$(CXX) $(CXXFLAGS) $+ -o $@ $(LDFLAGS)

war:
@echo make love not war



Hope this helps,

--kevin
-- 
GnuPG ID: B280F24EGod, I loved that Pontiac.
alumni.unh.edu!kdc-- Tom Waits
http://kdc-blog.blogspot.com/ 
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-17 Thread bruce . labitt
kevin_d_cl...@comcast.net (Kevin D. Clark) wrote on 09/17/2009 12:03:20 
PM:

 
 bruce.lab...@autoliv.com writes:
 
  There are two files that need to be compiled with gcc, and five with 
g++.
 
 (completely un-tested)
 
 MYFLAGS=-g -Werror -Wall -Wcast-qual
 CFLAGS=$(MYFLAGS)
 CXXFLAGS=$(MYFLAGS)
 
 # we define _XOPEN_SOURCE because
 # we define _GNU_SOURCE because 
 # modify to suit to your situation
 CPPFLAGS=-D_XOPEN_SOURCE=500 -D_GNU_SOURCE

where are CPPFLAGS used below?

 
 # file1 and file2 are C files, the rest are C++ files
 OBJS=file1.o file2.o file3.o file4.o file5.o file6.o file7.o
 
 .PHONY: all clean war
 
 all: myproject
 
 clean: $(RM) $(OBJS) myproject.o
 
 myproject: myproject.o $(OBJS)
 $(CXX) $(CXXFLAGS) $+ -o $@ $(LDFLAGS)
 
 war:
 @echo make love not war
 
 

How is CXX defined?  Will this automagically select gcc for *.c and g++ 
for *.cpp?
How can the dependencies (header files) be pulled in?

 
 Hope this helps,
 
 --kevin
 -- 
 GnuPG ID: B280F24EGod, I loved that Pontiac.
 alumni.unh.edu!kdc-- Tom Waits
 http://kdc-blog.blogspot.com/ 


**
Neither the footer nor anything else in this E-mail is intended to or 
constitutes an brelectronic signature and/or legally binding agreement in the 
absence of an brexpress statement or Autoliv policy and/or procedure to the 
contrary.brThis E-mail and any attachments hereto are Autoliv property and 
may contain legally brprivileged, confidential and/or proprietary 
information.brThe recipient of this E-mail is prohibited from distributing, 
copying, forwarding or in any way brdisseminating any material contained 
within this E-mail without prior written brpermission from the author. If you 
receive this E-mail in error, please brimmediately notify the author and 
delete this E-mail.  Autoliv disclaims all brresponsibility and liability for 
the consequences of any person who fails to brabide by the terms herein. br
**

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-17 Thread Kevin D. Clark

bruce.labitt writes:

 Kevin D. Clark wrote on 09/17/2009 12:03:20 PM:

  # we define _XOPEN_SOURCE because
  # we define _GNU_SOURCE because 
  # modify to suit to your situation
  CPPFLAGS=-D_XOPEN_SOURCE=500 -D_GNU_SOURCE
 
 where are CPPFLAGS used below?

They're not ; my example relies upon GNU Make's well known implicit
rules, documented here:

http://www.gnu.org/software/make/manual/make.html#Catalogue-of-Rules

 How is CXX defined?  Will this automagically select gcc for *.c and g++ 
 for *.cpp?

  $ cat ~/Makefile.test 
  
  all:
  @echo CC is $(CC) and CXX is $(CXX)
  $ make -f ~/Makefile.test
  CC is cc and CXX is g++
  $ cc -v ...


 How can the dependencies (header files) be pulled in?

That is harder to do.  gcc -M might do a large part of what you are
looking for.  You'll need to get very adept at these things in order to
make this aspect work.

--kevin
-- 
GnuPG ID: B280F24EGod, I loved that Pontiac.
alumni.unh.edu!kdc-- Tom Waits
http://kdc-blog.blogspot.com/ 
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-17 Thread Joshua Judson Rosen
bruce.lab...@autoliv.com writes:

 There are two files that need to be compiled with gcc, and five with g++.
 
 One could set up two objects lists,
 
 OBJ1=file1.o file2.o== use gcc
 OBJ2=file3.o file4.o file5.o file6.o file7.o== use g++
 SRC1=file1.c file2.c
 SRC2=file3.cpp file4.cpp file5.cpp file6.cpp file7.cpp
 CXX=g++
 CC=gcc
 CCOPTS=
 INCLUDES=
 DEPS=
 
 I'm trying, quite unsucessfully, I may add, to design a rule that compiles 
 things appropriately.
 
 Might this work?
 
 project: $(OBJS1) $(OBJ2)
 $(CXX) -o project $(OBJ1) $(OBJ2) $(LIBS)
 
 $(OBJ1): $(SRC1) $(DEPS)
 $(CC) -c $ $(CCOPTS) $(INCLUDES)
 
 $(OBJ2): $(SRC2) $(DEPS)
 $(CXX) -c $ $(CCOPTS) $(INCLUDES)

I'm a big fan of the GNU Autotools (Automake, Autoconf, Libtool);
doing it that way, you'd have something like the following two files
(which you can drop into the directory with your code, and then
initialise by running autoreconf --install):

# This is Makefile.am:

bin_PROGRAMS = project

project_SOURCES = file1.c file2.c \
file3.cpp file4.cpp file5.cpp file6.cpp file7.cpp
# (NOTE: project_SOURCES should also include
#  any corresponding header-files)

project_LDADD = -lfftw3 # ... since I hear you're using that...

# This is configure.ac (usually drafted by running autoscan):

AC_PREREQ([2.59])
AC_INIT([bl-project], [0.1], [bruce.lab...@autoliv.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
LT_INIT

AC_PROG_CC
AC_PROG_CXX

AC_CONFIG_SRCDIR([1.c])

AC_CONFIG_FILES([Makefile])

AC_OUTPUT
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Make Q's

2009-09-16 Thread Bruce Labitt
I made a make file for my project.  It was kind of ugly, but it nearly 
works...  First moderately complicated make I've done.

Three questions:
1.  Is it possible to have a project that some files are compiled with 
g++ and others gcc? 
2.  In the link phase one needs to use g++, correct?
3.  Is there a way to automate the compilation so that the *.c files get 
compiled by gcc and the *.cpp by g++?

Hmm, one more question.  Anyone have a favorite writeup or tutorial on 
make?  Google reveals lots of them - most are trivial.  I had one that 
was pretty good, but somehow have misplaced the URL.

TIA
-Bruce

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: Make Q's

2009-09-16 Thread Kevin D. Clark

Bruce Labitt writes:

 Three questions:
 1.  Is it possible to have a project that some files are compiled with 
 g++ and others gcc? 

Yes.  I do this all the time.

 2.  In the link phase one needs to use g++, correct?

Yes, if you are trying to link together a collection of C and C++
files and produce an executable from these.

 3.  Is there a way to automate the compilation so that the *.c files get 
 compiled by gcc and the *.cpp by g++?

Yes.  This a good idea to setup, IMHO.

 Hmm, one more question.  Anyone have a favorite writeup or tutorial on 
 make?  Google reveals lots of them - most are trivial.  I had one that 
 was pretty good, but somehow have misplaced the URL.

Look, I could write a big writeup here, giving you a complete example
of a Makefile that is similar to what I know you are looking for, but
in actuality let me just tell you that I happen to be a big fan of the
GNU Make manual.  I think that in 20 minutes of skimming you'll be
well on your way.

Regards,

--kevin
-- 
GnuPG ID: B280F24EGod, I loved that Pontiac.
alumni.unh.edu!kdc-- Tom Waits
http://kdc-blog.blogspot.com/ 
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/