link issue with whole-archive & no-whole_archive options

c++, g++, gcc, static-libraries

Solution

Have you tried using the following syntax?

-Wl,--whole-archive

I.e., no space after the comma and two dashes.

Problem

I tried to use `-whole-archive`/`-no-whole-archive` options for linking. The gcc is 4.1.2. when I try: ``` g++ ...... -Wl, -whole-archive libA.a -Wl, -no-whole-archive libB.a ... ``` It says `-whole-archive` and `-no-whole-archive` are unrecognized. When I replace `-whole-archive` with `--whole-archive`, and same to `no-whole-archive`, it says ``` error: unrecognized command line option "-fwhole-archive" error: unrecognized command line option "-fno-whole-archive" ``` Does anyone know where the problem comes from?

Original source