"k0mp" <[EMAIL PROTECTED]> writes:

> I've got a problem to compile my program (on Linux).

No, you didn't. You got a problem *linking* your program.

> /tmp/ccfRzJFM.o:(.bss+0x40): multiple definition of `program_name'

The problem is as follows: in eht_lib.h, you have:

  char *program_name;

When any file including this header is compiled, it gets a
*definition* of "program_name":

  g++ -c test.cc eth_lib.cc
  nm -A test.o eth_lib.o | grep ' program_name'

test.o:00000000 B program_name
eth_lib.o:00000000 B program_name

So you have two definitions, but you can have at most *one* such
definition.

To correct this, change 'char *program_name;' to 
'extern char *program_name;' in the eth_lib.h and add
'char *program_name;' to the eth_lib.cc. 

This way there will be one definition in eth_lib.o, and all other
uses will result in a reference to that one-and-only definition.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to