Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I saw this guide for configuring boost on VS 2010: How to use Boost in Visual Studio 2010.[^]
I did exactly what was wrriten (on 64 bit), but changed in (4) to
toolset=msvc-14.0
than I tried building this program from boost getting started web:

C++
#include "stdafx.h"          
#include <boost/regex.hpp>
#include <iostream>
#include <string>

int main()
{
std::string line;
boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" );

while (std::cin)
{
    std::getline(std::cin, line);
    boost::smatch matches;
    if (boost::regex_match(line, matches, pat))
        std::cout << matches[2] << std::endl;
}
}


but got the error:
Severity Code Description Project File Line Error LNK2019 unresolved external symbol "private: class boost::basic_regex > > & __thiscall boost::basic_regex > >::do_assign(char const *,char const *,unsigned int)" (?do_assign@?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@AAEAAV12@PBD0I@Z) referenced in function "public: class boost::basic_regex > > & __thiscall boost::basic_regex > >::assign(char const *,char const *,unsigned int)" (?assign@?$basic_regex@DU?$regex_traits@DV?$w32_regex_traits@D@boost@@@boost@@@boost@@QAEAAV12@PBD0I@Z) BoostTest C:\Users\shauzer\Documents\Visual Studio 2015\Projects\BoostTest\BoostTest\BoostTest.obj 1

I tried to google it, but havn't found yet something that will fix this problem. how can I solve this?
Posted

1 solution

It seems that you forgot to add the library file to your project.

The file name should be libboost-regex*.lib (* = VC version, single/multi thread, release/debug).

Look it up in your boost library directory and add it to your project at Linker - Input - Additional Dependencies (the debug library name for debug builds and similar for release builds).

[EDIT]
With Visual Studio it is normally not necessary to specify the library itself (but it does not harm). But the path to the boost libraries must be set.

To check if the libraries are found and linked you can add the /VERBOSE option to the linker settings (Project Settings - Linker - Command Line - Add: /VERBOSE) and check the build output.

From your comment I know that you have set the library path to x64. But did you build a 64-bit application? If not, you must set the library path to the 32-bit libraries (<prefix>/boost/lib/i386).
 
Share this answer
 
v2
Comments
Member 12133830 12-Nov-15 16:09pm    
You mean one of those files (that's the closest I got to what you wrote when I searched at the boost directory)?

libboost_regex-vc140-mt-1_59
libboost_regex-vc140-mt-gd-1_59
libboost_regex-vc140-s-1_59
libboost_regex-vc140-sgd-1_59
libboost_regex-vc140-mt-s-1_59
libboost_regex-vc140-mt-sgd-1_59
libboost_regex-vc140-mt-sgd-1_59
libboost_regex-vc140-mt-1_59
libboost_regex-vc140-mt-gd-1_59
libboost_regex-vc140-s-1_59
libboost_regex-vc140-sgd-1_59
libboost_regex-vc140-mt-s-1_59
libboost_regex-vc140-mt-sgd-1_59

well, I tried to add each one of them separately, and for each one of them the LNK 2019 error was solved, but I still get this error:

LNK1104 cannot open file : C:\Boost\lib\x64\libboost_regex-vc140-mt-sgd-1_59


What can I do to solve the LNK1104 error?
Jochen Arndt 13-Nov-15 2:55am    
The error LNK2019 is not solved yet because the error LNK1104 occurs now before the other can occur.

You must add only one library. The one that matches your project build settings. I will update my solution with a description.

Then check the possible LNK1104 causes at https://msdn.microsoft.com/en-us/library/ts7eyw4s.aspx.

Check also that your application is build as 64-bit. If you use a 32-bit build, you must change the additional library path (it is now for the 64-bit libraries). Note that these 32/64 bit refer to the VS build settings and not to your machine being 64-bit.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900