When I try to compile in windows with same command:
error: unrecognized option '-zmuldefs'
Uh oh... Why!??I use same code and same command!!!
The game compile and run all right in linux but not windows.Why!???!?!?!??!?
I don't post it here because it is too big...
Using it indicates that there is a problem with your source code and/or build system. Try to write your code so that you don't need the -z option and then try compiling on Windows again.
Thanks for your help but That way not work...sorry for that :(
I got many multiple definition error after use that way...
The -Xlinker -zmuldefs is required because I got same error in linux when I compile without -Xlinker -zmuldefs
Is there any command that can replace -Xlinker -zmuldefs ??
And how to write the code that con compile without -z option?
As I understand it, the linker's 'ignore multiple definitions' option exists to make Solaris behave when compiling statically-linked binaries -- because Sun's build system is screwed-up.
You aren't compiling with static libs. Where are you getting multiple definition errors?
multiple definition of 'ammo'
first definied here
multiple definition of 'shooter'
first definied here
multiple definition of 'enemy'
first definied here
multiple definition of 'shooter'
first definied here
--!!very long!!--
I don't know why...I only know I got same error when I compile this game in linux without "-Xlinker -zmuldefs" command
Is there anyway to add -z command to windows?Is there another way to solve this problem?
// foo.hpp
// Copyright, license, and other commentary goes here.
#pragma once
#ifndef A20365354_FOO_HPP
#define A20365354_FOO_HPP
#include <stuff>
namespace foo
{
bool bar( int a, int b );
class baz
{
int quux( int x )
};
} // namespace foo
#endif
// foo.cpp
// Copyright, license, and other commentary goes here. (The same as before.)
#include <more-stuff>
#include "foo.hpp"
namespace foo
{
bool bar( int a, int b )
{
return a < b;
}
int baz::quux( int x )
{
...
}
}
main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
...
#include "foo.hpp"
usingnamespace std; // if you want to do this
usingnamespace foo; // likewise, if you want to do this
int main()
{
baz b;
cout << bar( b.quux( 42 ), -7 ) << endl;
return 0;
}
Notice how the header files (.h and .hpp) have the guards in place so that you can #include them as often as you like without introducing multiple symbols.
Likewise, the header files only declare, or prototype, stuff. The source files (.cpp) #include what they need, and define, or actually create, stuff.
In the main program source, you can #include everything you need (prototyped via inclusion, defined elsewhere) and use it that way.
Then, when linking, all the separate source files (.cpp) are connected so that the program has all its parts.
/tmp/ccdEfgP5.o:(.bss+0x2f8): first defined here
/tmp/ccrdZjmP.o:(.bss+0x0): multiple definition of `ammo_clip'
/tmp/ccdEfgP5.o:(.bss+0x0): first defined here
/tmp/ccrdZjmP.o:(.bss+0x100): multiple definition of `healbar_clip'
/tmp/ccdEfgP5.o:(.bss+0x100): first defined here
/tmp/ccrdZjmP.o:(.bss+0x120): multiple definition of `shooter_clip'
/tmp/ccdEfgP5.o:(.bss+0x120): first defined here
/tmp/ccrdZjmP.o:(.bss+0x220): multiple definition of `number'
/tmp/ccdEfgP5.o:(.bss+0x220): first defined here
/tmp/ccrdZjmP.o:(.bss+0x270): multiple definition of `selecticon'
/tmp/ccdEfgP5.o:(.bss+0x270): first defined here
/tmp/ccrdZjmP.o:(.bss+0x278): multiple definition of `start'
/tmp/ccdEfgP5.o:(.bss+0x278): first defined here
/tmp/ccrdZjmP.o:(.bss+0x280): multiple definition of `generation'
/tmp/ccdEfgP5.o:(.bss+0x280): first defined here
/tmp/ccrdZjmP.o:(.bss+0x288): multiple definition of `level'
/tmp/ccdEfgP5.o:(.bss+0x288): first defined here
/tmp/ccrdZjmP.o:(.bss+0x290): multiple definition of `latest_level'
/tmp/ccdEfgP5.o:(.bss+0x290): first defined here
/tmp/ccrdZjmP.o:(.bss+0x298): multiple definition of `quit'
/tmp/ccdEfgP5.o:(.bss+0x298): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2a0): multiple definition of `yourock'
/tmp/ccdEfgP5.o:(.bss+0x2a0): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2a8): multiple definition of `gameover'
/tmp/ccdEfgP5.o:(.bss+0x2a8): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2b0): multiple definition of `lifes'
/tmp/ccdEfgP5.o:(.bss+0x2b0): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2b8): multiple definition of `life_icon'
/tmp/ccdEfgP5.o:(.bss+0x2b8): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2c0): multiple definition of `process'
/tmp/ccdEfgP5.o:(.bss+0x2c0): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2c8): multiple definition of `nextlevel'
/tmp/ccdEfgP5.o:(.bss+0x2c8): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2d0): multiple definition of `back'
/tmp/ccdEfgP5.o:(.bss+0x2d0): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2d8): multiple definition of `ammo'
/tmp/ccdEfgP5.o:(.bss+0x2d8): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2dc): multiple definition of `healbar'
/tmp/ccdEfgP5.o:(.bss+0x2dc): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2e8): multiple definition of `lifes_icon'
/tmp/ccdEfgP5.o:(.bss+0x2e8): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2e0): multiple definition of `morisermode'
/tmp/ccdEfgP5.o:(.bss+0x2e0): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2e4): multiple definition of `select_icon'
/tmp/ccdEfgP5.o:(.bss+0x2e4): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2ec): multiple definition of `shooter'
/tmp/ccdEfgP5.o:(.bss+0x2ec): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2f4): multiple definition of `text'
/tmp/ccdEfgP5.o:(.bss+0x2f4): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2f0): multiple definition of `screen'
/tmp/ccdEfgP5.o:(.bss+0x2f0): first defined here
/tmp/ccrdZjmP.o:(.bss+0x2f8): multiple definition of `Quit'
/tmp/ccdEfgP5.o:(.bss+0x2f8): first defined here
and much more...
Yu-ho! It's work!!!Thanks!kbw! :):):):):):)
Also thanks to Duoas because he/she told me "The -z linker option is not valid on Windows." and gave me the solution( even it not work )