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 8147015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:12:16+00:00 2026-06-06T14:12:16+00:00

I got an app that links to boost_program_options, whose CMakeLists.txt looks like FIND_PACKAGE(Boost COMPONENTS

  • 0

I got an app that links to boost_program_options, whose CMakeLists.txt looks like

FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES( ${SUBPROJECT_NAME} ${Boost_LIBRARIES} )

I use #define BOOST_ALL_NO_LIB in my code before including <boost/program_options.hpp> to disable the automatic linking of boost in vs2010, because I want to specify that by cmake to make it compatible with linux.

In Linux, this code compiles just fine (with cmake, make and gcc).
But in Windows with VS2010, I get a

2>App.obj : error LNK2001: unresolved external symbol "public: static unsigned int const boost::program_options::options_description::m_default_line_length" (?m_default_line_length@options_description@program_options@boost@@2IB)
2>App.obj : error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > boost::program_options::arg" (?arg@program_options@boost@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

Note that the linker finds the lib – if it didn’t find it, I would get many more unresolved external errors.

I tracked the problem down to the following:
http://lists.boost.org/boost-users/2009/11/54015.php which very nicely describes what’s going on (those two are global variables). Now the proposed solution there is to enable dynamic linking and link to the DLLs. But that is not what I’d like to do, I would like to link against the static boost lib (which I’m actually trying to do, in the App properties in VS under Linker->Input it lists D:\boost\boost_1_47\lib\boost_program_options-vc100-mt-gd-1_47.lib.

I also tried adding

set(Boost_USE_STATIC_LIBS        ON)
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)

to my CMakeLists.txt but it doesn’t change anything.

Any ideas how to solve this problem?

Update:
When linking with boost_program_options-vc100-mt-sgd-1_47.lib, I get a whole bunch of new linker errors about CRT-symbols being already defined in the boost-lib.
After changing the VS Runtime options as suggested by panickal, those errors are also gone and it’s working.

  • 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-06T14:12:18+00:00Added an answer on June 6, 2026 at 2:12 pm

    You have to link to the static library. Try linking to boost_program_options-vc100-mt-sgd-1_47.lib instead of boost_program_options-vc100-mt-gd-1_47.lib.

    The s indicates the static version of the library. You can check Boost Library Naming for more details about the naming conventions.

    Update:
    To fix the multiple definition linker errors, change the Visual Studio Runtime Library option in Configuration Properties / C/C++ / Code Generation / Runtime Library from Multi-threaded Debug DLL (/MDd) to Multi-threaded Debug (/MTd).

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

Sidebar

Related Questions

I've got a console app that loads up a datatable; I'd like to export
I've got a web app that I deploy to several applications like so- https://customerinternaldomain.com/thewebapp
I've got an iOS app that links to 15 Apple frameworks (including the ~3
I've got an app that will be doing a fair amount of communication with
I've got an app that's working pretty flawlessly in Chrome and FF, however, when
I've got an app that's in invite-only beta right now. Problem is, I can't
I've got an app that is heavily based on remote images. They are usually
I've got an app that uses MapView and I print out the user's latitude,
I've got an app that has a map with pins for locations, but I
I have an app that requires user to register. I've got the app conected

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.