Krumelur
Krumelur

Reputation: 32497

Force ignore duplicate symbols?

I am building some legacy code from projects that uses static libraries. Now, I get lots of errors like this:

ld: warning: option -m is obsolete and being ignored
ld: duplicate symbol <function name>

Is there a way to force through the build. From what I can see the "duplicate" functions are identical, it's just the build process thats gone haywire. The project is really large (and a mess of legacy c and c++ code) and I really want to avoid spending hours investigating the build process. Is there a "quick fix"? I really only need to run this program once, so I can live with (some) stability issues.

Upvotes: 12

Views: 9636

Answers (3)

rboy
rboy

Reputation: 2165

If you're using MinGW-W64 then you can use the ld option

LDFLAGS="-Wl,-allow-multiple-definition"

Upvotes: 1

Thomas Leonard
Thomas Leonard

Reputation: 7196

From the GNU ld man-page:

       --allow-multiple-definition
       -z muldefs
           Normally when a symbol is defined multiple times, the linker will
           report a fatal error. These options allow multiple definitions and
           the first definition will be used.

Upvotes: 7

pmg
pmg

Reputation: 108988

A search in man ld (for "duplicate"), on my system, brought this up:

   --traditional-format
       For some targets, the output of ld is different in some ways from
       the output of some existing linker.  This switch requests ld to use
       the traditional format instead.

       For example, on SunOS, ld combines duplicate entries in the symbol
       string table.  This can reduce the size of an output file with full
       debugging information by over 30 percent.  Unfortunately, the SunOS
       "dbx" program can not read the resulting program ("gdb" has no
       trouble).  The --traditional-format switch tells ld to not combine
       duplicate entries.

Try it. Maybe it solves your problem.

Upvotes: 1

Related Questions