Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8133075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:30:07+00:00 2026-06-06T09:30:07+00:00

I am trying to enable link time optimization in g++. My program compiles fine

  • 0

I am trying to enable link time optimization in g++. My program compiles fine without the -flto option. When I add it to my Makefile the object files compile without errors, e.g.

g++ main.cpp -I ../includes -std=c++0x -fopenmp -Wall -pedantic -Wno-vla -flto -D INFO_ -c -o .obj/main.o

But when it comes to link the program:

g++ -fwhole-program -I ../includes -std=c++0x -fopenmp -Wall -pedantic -Wno-vla -flto -D INFO_ .obj/main.o .obj/atom.o .obj/bee.o .obj/colony.o ../includes/.obj/error.o ../includes/.obj/CmdLine.o ../includes/boost_lib_deb/libboost_program_options.a ../includes/gmp_lib_deb/lib/libgmpxx.a ../includes/gmp_lib_deb/lib/libgmp.a -o BeeBench

I get a lot of errors like these:

includes/gmp_lib_deb/lib/libgmpxx.a ../includes/gmp_lib_deb/lib/libgmp.a -o BeeBench
`typeinfo for boost::program_options::too_many_positional_options_error' referenced in section `.rodata._ZTVN5boost15program_options33too_many_positional_options_errorE[vtable for boost::program_options::too_many_positional_options_error]' of ../includes/boost_lib_deb/libboost_program_options.a(cmdline.o): defined in discarded section `.gnu.linkonce.t._ZTIN5boost15program_options33too_many_positional_options_errorE' of .obj/main.o (symbol from plugin)

`typeinfo for boost::program_options::too_many_positional_options_error' referenced in section `.rodata._ZTIN5boost16exception_detail19error_info_injectorINS_15program_options33too_many_positional_options_errorEEE[typeinfo for boost::exception_detail::error_info_injector<boost::program_options::too_many_positional_options_error>]' of ../includes/boost_lib_deb/libboost_program_options.a(cmdline.o): defined in discarded section `.gnu.linkonce.t._ZTIN5boost15program_options33too_many_positional_options_errorE' of .obj/main.o (symbol from plugin)
`typeinfo for boost::program_options::invalid_command_line_style' referenced in section `.rodata._ZTVN5boost15program_options26invalid_command_line_styleE[vtable for boost::program_options::invalid_command_line_style]' of ../includes/boost_lib_deb/libboost_program_options.a(cmdline.o): defined in discarded section `.gnu.linkonce.t._ZTIN5boost15program_options26invalid_command_line_styleE' of .obj/main.o (symbol from plugin)

I can’t figure out what is going wrong. I compile all my object files using -flto. The libs, namely Boost and GMP, are compiled without -flto option. Is this causing the error? The gcc manual says that its ok to mix object files compiled with & without -flto option. Or am I missing something else, for example what is this plugin the error is speaking about?

I am using G++ 4.6.3 on Debian Wheezy.

UPDATE:

As adviced in the comments I made a minimal example. The code of my test program is only this:

#include "boost/program_options.hpp"

int main ( int argC, char* argV[] )
{
    return 0;
}

When I compile it using:

g++ -o test -I ../includes -Wall -std=c++0x test.cpp -flto -fwhole-program -static

it gives similar errors as described above. If I omit the -static, -flto OR std=c++0x option it compiles without errors. The -fwhole-program option does not change the result. I now also tested with G++ 4.7, same error.

Any suggestions? Is this really a compiler error, or am I still doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:30:09+00:00Added an answer on June 6, 2026 at 9:30 am

    Since I found no evidence, that there is something wrong with my code, I have posted a Boost bugreport. It was reproduced by other boost users as well, therefore I think it is actually a bug within boost or the g++. By now there was no response from the Boost maintainer. I’ll update this post when there is one.

    Update

    It seems like the g++ linker-plugin is causing the problem (Still I have no idea why). Therefore a possible work around is to disable the linker-plugin by using -fno-use-linker-plugin.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to build and link libphp5.so using the --enable-embed configure option, on
I'm using jwplayer nad all works fine. I'm trying to add an external link
I'm trying to enable .htaccess files on a Ubuntu server I set up. I
I am trying to enable SQL Debugging following this link http://msdn.microsoft.com/en-us/library/ms165038%28VS.80%29.aspx but i can't
I' m trying to enable adding/deleting rows to/from table using folowing code: Script: $(document).ready(function()
I'm trying to enable Expires headers for images as recommended by YSlow. I'm sure
I am trying to enable an additional net.tcp endpoint (which uses Username authentication) for
I'm trying to enable dynamic fields in the configuration file for my mapping app,
I am trying to enable JavaScript in a Joomla template to behave differently depending
I'm trying to enable Ruby via the plugin manager, and I receive the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.