https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109389
Bug ID: 109389 Summary: g++ file.cpp -lgmp (option only works after filename) Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: frechbengel at gmx dot de Target Milestone: --- Hello, 1. »g++ --version« outputs: g++ (Debian 10.2.1-6) 10.2.1 20210110 2. »g++ --help« says: Usage: g++ [options] file... 3. But if I try to compile: #include <gmp.h> int main(){ mpz_t n; mpz_init(n); mpz_clear(n); return 0;} 4. with »g++ -lgmp file.cpp« the error is: /usr/bin/ld: /tmp/cc8lgHAc.o: in function `main': guard_driver.cpp:(.text+0x10): undefined reference to `__gmpz_init' /usr/bin/ld: guard_driver.cpp:(.text+0x21): undefined reference to `__gmpz_set_ui' /usr/bin/ld: guard_driver.cpp:(.text+0x34): undefined reference to `operator<<(std::ostream&, __mpz_struct const*)' /usr/bin/ld: guard_driver.cpp:(.text+0x55): undefined reference to `__gmpz_clear' collect2: error: ld returned 1 exit status 5. There is no error if I compile with: »g++ file.cpp -lgmp« 6. As the --help says the options should be given BEFORE the filename it is a feature if it works with options given after the filename, too. But I is propably a bug that compilation only works with the option given after the filename. Regards and thank you for you valuable work Bernd