I'm getting the following (and many more) errors when attempting to link my project statically with boost.log on MSVC 10.0:
1>libboost_log-vc100-mt-gd-1_53.lib(attribute_name.obj) : error
LNK2001: unresolved external symbol "**__declspec(dllimport)** public:
__thiscall std::_Container_base::~_Container_base(void)" (__imp_??1_Container_base#std##QAE#XZ)
1>libboost_log-vc100-mt-gd-1_53.lib(text_file_backend.obj) : error
LNK2001: unresolved external symbol "**__declspec(dllimport)** public:
__thiscall std::_Container_base::~_Container_base(void)" (__imp_??1_Container_base#std##QAE#XZ)
Note that the project is linking also to boost system, filesystem, and thread libraries.
1> Searching ../lib/\libboost_system-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_date_time-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_regex-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_thread-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_chrono-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_log-vc100-mt-gd-1_53.lib:
1> Searching ../lib/\libboost_filesystem-vc100-mt-gd-1_53.lib:
My project does not define the BOOST_ALL_DYN_LINK or BOOST_LOG_DYN_LINK macros, so I was not expecting to see the __declspec signatures, which I am thinking is the ultimate problem. Am I missing something required to properly link this library statically?
Update
I removed precompiled headers on my project and performed a "clean", and everything linked fine. Is it possible that precompiled headers were somehow causing the project to link statically to CRT?
You may need link log_setup firstly and then log before filesystem and so on, this was boost link code in my CMakeLists.txt:
set(USED_BOOST_LIBS ${Boost_LOG_SETUP_LIBRARY} ${Boost_LOG_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY}
${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY}
)
...
target_link_libraries(myexe ${USED_BOOST_LIBS})
It works fine with me both on MSVC 14.0 and gcc 4.8.You can try it.
Related
I'm new to CMake and also new to compiling mixed source, I have received the following errors while trying to compile using CMake and Visual Studio 14.0
(Link target) ->
main.obj : error LNK2001: unresolved external symbol ethash_get_cachesize
main.obj : error LNK2001: unresolved external symbol ethash_get_datasize
The layout of my project is like this:
I have ethash_get_cachesize and ethash_get_datasize defined in internal.c in a directory ethminer/libethash/ these are C source. im sure that the CMake file that came with this set of sources is ok as the project has compiled before without issue, it has only given me LINK problems after i have added the following:
I have another directory /ethminer/dag/ with a C++ source "dag.cpp" and "dag.h" these are both C++ files. and the CMake file.
set(SOURCES
DAG.h DAG.cpp
)
include_directories(BEFORE ..)
link_directories(BEFORE ..)
the C++ source file "dag.cpp" includes #include <libethash/internal.h>
however I fear that I am missing something to tell CMake or Visual Studio to find the files it needs from the directory containing "internal.c"
any help would be much appreciated
I built boost latest version (64 bit, msvc-10.0). When using the libraries with my project getting following linker error:
error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?
Things checked:
1. Libraries are present in the path specified
2. Built 64-bit boost library
3. Using latest boost headers, etc..
Any suggestions?
I've experienced the same problem when using some header-only boost library. The problem is some libraries are themselves header-only, but they depend on boost.system which need be linked against your program.
I'm using Visual Studio 2010 and I've installed openmpi and boost. I've successfully managed to build the boost mpi libraries but when I try to run their example hello_world program I get linking errors like:
Error 16 error LNK2001: unresolved external symbol "public: void __cdecl boost::mpi::communicator::send(int,int,class boost::mpi::packed_oarchive const &)const " (??$send#Vpacked_oarchive#mpi#boost###communicator#mpi#boost##QEBAXHHAEBVpacked_oarchive#12##Z) C:\Dropbox\mpi_tess\MPITess\hello_world.obj
I've included the build lib files into the linker path. Any ideas what's wrong?
Thanks for the help,
Elad
I develop addons for a space flight simulator called Orbiter: http://orbit.medphys.ucl.ac.uk/
It accepts plugins as dll files. I recently made a plugin which uses the Bullet physics library as well. Its statically linked to the dll, so the bullet library is itself not a dll but compiled right into the plugin. Bullet is compiled with Multi-threaded (/MT) option for the release and Multi-threaded Debug (/MTd) for debug
Now I want to use threads from Boost. So I installed the static Boost libraries by choosing the 2 static options from the Boost Pro installer. I was able to successfully create a Win 32 application with these static libraries. The application used Multi-threaded (/MT) as well. So I know that there is no mismatch on the flags.
Yet, when I add Boost to my Orbiter dll plugin project, which also has Bullet, I get a link error :
1>------ Build started: Project: Bump, Configuration: Release Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(F:\Orbiter\Orbitersdk\samples\BumpThreaded\Release\Bump.dll) does not match the Linker's OutputFile property value (F:\Orbiter\Modules\Plugin\Bump.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info##AAE#ABV0##Z) already defined in LIBCMT.lib(typinfo.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info##AAEAAV0#ABV0##Z) already defined in LIBCMT.lib(typinfo.obj)
1> Creating library F:\Orbiter\Orbitersdk\samples\BumpThreaded\Release\Bump.lib and object F:\Orbiter\Orbitersdk\samples\BumpThreaded\Release\Bump.exp
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>......\Modules\Plugin\Bump.dll : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========
From what I read on other questions, this can be due to mismatched flags for 2 libraries being used within an application. But thats not the case here. Both Bullet and Boost are compiled with /MT.
Also boost works ok with a normal win 32 application, so why the problem when linking it statically to output a dll ?
I use visual studio 2010 express and have a windows 7 64 bit system.
Thanks for any help in advance :)
If you're only using Boost and Bullet, and these are both definitely compiled with /MT, then it must be your Bump dll itself which is using /MD.
Visual Studio 2005
I am linking with boost libraries release 1_33_1.
I keep getting this link error.
libboost_thread-vc80-mt-sgd-1_33_1.lib(once.obj) :error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran#_String_base#std##QBEXXZ)
Does anyone have any suggestions?
Many thanks,
Edit ======
After recompiling the boost libraries using these switches:
C:\boost_1_42_0>bjam --build-dir=d:\boost_1_42 --build-type-complete --toolset=msvc-8.0 address-model=32 architecture=x86
I am getting some of the following errors:
1>msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info##AAEAAV0#ABV0##Z) already defined in LIBCMTD.lib(typinfo.obj)
1>msvcrtd.lib(MSVCR80D.dll) : error LNK2005: __wassert already defined in LIBCMTD.lib(wassert.obj)
Anyone have any ideas?
Many thanks,
First of all you don't have to set address-model and architecture explicitly if building 32 bit. Also your call has an error: --build-type-complete should be --build-type=complete. If I'm not wrong your call builds absolutely all libs, including filesystem, regex etc.
Obviously you need boost::thread only, so I would recommend to try this call:
C:\boost_1_42_0>bjam --build-dir=d:\boost_1_42 --build-type=complete --toolset=msvc-8.0 --with-thread
But I don't think that will solve your prob but you could give it a try.
My guess is that you somehow mixed /MD and /MT in the project settings.
See these links: First, second
What is probably happening is that your project is linking to the static debug version of the C++ runtime, which causes the static debug boost thread library to be linked and is also linking to another static library which was dynamically linked to the C++ runtime.
The sgd tag in libboost_thread-vc80-mt-sgd-1_33_1.lib means that the boost thread library you're linking with was built against the static debug version of the C++ runtime.