I read through the boost documentation using the '5.3.4 Invoke b2' and followed up with forum threads that explained details of linking the boost library to the header and linker directories, in the boost help '4.1 Build From the Visual Studio IDE', and found this cool boost related wiki that explained the bjam.exe controls.
placed #include <boost/thread/thread.hpp> in the main.cpp
And, I get this linker error, and the existing help threads have identified the problem is with x64:
Directory path and x32/x64
unrelated to Visual studio
unresolved
The error:
error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category#system#boost##YAAEBVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category#system#boost##YAXXZ) main.obj
error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category#system#boost##YAAEBVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat#system#boost##YAXXZ) main.obj
they are similar, something about 'posix_category' and something about 'native_ecat'
So, I tried to build the x64 boost library, and found conflicting instructions on where to put these:
did not say "Note for x64 users: Add the address-model=64 option to bjam (after the threading argument) in order to build static libs with the 64-bit compiler."
cant find the link but one said to place x64 lib in the vs2008 bin?
Also, I tried changing the vs2008 configuration back to x32 -> solutionExplorer/solution_properties/configuration_manager/active_solution_platform - Win32, closed and reopened visual studio - relinked the additional directories C/C++/general and Linker/general to Boost/root and Boost/stage/lib - and it compiled without error.
My best guess at the b2 commands is --toolset=msvc-9.0 address-model=64 --build-type=complete --stagedir=lib\x64 stage
Please give concise instructions for how to build and install x64 version of boost on VS2008. Also, what was the wiki talking about for release and debug - they are not in Boost invocation?
use c++ 11
It more or less includes all the features of boost I wanted to use, also compiles in g++ without figuring out how to build the boost library on my university server and then reference into a remote g++ build - pretty much solved everything with that
Related
Attempting to link in libyaml (0.2.5) using Visual Studio 2019 Enterprise and CMake, as I have a cross-platform (Linux/Windows) project that uses this library. According to the documentation, this library should work in Windows 10. It links in just fine on Linux (64-bit machine).
I'm compiling it as a static lib, and it has no issue generating the .lib file. I've copied it to the appropriate location that I'm linking in from my CMakelists.txt, as well as the header.
When I link it in from my project on Windows:
ts.lib(yamlparser.cxx.obj) : error LNK2019: unresolved external symbol __imp_yaml_parser_initialize referenced in function "public: bool __cdecl YAMLParser::parse_cfg(void)" (?parse_cfg#YAMLParser##QEAA_NXZ)
ts.lib(yamlparser.cxx.obj) : error LNK2019: unresolved external symbol __imp_yaml_parser_set_input_file referenced in function "public: bool __cdecl YAMLParser::parse_cfg(void)" (?parse_cfg#YAMLParser##QEAA_NXZ)
ts.lib(yamlparser.cxx.obj) : error LNK2019: unresolved external symbol __imp_yaml_parser_scan referenced in function "public: bool __cdecl YAMLParser::parse_cfg(void)" (?parse_cfg#YAMLParser##QEAA_NXZ)
This is what I'm doing on the CMake side - the very same thing I'm doing to link in my GoogleTest libraries on both Linux and Windows:
if (UNIX)
...
...
else()
set (MY_LIB_DIR "C:/mylib/lib")
set (MY_INCLUDE "C:/mylib/include")
set (YAML_LIB "${MY_LIB_DIR}/yaml.lib")
set (VCPKG_LIBRARY_LINKAGE static)
endif()
include_directories(${MY_INCLUDE})
add_library(ts
...
...
)
add_executable(myexec main.cxx)
target_link_libraries(myexec ts ${YAML_LIB})
VS isn't giving me many clues here except that there's a linkage problem that I can't quite figure out.
Any advice on how I can debug this or what the problem may be?
The __imp was the clue that my code was trying to include the library dynamically... Opening up yaml.h, I noticed that it tries to export from DLL unless YAML_DECLARE_STATIC is defined. Defined this in CMake and my issue is resolved.
I start using vcpkg in my msvc C++ project recently.
I built the boost 1.67 and referred it in my vs project. After I installed vcpkg, I added some lib and vcpkg seems installed another boost for me and link it to my project. Unfortunately, that boost does't work. I am now having tens of error in building project. Most of them are E0145 and LINK2019. I'm new in c++ programming. I want to know how I can use the boost I built instead of the one vcpkg installed for me.
eg. one of the error is because it changes my BOOST_NO_CXX11_CONSTEXPR and try to use constexpr while it's not supported on my pc. The error is:
E0145 member "boost::filesystem::path::separator" may not be initialized c:\Users\admin\Libraries\boost_1_67_0\boost_1_67_0\boost\filesystem\path.hpp 65
this is my own boost file but all refer is to c:\Users\xxx\vcpkg\vcpkg\installed\x86-windows\include\boost\config\detail\suffix.hpp
instead of
C:\Users\xxx\Libraries\boost_1_67_0\boost_1_67_0\include\boost-1_67\boost\config\detail\suffix.hpp
What can I do to correct this?
The file structure of vcpkg-boost is differ from the boost 1.67 I used before. If I replace the files with 1.67 ones, I'm afraid it will be reset when I upgrade the vcpkg and its libraries. Please give me some advice on this.
And I also got error like,
LNK2019 unresolved external symbol "__declspec(dllimport) void __cdecl boost::filesystem::path_traits::convert(char const *,char const *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,class std::codecvt<wchar_t,char,struct _Mbstatet> const &)"......
How can I get around missing boost::throw_exception while building PCL?
I've built PCL on Windows (MSVC 2013) a few times in the past, but I've never see this error. It's been blocking me all today and yesterday:
LNK2019: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception#boost##YAXAEBVexception#std###Z) referenced in function "public: __cdecl boost::detail::shared_count::shared_count<struct pcl::io::ply::ply_parser::list_property<unsigned char,signed char> >(struct pcl::io::ply::ply_parser::list_property<unsigned char,signed char> *)" (??$?0U?$list_property#EC#ply_parser#ply#io#pcl###shared_count#detail#boost##QEAA#PEAU?$list_property#EC#ply_parser#ply#io#pcl###Z) [C:\Users\mrussell\.conan\data\pcl\1.7.2\ntc\stable\build\d63ff451cbfa147e3b952f2f3790530e1116d93c\io\pcl_io_ply.vcxproj]
It appears that BOOST_NO_EXCEPTIONS is set in boost\config\compiler\visualc.hpp, which prevents boost/throw_exception.hpp from defining it.
I've tried to set TPN_WIN32 to /EHsc (see this answer) both through CMake and via the project properties in Visual Studio to no avail, and even tried sneaking a definition into a high level PCL include (see this answer), nothing worked.
My CMake generator is Visual Studio 12 2013 Win64 and my definitions are:
-DBOOST_ROOT:PATH=%CONAN_BOOST%
-DCMAKE_INSTALL_PREFIX=%CONAN_PCL%
-DEIGEN3_DIR:PATH=%CONAN_EIGEN%\share\eigen3\cmake
-DEIGEN_INCLUDE_DIR:PATH=%CONAN_EIGEN%\include\eigen3
-DFLANN_INCLUDE_DIR:PATH=%CONAN_FLANN%\include
-DFLANN_LIBRARY:FILEPATH=%CONAN_FLANN%\lib\libflann_cpp.so
-DQHULL_INCLUDE_DIR:PATH=%CONAN_QHULL%\include
-DQHULL_LIBRARY:FILEPATH=%CONAN_QHULL%\lib\libqhull.so
-DGTEST_ROOT:PATH=%CONAN_GTEST%
-DBUILD_surface_on_nurbs:BOOL=ON
I've tried:
Removing Qt & VTK
With Boost 1.60, 1.66, and 1.59
Linking against a shared and static versions of boost. (PCL does not seem to like shared boost on Windows...)
Attempting to build shared and static versions of PCL
I feel like I'm chasing the wrong thing, or am missing something. Maybe I'm missing a _CPPUNWIND define for exceptions? I'm really just stuck.
TPN_WIN32 is a user defined variable on that post you reference. You need to append /EHsc to your CMAKE_CXX_FLAGS to pass it to the compiler.
Unrelated but really suspicious -DFLANN_LIBRARY:FILEPATH=%CONAN_FLANN%\lib\libflann_cpp.so is a unix dynamic library. You can't link it on windows with MSVC.
I installed and integrated latest version of vcpkg:
e:\work\vcpkg>vcpkg version
Vcpkg package management program version 0.0.65-692a363701156f1bc319306fbde93fb6748325f6
See LICENSE.txt for license information.
e:\work\vcpkg>vcpkg integrate install
Applied user-wide integration for this vcpkg root.
All C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.
I installed google test:
e:\work\vcpkg>vcpkg list
gtest:x64-windows 1.8 GoogleTest and GoogleMock testing frameworks.
gtest:x86-windows 1.8 GoogleTest and GoogleMock testing frameworks.
I included gtest.h in my project in Visual Studio 2015 Update 3:
#include <gtest/gtest.h>
It compiles fine, but I have linker errors:
1>main.obj : error LNK2001: unresolved external symbol "void __cdecl testing::InitGoogleTest(int *,char * *)" (?InitGoogleTest#testing##YAXPEAHPEAPEAD#Z)
1>main.obj : error LNK2001: unresolved external symbol "public: int __cdecl testing::UnitTest::Run(void)" (?Run#UnitTest#testing##QEAAHXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: static class testing::UnitTest * __cdecl testing::UnitTest::GetInstance(void)" (?GetInstance#UnitTest#testing##SAPEAV12#XZ)
Apparently, Visual Studio does not know it should link with gtest.lib. And I cannot understand why. Vcpkg only says that "Linking will be handled automatically." No idea how it is going to do this.
In "Additional Library Dependencies" of my project I can see these inherited values:
$(VcpkgRoot)lib
$(VcpkgRoot)lib\manual-link
And $(VcpkgRoot) is resolved to e:\work\vcpkg\installed\x64-windows\. So it seems like integration was successful. But how Visual Studio knows it should link with gtest.lib?
Note that if I add gtest.lib to "Additional Dependencies" manually, all works fine, and gtest.dll is automatically copied to output directory.
I think that the autolinking behavior has been intentionally disabled for gtest, see vcpkg issue #306.
Original comment on the issue: here.
The vcpkg implementation requires manual linking because Google Test can redefine main(), and the gtest functionality is duplicated in all of the four separate library files.
Official documentation.
The required per project configuration:
In: Configuration Properties > Linker > Input > Additional Dependencies
For release-builds:
$(VcpkgRoot)lib\manual-link\gtest_main.lib
For debug-builds:
$(VcpkgRoot)debug\lib\manual-link\gtest_main.lib
If you want to create your own custom main(), replace gtest_main.lib with gtest.lib.
If you want to use gmock, you can replace it with gmock_main.lib or gmock.lib.
This is an old thread but I would like to point out what I've found.
You need to link the libs in the manual-link directory, but you need to link them in the right order.
First link gmock_main then gtest_main.
The other way around just results in 0 test.
I downloaded and built the boost libraries (version 1.47.0) on Windows 7 (64bit) following the instructions here.
Now when I want to use the Boost::Filesystem library I can include the header file without issue and it compiles my code file. The problem arises at linking. I get the following errors;
main.obj : error LNK2019: unresolved external symbol "class boost::filesystem3::file_status __cdecl boost::filesystem3::detail::status(class boost::filesystem3::path const &,class boost::system::error_code *)" (?status#detail#filesystem3#boost##YA?AVfile_status#23#AEBVpath#23#PEAVerror_code#system#3##Z) referenced in function "bool __cdecl boost::filesystem3::exists(class boost::filesystem3::path const &)" (?exists#filesystem3#boost##YA_NAEBVpath#12##Z)
main.obj : error LNK2019: unresolved external symbol "private: static class std::codecvt<wchar_t,char,int> const * & __cdecl boost::filesystem3::path::wchar_t_codecvt_facet(void)" (?wchar_t_codecvt_facet#path#filesystem3#boost##CAAEAPEBV?$codecvt#_WDH#std##XZ) referenced in function "public: static class std::codecvt<wchar_t,char,int> const & __cdecl boost::filesystem3::path::codecvt(void)" (?codecvt#path#filesystem3#boost##SAAEBV?$codecvt#_WDH#std##XZ)
(amongst others)
It might be worth noting that when I first tried to build the project it said it couldn't find the .lib file libboost_filesystem-vc100-mt-1_47.lib. I hadn't specifically told it it needed that file so not sure how it figured that out? Either way I pointed the linker to the correct directory and then it gave the above errors.
Does anybody know how to fix this problem? Thanks.
Edit: I'm using VS2010 toolchain through eclipse CDT to build the system. The complete compile command is
cl /c /EHs /MD /Zi /I"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include" /I"C:\boost_1_47_0" /nologo <SOURCE_FILE>
and the linker command
link /debug /nologo /libpath:C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64 /libpath:C:\boost_1_47_0\stage\lib /libpath:C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64 /OUT:<EXE_NAME> <OBJECT_FILES>
Rebuild the Boost library with address-model=64 b2 command line switch. This builds 64 bit libraries.
If you're on linux and happen upon this article looking for the fix the fix is (at least on ubuntu 12.10) to install the development package for boost filesystem:
sudo apt-get install libboost-filesystem-dev
That installs the correct libraries for linking to and all works well.